Blitz
|
 |
« Reply #30 on: March 18, 2004, 06:29:17 PM » |
|
Exactly, the crappiest evarrrrr.
|
|
|
Logged
|
oship me and i will give you lots of guurrls and beeea
|
|
|
Agamemnus
|
 |
« Reply #31 on: March 18, 2004, 07:04:23 PM » |
|
It's better than nothing.
What kind of error handling system do you suggest, anyways???
|
|
|
Logged
|
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war." Visit www.neobasic.net to see rubbish in all its finest.
|
|
|
na_th_an
|
 |
« Reply #32 on: March 18, 2004, 08:48:19 PM » |
|
You can do the error handling yourself. Check stuff that may fail.
|
|
|
Logged
|
|
|
|
R@dioman
|
 |
« Reply #33 on: March 18, 2004, 10:17:42 PM » |
|
Nathan wrote: You can do the error handling yourself. Check stuff that may fail.
Suppose you're initializing something, like your sound, or memory. Write it as a function that sends back 0 if everything went alright, or sends an error code explaining the error if something failed.
|
|
|
Logged
|
|
|
|
oracle
|
 |
« Reply #34 on: March 19, 2004, 12:44:52 AM » |
|
Which is exactly how it should be done, and is done in my project. ps: for those of you who want to quote somebody without using the quote button: persons_text
|
|
|
Logged
|
|
|
|
Neo
|
 |
« Reply #35 on: March 22, 2004, 07:17:55 AM » |
|
Hehe. We made the prettiest Initialization routine ever... 
|
|
|
Logged
|
|
|
|
adosorken
|
 |
« Reply #36 on: March 22, 2004, 10:47:15 AM » |
|
GOTO: Spaghetti code (sometimes causing stack error as well) GOTOs boil down to a JMP and do not use stack space. I have no idea where you pulled this one from. :  : Btw, why, why, why does ON ERROR only support GOTO and not CALL SUB or so...  My theory is that QB was developed at a time when companies were still being weaned off of line numbers for BASIC programming. 
|
|
|
Logged
|
I'd knock on wood, but my desk is particle board.
|
|
|
Neo
|
 |
« Reply #37 on: March 23, 2004, 07:22:49 AM » |
|
GOTOs boil down to a JMP and do not use stack space. I have no idea where you pulled this one from. :  : Using a lot of GOTOs in your code makes your code spaghetti. You can't exactly see how the program runs when looking at the code. (try Aga's code... j/k :rotfl: )
|
|
|
Logged
|
|
|
|
na_th_an
|
 |
« Reply #38 on: March 23, 2004, 10:35:12 AM » |
|
But it has nothing to do with the Stack. It may be ugly and unreadable, but it ain't unefficient or dangerous.
|
|
|
Logged
|
|
|
|
adosorken
|
 |
« Reply #39 on: March 23, 2004, 11:48:30 AM » |
|
On the contrary...being from a C64 BASIC and assembly background, spaghetti code to me is far more readable than procedural code because I can just scroll around spaghetti code but have to keep hitting the F2 key for procedural code and it's a pain in the ass to be honest. I can read Agamemnus' code just fine and I'd have to say he's one of the best coders here. Of course, not everyone has a background in writing efficient spaghetti code  so I guess this doesn't apply to some 
|
|
|
Logged
|
I'd knock on wood, but my desk is particle board.
|
|
|
na_th_an
|
 |
« Reply #40 on: March 23, 2004, 12:47:48 PM » |
|
I come from Spaghetti realms as well, I coded in my ZX Spectrum from 1988 to 1993. I can read Aga's code as well and I think he's one of the best coders here, as well. But I could change my mind and benefit from the advantages that procedural approaches have over line_numbers-GOTO'ed-GOSUB'ed-non_block_IF'ed-etc approaches  This is code from a ZX Spectrum game I was coding this summer: this moves the enemies  2000 REM selectGFX 2010 LET aa=PEEK (dir+6): GO SUB 930 2015 IF PEEK (dir+7)=0 THEN GO TO 2050: REM left 2025 IF PEEK (dir+4)=1 THEN GO TO 2040 2030 IF p THEN LET f$="./": GO TO 2032 2031 LET f$="01" 2032 LET e$=",-": RETURN 2040 IF p THEN LET f$=":;": GO TO 2042 2041 LET f$="<=" 2042 LET e$="89": RETURN 2050 IF PEEK (dir+4)=1 THEN GO TO 2070 2060 IF p THEN LET f$="45": GO TO 2062 2061 LET f$="67" 2062 LET e$="23": RETURN 2070 IF p THEN LET f$="@A": GO TO 2072 2071 LET f$="BC" 2072 LET e$=">?": RETURN 2100 REM ENEMIGOS-MOVER 2110 FOR i=1 TO 2 2111 LET dir=benem+16*px+80*py+(i-1)*8 2120 GO SUB 2000: REM selectGFX 2132 LET old=PEEK (dir+6) 2140 POKE dir+6,PEEK (dir+6)+PEEK (dir+7)-1 2150 IF PEEK (dir+6)=PEEK (dir+1) OR PEEK (dir+6)=PEEK (dir+2) THEN POKE dir+7, 1-(PEEK (dir+7)-1) 2155 IF PEEK dir THEN GO TO 2200 2157 REM HORIZONTAL 2160 IF old<PEEK (dir+6) THEN PRINT PAPER ps; INK is;AT PEEK (dir+3)-1,PEEK (dir+6)-1;"a"; INK PEEK (dir+5);e$;AT PEEK (dir+3),PEEK (dir+6)-1; INK is;"a"; INK PEEK (dir+5);f$: GO TO 2180 2170 PRINT PAPER ps; INK PEEK (dir+5);AT PEEK (dir+3)-1,PEEK (dir+6);e$; INK is;"a"; INK PEEK (dir+5);AT PEEK (dir+3),PEEK (dir+6);f$; INK is;"a" 2180 IF PEEK (dir+6)>=a-1 AND PEEK (dir+6)<=a+1 AND PEEK (dir+3)>=w-1 AND PEEK (dir+3)<=w+1 THEN LET vi=vi-1: GO SUB 701 2181 GO TO 2300 2200 REM VERTICAL 2210 IF old<PEEK (dir+6) THEN PRINT PAPER ps;AT PEEK (dir+6)-2,PEEK (dir+3); INK is;"aa"; INK PEEK (dir+5);AT PEEK (dir+6)-1,PEEK (dir+3);e$;AT PEEK (dir+6),PEEK (dir+3);f$: GO TO 2230 2220 PRINT PAPER ps;AT PEEK (dir+6)+1,PEEK (dir+3); INK is;"aa"; INK PEEK (dir+5);AT PEEK (dir+6)-1,PEEK (dir+3);e$;AT PEEK (dir+6),PEEK (dir+3);f$ 2230 IF PEEK (dir+6)>=w-1 AND PEEK (dir+6)<=w+1 AND PEEK (dir+3)>=a-1 AND PEEK (dir+3)<=a+1 THEN LET vi=vi-1: GO SUB 701 2300 NEXT i 2301 RETURN That's Spaghetti, kiddo  It's better to go procedural/structured 'cause it is easier to understand other languages, not just BASIC.
|
|
|
Logged
|
|
|
|
TheBigBasicQ
|
 |
« Reply #41 on: March 24, 2004, 05:02:02 AM » |
|
Nath that may be spagetti code for you but i've seen such code in most of the older books published around in the 70s and 80s. Just because we have more structured languages now doesnt mean that the code in the older languages is spagetti =).
|
|
|
Logged
|
|
|
|
Neo
|
 |
« Reply #42 on: March 24, 2004, 07:30:32 AM » |
|
But it has nothing to do with the Stack. It may be ugly and unreadable, but it ain't unefficient or dangerous. I wasn't talking about the stack or the ASM clone of the code  It's just unreadable to humans but for the computer, in ASM it is all the same, some jmps to a specified address, both with loops (DO, FOR, WHILE) and GOTOs.
|
|
|
Logged
|
|
|
|
na_th_an
|
 |
« Reply #43 on: March 24, 2004, 10:55:53 AM » |
|
Nath that may be spagetti code for you but i've seen such code in most of the older books published around in the 70s and 80s. Just because we have more structured languages now doesnt mean that the code in the older languages is spagetti =). That depends on what you call spaghetti code. I call it "spaghetti code" when the code looks like a plate of spaghetti: You follow a "run path" and it goes to line 10, keeps on to line 110, then it GOTOs to line 20, then it GOTOs to line 2000, having GOSUBed to line 6500... Like a plate of spaghetti, where every spaghetto is twisted, tied, and goes around other spaghetti. That's the metaphor I think the therm is based on  Therefore ol' 8 bits dialects of BASIC are spaghetti makers  Neo: I was replying to this concrete phrase: GOTO: Spaghetti code (sometimes causing stack error as well) You said that GOTO "sometimes causes stack error as well", but that will never happen as GOTOs doesn't touch the stack.
|
|
|
Logged
|
|
|
|
|