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

Anything QL Software or Programming Related.
User avatar
Giorgio Garabello
Gold Card
Posts: 299
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

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

Post by Giorgio Garabello »

NormanDunbar wrote: Mon Apr 21, 2025 7:42 am Morning Derek.

https://github.com/SinclairQL/Structure ... tag/2.7.2g

2.7.2g is the latest. Details in the docs as to what changed. One thing I added that is incompatible with Tim's version,the line continuation character is "/" in Tim's but in mine it's "/+" as I often use PRINT statements with the trailing slash to get a linefeed. Those lines were combined with the next one and caused MISTakes.

Cheers,
Norm.
I'm moving the discussion, otherwise we'll go OFF TOPIC


User avatar
Giorgio Garabello
Gold Card
Posts: 299
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

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

Post by Giorgio Garabello »

Derek_Stewart wrote: Mon Apr 21, 2025 7:06 am How do you run SSB from MicroEMACS?
Via FileInfo2

Giorgio


swensont
Forum Moderator
Posts: 322
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

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

Post by swensont »

Derek,

My latest version is here:
http://swensont.epizy.com/ssb272.zip

Norman has expanded it with some additional features.

The documentation for 2.7.2 details how to use SSB with MicroEmacs. That document is here:

http://swensont.epizy.com/SSB.pdf

See page 26 for a macro that calls SSBGO to execute SSB while still in MicroEmacs.

Tim


User avatar
ql_freak
Gold Card
Posts: 474
Joined: Sun Jan 18, 2015 1:29 am

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

Post by ql_freak »

Martin_Head wrote: Sat Apr 19, 2025 10:23 am I'm not sure exactly what you are trying to do. But could you pull the 'ED' code from the SMSQ/E sources, and modify it to take it's input from a file instead of the keyboard.
It seems you are not the only one who don't understand what I want to achieve. I have now written (currently only in SuperBASIC) the function ref_getLnHi which returns the currently highest SuperBASIC line. Jan's example unfortunately didn't work, but his explanation is correct and I found the SuperBASIC program structure in Jan Jones book in appendix C.

So here's another example, which hopefully makes it clearer what I want (and it's working). NOTE: Preliminary version. The program to merge must currently be without line numbers. I will extend rn so that it can renumber programs with line numbers. BUT I WILL NEVER SUPPORT GO TO, GO SUB (except perhaps for a special kind of computed line numbers). As ref_getLnHi is currently written in SuperBASIC it must be (of course) normally merged. I decided to load it at 10000 and all subsequent merged programs (without line numbers) are merged after it.
rnMergeTest1_1.png
rnMergeTest1_1.png (11.45 KiB) Viewed 209 times
rnMergeTest1_2.png
Attachments
rnMergeTestFiles.zip
other files for rnMergeTest example
(3.41 KiB) Downloaded 4 times
rn.zip
rn (add line numbers) executable program
(6.43 KiB) Downloaded 4 times


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

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

Post by ql_freak »

Yeah! I think I have completed the rn version which ALSO(!) accepts line numbers (it should be even possible to give it a file, where some lines have line numbers and others not) - that's really a beta version (OK in my mind but tested only once):
rnMergeTest2.png
Edit: The Change in Source Code (rn_c):

Code: Select all


int writeAndRenumLineNumbers(in, out, start, step)
    /* Second version  U N D E R   C O N S T R U C T I O N ! */
    FILE *in, *out; /* const */ short start, step;
{
    char buf[BUFSIZE], *bp, *eob, *ibp;
    int  cl /* Current Line */
        ,noc /* Number Of Chars written */
        ,lim /* limit of characters which can mostly be read */
        ,len /* length of line read */
        ,oldln /* storage for (preceeding) line number in input file - NOT NEEDED (required) */
        ;
    eob = buf + BUFSIZE; /* One char beyond last character ('\0') of buffer */

    for (cl=start; cl < MAX_LINE_NO; cl += step) {
        bp = buf;
        /* Write line number and space: */
        noc = sprintf(bp, "%d ", cl); /*  */
        bp += noc; /* set bp to terminating '\0' */

        lim = BUFSIZE - noc; /* Max characters inclusive '\0' remaining in buf */

        /* BEGIN Change 2nd VERSION */
          /* TODO: Read line number from in and get position of filepointer in in after read,
             then read from new filepointer the rest of line: */
        fscanf(in, "%d", &oldln); /* Eat an eventually preceeding line number, we don't need it */
        /* END Change 2nd VERSION */

        len = getline(in, bp, lim); /* Now get the line (without line number); len: Number of chars read */
      /*  
Edit:
It was really just one fscanf() in C (eat the line number from source [SuperBASIC] file) to correct the original rn program (which only worked with BASIC files without line numbers [_bat files]).

p.s.: If it really will be working –just tested once ;‑)
Attachments
rnWithLineNumberSupport.zip
(6.52 KiB) Downloaded 4 times


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 :-)
Derek_Stewart
Font of All Knowledge
Posts: 4652
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

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

Post by Derek_Stewart »

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.


Regards,

Derek
User avatar
ql_freak
Gold Card
Posts: 474
Joined: Sun Jan 18, 2015 1:29 am

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

Post by ql_freak »

Derek_Stewart wrote: Wed Apr 23, 2025 7:05 am AUTO: LOAD <program>

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

Due to a bug in Superbasic.
This is NOT a bug, it's documented in Jan Jones SuperBASIC book in Chapter 9 (page 89 in first version). And it's even better: You can write AUTO as the first line of a numberless program and then load it. Don't forget to press CTRL-SPACE (ALT-CTRL-SPACE in a Minerva MultiBASIC) after it has loaded. But this feature won't help, if you want to merge a program.
This does not work in SMSQ/E SBASIC.
Unfortunately SBASIC is not fully compatible to SuperBASIC. E.g. following is possible in SBASIC, gives error in expression in SuperBASIC:
NEW
a$=b$


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 :-)
Derek_Stewart
Font of All Knowledge
Posts: 4652
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

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

Post by Derek_Stewart »

ql_freak wrote: Thu Apr 24, 2025 6:55 am
Derek_Stewart wrote: Wed Apr 23, 2025 7:05 am AUTO: LOAD <program>

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

Due to a bug in Superbasic.
This is NOT a bug, it's documented in Jan Jones SuperBASIC book in Chapter 9 (page 89 in first version). And it's even better: You can write AUTO as the first line of a numberless program and then load it. Don't forget to press CTRL-SPACE (ALT-CTRL-SPACE in a Minerva MultiBASIC) after it has loaded. But this feature won't help, if you want to merge a program.
This does not work in SMSQ/E SBASIC.
Unfortunately SBASIC is not fully compatible to SuperBASIC. E.g. following is possible in SBASIC, gives error in expression in SuperBASIC:
NEW
a$=b$
To merge a numberless Superbasic programme, just do: AUTO : MERGE <program_bas>


Regards,

Derek
Post Reply