My "from PACKAGE import *" (Python) simulation project (reflection)

Anything QL Software or Programming Related.
User avatar
polka
Trump Card
Posts: 212
Joined: Mon Mar 07, 2011 11:43 am

Re: My "from PACKAGE import *" (Python) simulation project (reflection)

Post by polka »

Here is this (unnumbered) file :

LRESPR DEV$ & 'ptr_gen'
LRESPR DEV$ & 'MacMouse11'
LRESPR DEV$ & 'wman'
LRESPR DEV$ & 'Qptr'

WINDOW#0,512,256,0,0:PAPER#0,0:INK#0,0:CLS#0
WINDOW#0,388,42,110,0:PAPER#0,2;:INK#0,7:BORDER#0,1,7
WINDOW#1,94,225,14,0:PAPER#1,0;:INK#1,7:BORDER#1,1,7
WINDOW#2,388,182,110,43:PAPER#2,0;:INK#2,4:BORDER#2,1,7
OPEN#3,'scr_512x31a0x225':PAPER#3,0;:INK#3,4

CFO = 0
IF CFO > 0 THEN
OPEN_OVER#4,DEV$ & "TOOB"
PRINT#4,"CFO = "; : PRINT#4,CFO
R = ALN("CFORMS",CFO,1)
TMO = R+1
PRINT#4,"TMO = "; : PRINT#4,TMO
R = ALN("TOP_MENU",TMO,1)
PMO = R+1
PRINT#4,"PMO = "; : PRINT#4,PMO
R = aln("PSION_MENU",PMO,1)
LMO = R+1
PRINT#4,"LMO = "; : PRINT#4,LMO
R = ALN("LANG_MENU",LMO,1)
CMO = R+1
PRINT#4,"CMO = "; : print#4,CMO
R = ALN("C68_MENU",CMO,1)
PRINT#4,"KO = CFO - 1 : OK = TMO"
PRINT#4,"DLINE 1 TO KO"
PRINT#4,"INITFORM : BYE"
CLOSE#4
END IF

MERGE DEV$ & "C68_MENU_bas"
MERGE DEV$ & "LANG_MENU_bas"
MERGE DEV$ & "PSION_MENU_bas"
MERGE DEV$ & "TOP_MENU_bas"
MERGE DEV$ & "CFORMS_bas"


The MANIFEST program will simply complete the boot process by LRESPR some binaries, managing some windows, adding line numbers to some unnumbered modules and finally MERGE them together. To be noted that ALN always overwrite and keeps only the latest _BAS versions of the modules. So when they are not modified, the ALN sequence could be skipped. It is : using simply the superbasic control structure IF ... ENDIF ; no need of special preprocessing (C like) conditionnal instructions.


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 212
Joined: Mon Mar 07, 2011 11:43 am

Re: My "from PACKAGE import *" (Python) simulation project (reflection)

Post by polka »

When the ALN section is not skipped (because you needed to update the _BAS modules and thus set CFO > 0 ), it will also create or update (overwrite) a file called TOOB, to be MRUN by intruction 32741 of the boot file. Ha ha ! What is this ? Here the TOOB file when in MANIFEST, instead of CFO = 0 you have CFO = 32601 :

CFO = 32601
TMO = 32702
PMO = 32712
LMO = 32722
CMO = 32732
KO = CFO-1 : OK = TMO
DLINE 1 TO KO
INITFORM : BYE


It will set some variables to the first line numbers of the modules loaded and KO to the last possible line number before the boot program and OK to the first line number of the top menu, that will be called by BYE after having erased the (no longer useful) MANIFEST with :

DLINE 1 TO KO

Why remember the first line numbers of the modules ? Here for instance the TOP_MENU module :

32702 DATA 208,7,' PSION ',' SUITE '
32703 DATA 208,7,' PROLOG ',' and FORTH '
32704 DATA 208,7,' C68 ','programming'
32705 DATA 2,7,' QJUMP ',' Q R A M '
32706 DATA 80,7,' SUPER ',' BASIC '
32707 OK=32712 : PAPER#2,0:INK#2,4:CLS#2 : bye
32708 OK=32722 : PAPER#2,0:INK#2,4:CLS#2 : bye
32709 OK=32732 : PAPER#2,0:INK#2,4:CLS#2 : C68 : bye
32710 EXEC DEV$ & 'QRAM' : bye
32711 CLS:CLS#0:PRINT#0,'Say BYE to quit SUPER BASIC':STOP


The BYE PROCedure will use TMO to restore and read five DATA instructions to display the function key labels of the TOP_MENU ; then use this same TMO for executing a "computed" GOTO at line 32766 selecting one from five "target" intructions.

The three first target intructions simply update OK so that BYE will go to respective submenus. Line 32710 is a target for QRAM and line 31711 (ending with STOP) will simply reactuate the superbasic console in window #0.

Imagine how these simple tools may let develop superbasic programs merging small modules written in plain vanilla superbasic, thus easily read and modified, witout having to bother about line re-numbering.

Some programming discipline tips I adopted : use preferably PROCedures and FuNctions for structuring everything, no GOTO nor GOSUB, and put the DATA at the beginning of the modules for remembering their first line numbers.


May the FORTH be with you !
POLKa
Derek_Stewart
Font of All Knowledge
Posts: 4718
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: My "from PACKAGE import *" (Python) simulation project (reflection)

Post by Derek_Stewart »

Hi,

The BasicLinker software is on the QL Hompage in the Software dowloads section : Programming Section

or on Wolfgang's web site.


Regards,

Derek
User avatar
polka
Trump Card
Posts: 212
Joined: Mon Mar 07, 2011 11:43 am

Re: My "from PACKAGE import *" (Python) simulation project

Post by polka »

Hi,

I tried it, yes it works : with LOAD and also with MERGE but who would have had the idea to try such a simple thing ? Congratulation !
Derek_Stewart wrote: Wed Apr 23, 2025 7:05 am Hi,

I used to write numberless Superbasic programs in QED, on a Minerva based QL and could load the program into Superbasic and add line numbers with:

AUTO: LOAD <program>

Where <program> is a Superbasic progam without line numbers.

Due to a bug in Superbasic.

This does not work in SMSQ/E SBASIC.
Anyway, I would not call it a "bug", I would say it is a "feature" of SB.

Thank you also for pointing me to the BasicLinker tool, I will try it, it seems interesting.


May the FORTH be with you !
POLKa
User avatar
ql_freak
Super Gold Card
Posts: 500
Joined: Sun Jan 18, 2015 1:29 am

Re: My "from PACKAGE import *" (Python) simulation project (reflection)

Post by ql_freak »

TO MAKE IT CLEAR:

reflection.cde and rn are both under construction (the current rn version [don't know if I have already published it here], developed with Visual Studio and its great debugger) should now be in a v0.99.0 version (i.e. usable). reflection.cde IS NOT(!), my internal version number for (MY) current version (not yet published) is 0.0.3. Per has kindly looked into my code and have found some really hard bugs (I haven't programmed in 68k assembler for a long time). One warning from one of its posts to me:

"Running your original code more than a few times crashes QPC2 down to
Windows and Qemulator siezes up, so, considering your code has had nearly
30 downloads, you should warn people and ask them to download the fixed
version so they dont lose their precious data and hate you forever! ;o)"

Note: I'm currently only testing with sQLUX 1.1 (english version on German keyboard, arrggghhh...). Problem with QPC2, it's not fully compatible to a BBQL (as Minerva on UQLX/sQLux) and Qemulator does not support high resolution as sQLux/UQLX.

Unfortunately I'm currently really short of time (my father, 93, needs help, I have a job, ...). I want to implement one further function, before I will release a first version (with source), but this will IMHO be a great enhancement to SuperBASIC (if I will succeed).


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
ql_freak
Super Gold Card
Posts: 500
Joined: Sun Jan 18, 2015 1:29 am

Re: My "from PACKAGE import *" (Python) simulation project

Post by ql_freak »

polka wrote: Mon Jun 02, 2025 8:35 am
Derek_Stewart wrote: Wed Apr 23, 2025 7:05 am I used to write numberless Superbasic programs in QED, on a Minerva based QL and could load the program into Superbasic and add line numbers with:

AUTO: LOAD <program>

Where <program> is a Superbasic progam without line numbers.
Anyway, I would not call it a "bug", I would say it is a "feature" of SB.
Once again(!): It's NOT a bug, it's documented in Jan Jones "SuperBASIC THE  D E F I N I V E  H A N D B O O K" in chapter 9:

"If you have a non-line-numbered file like this that you want to read as a line
numbered SuperBASIC program, you can say
AUTO
at the keyboard, then delete the line number printed (don’t BREAK!) and enter
LOAD filename
AUTO will then obligingly put a line number in front of every line for you. Try it
with the above file like so,
AUTO
Delete the four chars to the left and type
LOAD mdv1_loadtest
CTRL and space … to BREAK out of AUTO
LIST
Lo and behold!
You can also achieve the same effect by having AUTO as the first line of your
non-line-numbered file. For example,
OPEN #3, mdv1_loadtest: OPEN_NEW #4, mdv1_autotest
PRINT #4,’auto’
REPeat p: INPUT #3,a$: PRINT #4,a$
CLOSE #3: CLOSE #4
Load mdv1_autotest
CTRL and space … to BEAK out of auto
LIST
Clever, eh?"

This does unfortunately NOT work on QPC2 (SBASIC).


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 :-)
Post Reply