SBASIC not compatible with SB: PROCedure in PROCedure

Anything QL Software or Programming Related.
Post Reply
User avatar
ql_freak
Gold Card
Posts: 354
Joined: Sun Jan 18, 2015 1:29 am

SBASIC not compatible with SB: PROCedure in PROCedure

Post by ql_freak »

When trying to run some of my games on QPC I have found an incompatibility of SBASIC.

I've tried to start Psion Chess from one of my old "Games Floppies". In the boot file there was a construct like this:

...
DeFine PROCedure something
DeFine PROCedure pat
do something
END DeFine PROCedure
END DeFine PROCedure
...

This gives an error in SBASIC (I think "Not implemented"(1), not sure). With SuperBASIC this was OK. It's one of my old floppies, and so I know, that this has been possible with SuperBASIC, but unfortunately not with SBASIC.

It isn't a great problem, because I know that I have a PSION Chess version which is executeable (as a job - I have been successful to run it with Extended Environment on Minerva - perfect Multitasking) and it would be easy to rewrite the boot program and write the pat-proc outside of the outer proc, but it's an incompatibility, which could result in problems for larger programs, where it is not so easy.

p.s.:
(1) Error is: At line nnn:nn DEFines may not be within other clauses

For an example see the attached screenshot
Attachments
SBASICincompatible001.jpg


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
vanpeebles
Commissario Pebbli
Posts: 2823
Joined: Sat Nov 20, 2010 7:13 pm
Location: North East UK

Re: SBASIC not compatible with SB: PROCedure in PROCedure

Post by vanpeebles »

Do you have any rare games hiding amongst those game floppies? :)


User avatar
tofro
Font of All Knowledge
Posts: 2724
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: SBASIC not compatible with SB: PROCedure in PROCedure

Post by tofro »

Peter,

yes, that's true. SBASIC checks against a number of possible quirks in programs that SuperBASIC didn't care about - A fact that has mostly been considered a bug in the interpreter. One of those is the proper nesting of PROCs and FuNcs.
Other languages like Pascal or MODULA allow you to basically hide a PROC or FuNc within another one (so that it will only be known to the construct it is contained in, and this is sometimes very handy, because you can also share local variables between inner and outer construct) - This is not the case in SuperBASIC, if you use such nesting there, the inner construct will still be known to the rest of the program, so there is actually not really a point in doing it - Most S*BASIC programmers would thus consider this bad practice. (At least to my eyes, it looks weird ;) )

Compilers like TURBO will btw not accept such constructs as well (QLiberator will most probably happily compile) - So if you want to use Turbo or run on SMSQ/E, you should keep your definitions properly apart.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1322
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: SBASIC not compatible with SB: PROCedure in PROCedure

Post by pjw »

...
DeFine PROCedure something
DeFine PROCedure pat
do something
END DeFine PROCedure
END DeFine PROCedure
...
Nested procedures arent implemented either in SuperBASIC or SBASIC. A lazy interpreter let a cheeky programmer get away with it in the instance above. A shame, its a nice idea..

Per


Per
dont be happy. worry
- ?
Post Reply