Expanding the range of QL Adventures

Anything QL Software or Programming Related.
User avatar
tofro
QL Wafer Drive
Posts: 1289
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Expanding the range of QL Adventures

Postby tofro » Thu Jan 25, 2018 9:59 am

Cristian wrote:100 DEFine PROCedure doSomething(dng)
110 some calculations
120 IF done THEN EXIT doSomething
130 do some more
140 END DEFine doSomething

You should utilize EXIT and place the END DEFine at the very end of the procedure.
And thanks for your nice game!


No you shouldn't. EXIT (at least on SBASIC) will only work to exit from loops (REPeat, FOR). Your way of doing things produces an "undefined loop variable" error in SBASIC. The Turbo compiler will also choke on this line. SuperBASIC with its sloppy syntax check might probably accept this, I can't test at the moment.

Tobias


georgeo
Bent Pin Expansion Port
Posts: 91
Joined: Wed Aug 03, 2016 8:49 am

Re: Expanding the range of QL Adventures

Postby georgeo » Thu Jan 25, 2018 2:03 pm

Hi everyone,

A quick look at Jan Jones' book suggests that I should use RETURN if I want to exit a procedure before the end, which is what I have mostly done--except for the typo, which is probably what Martyn was referring to.

Thanks for your help,
George.


User avatar
Cristian
Gold Card
Posts: 438
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Expanding the range of QL Adventures

Postby Cristian » Thu Jan 25, 2018 7:43 pm

tofro wrote:
No you shouldn't. EXIT (at least on SBASIC) will only work to exit from loops (REPeat, FOR). Your way of doing things produces an "undefined loop variable" error in SBASIC. The Turbo compiler will also choke on this line. SuperBASIC with its sloppy syntax check might probably accept this, I can't test at the moment.

Tobias



Yes you're absolutely right Tobias, and thank you very much for your correction! Sorry! Never try to write code with a headache... I should take a pill and keep my hands far from the keyboard!



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 2 guests