Check if BASIC is running

Anything QL Software or Programming Related.
Andrew
Trump Card
Posts: 189
Joined: Tue Jul 17, 2018 9:10 pm

Check if BASIC is running

Postby Andrew » Fri Mar 08, 2019 4:35 pm

How can I check if BASIC is running ?

A function like this
100 DEFine FuNction isBasicRunning
110 RETurn NOT BASIC_B%(111)
120 END DEFine isBasicRunning

will return 1 (aka Basic is running) if either:
  1. a BASIC program is running
  2. a BASIC program was running but execution was interrupted with CTRL-SPACE (user can use CONTINUE to resume the execution)
  3. a BASIC program has run, but there was no STOP command in the program and no CLEAR or NEW command was issued after it ended

I am interested in finding a way that would return TRUE only if a BASIC program is actually running (item 1 from above - but not for items 2 and 3).
Is there any memory address / system variable / whatever that I could check ?


User avatar
NormanDunbar
Super Gold Card
Posts: 700
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Check if BASIC is running

Postby NormanDunbar » Fri Mar 08, 2019 9:55 pm

Ther's a list of Basic's own variables at http://qdosmsq.dunbar-it.co.uk/doku.php ... nal:sbvars which might be useful.

Number 2 you might get from bv_cont, possibly bv_line nd/or bv_stmt for option 1. Not sure about the last option though.

Good luck.

Cheers,
Norm.


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
Andrew
Trump Card
Posts: 189
Joined: Tue Jul 17, 2018 9:10 pm

Re: Check if BASIC is running

Postby Andrew » Fri Mar 08, 2019 10:20 pm

Thank you Norman !
I did not knew your site - but it is great ! Full of info I was looking for ! thank you !!


EmmBee
Brittle Membrane
Posts: 100
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Check if BASIC is running

Postby EmmBee » Fri Mar 08, 2019 11:39 pm

Current Line number executing ... BASIC_W%(104)

Continue Line number ... BASIC_W%(146)

Break - whether Ctrl-Space was pressed - BASIC_B%(143)

Best of luck with this. I got the above information from Jan Jones's QL SuperBASIC The Definitive Handbook
These will work with QDOS - but not necessarily with SMSQ/E


EmmBee
Brittle Membrane
Posts: 100
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Check if BASIC is running

Postby EmmBee » Thu Mar 14, 2019 11:19 pm

Here is a version I wrote ...

Code: Select all

DEFine FuNction isBasicRunning
  IF VER$ = "HBA"
    REMark SMSQ/E
    IF BASIC_B%(110) = 1 : RETurn 1 : ELSE RETurn 0
  ELSE
    REMark QDOS
    IF CHBASE(0,0) <> -1 : RETurn 2 : REMark no #0 cursor
    IF BASIC_W%(104) = BASIC_W%(146) : RETurn 0 : REMark STOP occurred
    IF BASIC_B%(143) = 0 : RETurn 0 : REMark break - Ctrl-Space pressed twice
    IF BASIC_B%(111)<> 0 : RETurn 0 : REMark single line command
    RETurn 3 : REMark Input to #0
  END IF
END DEFine isBasicRunning

It uses the DIY VolQ QBASE toolkit function CHBASE(). This makes the code easier to write.


Andrew
Trump Card
Posts: 189
Joined: Tue Jul 17, 2018 9:10 pm

Re: Check if BASIC is running

Postby Andrew » Fri Mar 15, 2019 10:30 pm

Thank you EmBee

IF CHBASE(0,0) <> -1 : RETurn 2 : REMark no #0 cursor
No matter what (program running or not running), on QEmulator I always get that CHBASE(0,0) = -1


EmmBee
Brittle Membrane
Posts: 100
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Check if BASIC is running

Postby EmmBee » Sat Mar 16, 2019 12:10 pm

I now don't think that the CHBASE(0,0) line is really necessary - it can be deleted.
It's all to do with finding out if it's stopped.
If it's not stopped, then it must be running.



Who is online

Users browsing this forum: No registered users and 9 guests