qbiscool
Member

Posts: 56
|
 |
« Reply #15 on: March 15, 2004, 07:27:23 PM » |
|
or if you realy want to you could use goto's input "hit a key"; j$ if j$ = "w" then print "you hit w" else if j$ = "r" then print "you hit r" else print "you hit "j$ end if
or on error goto goterror print "hit a key or esc to exit" do key$ = inkey$ do loop until key$ <> "" print key$ if key$ <> chr$(27) then loop else system system
goterror: print "found error" do print "[r]etry, gnore, [f]ail" do key$ = inkey$ if key$ = "r" then resume if key$ = "i" then resume next if key$ = "f" then system loop until key$ <> "" loop
|
|
|
Logged
|
pen your other eyes.........
|
|
|
TheBigBasicQ
|
 |
« Reply #16 on: March 16, 2004, 07:46:41 AM » |
|
/me thinks aga is insane =P
Qbiscool. goto statements are dangerous at the hands of a newbie =(. So I would rather advice him to use gosub.
|
|
|
Logged
|
|
|
|
Neo
|
 |
« Reply #17 on: March 16, 2004, 09:42:12 AM » |
|
Qbiscool. goto statements are dangerous at the hands of a newbie =(. So I would rather advice him to use gosub. So... you discriminate people on their knowledge and then say either ' YOU SHOULD USE SUBs' (experienced) or ' YOU SHOULD USE GOSUB' (newb)...  Ah, yes, I like Aga's example. It reads so much better. Some people may not like multiple statements on one line, but they sure make the code look nice. You can see the whole thing with one glance. I'd really like it though if it had some identing... 
|
|
|
Logged
|
|
|
|
TheBigBasicQ
|
 |
« Reply #18 on: March 16, 2004, 09:45:19 AM » |
|
No, i wasnt discriminating =P. I was just saying that goto is dangerous. I dont like GOSUB(personally) so I suggested SUB =).
|
|
|
Logged
|
|
|
|
Neo
|
 |
« Reply #19 on: March 16, 2004, 09:48:02 AM » |
|
*Inproper* use of GOSUB: Out of stack space GOTO: Spaghetti code (sometimes causing stack error as well) SUBS: Optimal procedural programming. I think I agree with you  Btw, why, why, why does ON ERROR only support GOTO and not CALL SUB or so... 
|
|
|
Logged
|
|
|
|
TheBigBasicQ
|
 |
« Reply #20 on: March 16, 2004, 09:49:48 AM » |
|
How how how should I know =P? But I dont find it inconvinient =P.
|
|
|
Logged
|
|
|
|
Agamemnus
|
 |
« Reply #21 on: March 16, 2004, 09:50:02 AM » |
|
Simple. My program modified to have tabs: DO '7 tabs INPUT "Enter the !#$!@#$@#$ key already!!", ikey '1 tab SELECT CASE ikey '5 tabs CASE "1": key1: EXIT DO '5 tabs CASE "2": key2: EXIT DO '5 tabs CASE ...... CASE ELSE: PRINT "INVALID!" '4 tabs END SELECT '6 tabs LOOP '7 tabs
|
|
|
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.
|
|
|
TheBigBasicQ
|
 |
« Reply #22 on: March 16, 2004, 09:51:15 AM » |
|
Simple. My program modified to have tabs: DO '7 tabs INPUT "Enter the !#$!@#$@#$ key already!!", ikey '1 tab SELECT CASE ikey '5 tabs CASE "1": key1: EXIT DO '5 tabs CASE "2": key2: EXIT DO '5 tabs CASE ...... CASE ELSE: PRINT "INVALID!" '4 tabs END SELECT '6 tabs LOOP '7 tabs
I dont get the relevance?
|
|
|
Logged
|
|
|
|
Neo
|
 |
« Reply #23 on: March 16, 2004, 09:52:36 AM » |
|
Simple. My program modified to have tabs: Hrmmm... where are the tabs? I meant something like this: DO INPUT "Enter the !#$!@#$@#$ key already!!", ikey SELECT CASE ikey CASE "1": key1: EXIT DO CASE "2": key2: EXIT DO CASE ...... CASE ELSE: PRINT "INVALID!" END SELECT LOOP
|
|
|
Logged
|
|
|
|
Moneo
|
 |
« Reply #24 on: March 16, 2004, 11:49:08 PM » |
|
Neo, I have a feeling that Aga doesn't waste time indenting or formating sample code. I guesss he figures if you like it you'll adopt it and format it to your taste. *****l
|
|
|
Logged
|
|
|
|
Agamemnus
|
 |
« Reply #25 on: March 17, 2004, 12:16:42 AM » |
|
tBBQ: in response to Neo. In regards to GOSUBs, I think that they're usually not necessary, but they still have use. I think that there could have been a lot more done with QB4.5's GOSUB/SUB thing, such as multiple layers:
1) Commands in one SUB don't respond to labels in other SUBs, but the label namespace is global not local. (ie. only one "blah:" per program)
2) GOSUBs are a nice organizational tool when you have a lot of SUBs or very few SUBs. Could make the IDE a lot cooler if you could see GOSUBs in a SUB, and maybe SUBs in SuperSUBs. (ie modules)
Neo: After the code and before the comments.
Moneo: Yup, yup, very sensible...
|
|
|
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.
|
|
|
qbiscool
Member

Posts: 56
|
 |
« Reply #26 on: March 17, 2004, 08:51:02 PM » |
|
hey for that ON ERROR GOTO goterror could i use two ON ERROR's like this: ON ERROR GOTO 1 bload "",d,3
on error goto 2 open "" for output as #1 close #1
1 resume next
2 system
|
|
|
Logged
|
pen your other eyes.........
|
|
|
whitetiger0990
|
 |
« Reply #27 on: March 17, 2004, 11:33:22 PM » |
|
Like this? CLS ON ERROR GOTO 1 OPEN "aBaBaB1" FOR INPUT AS #1 ON ERROR GOTO 2 OPEN "aBaBaB2" FOR INPUT AS #1 CLOSE #1 END 1 PRINT 1 RESUME NEXT
2 PRINT 2 RESUME NEXT hmm, guess so. it prints 1 and 2. (and if you remove one of the OPENs it only prints one number so...)
|
|
|
Logged
|
 [size=10]Back by popular demand! I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
|
|
|
Blitz
|
 |
« Reply #28 on: March 18, 2004, 09:12:41 AM » |
|
QBs error handling is the crappiest evarrr.
|
|
|
Logged
|
oship me and i will give you lots of guurrls and beeea
|
|
|
TheBigBasicQ
|
 |
« Reply #29 on: March 18, 2004, 12:11:03 PM » |
|
Nope you put only one ON ERROR statement. In order to check which error actually caused your error handler to be called you would use ERR command. Like this: CLS ON ERROR GOTO errhandler
CHDIR "e:"
END errhandler: IF ERR = 71 THEN PRINT "ErrorHandler: device not ready" ELSEIF ERR = 76 THEN PRINT "ErrorHandler: Invalid drive specification" END IF
RESUME NEXT Change the drive letter to a non existing one and you will trap the second error while change it to "a:" and dont put any floppy into it and you will have it catch the first error =)
|
|
|
Logged
|
|
|
|
|