LB Booster
« GOTO Problem »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:07am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: GOTO Problem  (Read 828 times)
Cheemag
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx GOTO Problem
« Thread started on: Feb 14th, 2015, 2:39pm »

Hello again so soon,

This routine misbehaves in that the last line refuses to goto [Start]. The programme terminates there. The other two goto [Start] instances do in fact go back to [Start] but not the last one. Why?

[Start]
cls:e=0:locate 2,7tonguerint"Locate Auth......A"
locate 2,9tonguerint"Decode Call......D"
locate 2,11tonguerint"# to Exit"
g$=input$(1):g$=lower$(g$):if g$=chr$(13) or g$="#" then cls:end
if g$<>"a"and g$<>"d"then e=5
if e=5 then playwave"Chord.wav",async:goto [Start]
if g$="d"then call Decode fn$:goto [Start]

open fn$ for input as#1:input#1,i
for y=1 to i:input#1,a$:a$(y)=a$:next:close #1

locate 2,2tonguerint"Auth .....Choose up to Three"
for y=1 to i:locate 2,y+3tonguerint a$(y):nexttonguerinttonguerint" Any Key for Menu"
g$=input$(1):goto [Start]

Regards,

Cheemag
User IP Logged

Regards,

Cheemag
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: GOTO Problem
« Reply #1 on: Feb 14th, 2015, 2:54pm »

on Feb 14th, 2015, 2:39pm, Cheemag wrote:
The other two goto [Start] instances do in fact go back to [Start] but not the last one. Why?

It works for me. If I delete the file-reading lines (I don't have the file) pressing A causes "Auth .....Choose up to Three" to be printed and then pressing any key restarts. So I don't know why it doesn't work for you, but have you tried using the debugger?

I expect you are aware that your code is poorly structured. That is your choice, but it makes fault-finding more difficult, particularly for other people.

When listing code in a post please put it in a [code] block, so it is not mangled by the forum software.

Richard.
User IP Logged

Cheemag
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx Re: GOTO Problem
« Reply #2 on: Feb 14th, 2015, 3:35pm »

on Feb 14th, 2015, 2:54pm, Richard Russell wrote:
It works for me. If I delete the file-reading lines (I don't have the file) pressing A causes "Auth .....Choose up to Three" to be printed and then pressing any key restarts. So I don't know why it doesn't work for you, but have you tried using the debugger?


It works for me if I take the file reads and filenames out.
I haven't yet had the course on using the debugger.

Quote:
I expect you are aware that your code is poorly structured.


Of course it's poorly structured - I'm a novice.

I'll try re-writing it.

Regards,

Cheemag

PS It runs in LB !
User IP Logged

Regards,

Cheemag
Cheemag
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx Re: GOTO Problem
« Reply #3 on: Feb 14th, 2015, 5:19pm »

on Feb 14th, 2015, 3:35pm, Cheemag wrote:
I wrote:


No matter whether I stick with the for/next or use while/wend, as long as the second last line with the locate and the print a$(y) is present, it will not run as intended as an LBB compile.

I've had to arrange that it runs in LB.

Regards,

Cheemag

User IP Logged

Regards,

Cheemag
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: GOTO Problem
« Reply #4 on: Feb 14th, 2015, 5:51pm »

on Feb 14th, 2015, 5:19pm, Cheemag wrote:
as long as the second last line with the locate and the print a$(y) is present, it will not run as intended as an LBB compile.

I cannot reproduce that. Please copy-and-paste this program, exactly as shown, into LBB v2.86 and compile it to an exe:

Code:
[Start]
cls:e=0:locate 2,7:print"Locate Auth......A"
locate 2,9:print"Decode Call......D"
locate 2,11:print"# to Exit"
g$=input$(1):g$=lower$(g$):if g$=chr$(13) or g$="#" then cls:end
if g$<>"a"and g$<>"d"then e=5
if e=5 then playwave"Chord.wav",async:goto [Start]
if g$="d"then call Decode fn$:goto [Start]

'open fn$ for input as#1:input#1,i
'for y=1 to i:input#1,a$:a$(y)=a$:next:close #1

locate 2,2:print"Auth .....Choose up to Three"
for y=1 to i:locate 2,y+3:print a$(y):next:print:print" Any Key for Menu"
g$=input$(1):goto [Start] 

Now run the executable and press A followed by any other key. Here, it behaves as I would expect. What happens when you try it?

If you enable the file-reading code be very careful to ensure your strings contain no 'non-printing' characters (e.g. codes in the range 0-31). LB4 tends to ignore such characters, but in LBB they are control characters that can have all sorts of unwanted (or wanted!) effects.

Quote:
I've had to arrange that it runs in LB.

I am confident that it runs correctly in LBB.

Richard.
User IP Logged

Cheemag
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx Re: GOTO Problem
« Reply #5 on: Feb 15th, 2015, 11:52am »

on Feb 14th, 2015, 5:51pm, Richard Russell wrote:
I cannot reproduce that. Please copy-and-paste this program, exactly as shown, into LBB v2.86 and compile it to an exe:

Code:
[Start]
cls:e=0:locate 2,7:print"Locate Auth......A"
locate 2,9:print"Decode Call......D"
locate 2,11:print"# to Exit"
g$=input$(1):g$=lower$(g$):if g$=chr$(13) or g$="#" then cls:end
if g$<>"a"and g$<>"d"then e=5
if e=5 then playwave"Chord.wav",async:goto [Start]
if g$="d"then call Decode fn$:goto [Start]

'open fn$ for input as#1:input#1,i
'for y=1 to i:input#1,a$:a$(y)=a$:next:close #1

locate 2,2:print"Auth .....Choose up to Three"
for y=1 to i:locate 2,y+3:print a$(y):next:print:print" Any Key for Menu"
g$=input$(1):goto [Start] 

Now run the executable and press A followed by any other key. Here, it behaves as I would expect. What happens when you try it?

If you enable the file-reading code be very careful to ensure your strings contain no 'non-printing' characters (e.g. codes in the range 0-31). LB4 tends to ignore such characters, but in LBB they are control characters that can have all sorts of unwanted (or wanted!) effects.


I am confident that it runs correctly in LBB.

Richard.


It does, but the same code does not run when incorporated in the whole programme.

It's something to do with the array a$(). As soon as that print a$(y) line is put in, it will print a$(y), but fail the GOTO.

I'll try putting it in a subroutine.

Regards,

Cheemag
User IP Logged

Regards,

Cheemag
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls