Page 3 of 7

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

Posted: Mon Apr 21, 2025 9:58 am
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

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

Posted: Mon Apr 21, 2025 10:18 am
by Giorgio Garabello
Derek_Stewart wrote: Mon Apr 21, 2025 7:06 am How do you run SSB from MicroEMACS?
Via FileInfo2

Giorgio

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

Posted: Mon Apr 21, 2025 6:12 pm
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

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

Posted: Tue Apr 22, 2025 8:27 pm
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 1216 times
rnMergeTest1_2.png
 
Edith (2025-05-14 Wed): Unfortunately I have detected, that this version of the rn program does NOT work correctly. DUNNO why it worked, when I have had tested it (I wrote: Tested it only once). More unfortunately: I cannot find the source, only that of the version, which only is working with "_bat" files (SuperBASIC programs WITHOUT line numbers), which I have attached in a previous message in this thread. This seems to work. I will have a look at it, but I'm currently extremely short of time.

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

Posted: Wed Apr 23, 2025 1:35 am
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 ;‑)

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

Posted: Wed Apr 23, 2025 7:05 am
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.

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

Posted: Thu Apr 24, 2025 6:55 am
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$

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

Posted: Thu Apr 24, 2025 7:11 am
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>

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

Posted: Wed Apr 30, 2025 6:16 pm
by Popopo
tofro wrote: Sat Apr 19, 2025 9:48 am RENUM can very well be used in a running program - as long as you make sure the line numbers that "currently run" (i.e. the ones that actually call RENUM) don't change. You can achieve this by putting the RENUM code at the beginning of the program with increments you intend to use later. Of course it's a dirty hack, but the only method I see that does what you want from S*BASIC. But if you refuse to have your program renumbered, well you need to do it the complicated way (or you introduce a convention that makes sure all your programs and snippets have a DATA line as the last line).
Following all the comments.
Just want to remark that I was trying to merge, a line of code into a running basic program but it always failure into the missing PC. Returning to the shell.
So...
How have you make it? I mean to merge another basic program into a running one without exiting.
Thanks

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

Posted: Sat May 03, 2025 2:44 am
by ql_freak
Popopo wrote: Wed Apr 30, 2025 6:16 pm Just want to remark that I was trying to merge, a line of code into a running basic program but it always failure into the missing PC. Returning to the shell.
So...
How have you make it? I mean to merge another basic program into a running one without exiting.
Thanks
This is DEFINITELY working (sQLux with Minerva)! See my current project:

viewtopic.php?p=64237#p64237

p.s.: Are you the one who sells memory expansion and this Microdrive emulator SD-interface on ebay? I think I must order...