Is SBASIC programming on SMSQE difficult?

Anything QL Software or Programming Related.
Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Is SBASIC programming on SMSQE difficult?

Post by Tinyfpga »

tofro posted
Nope, there's no such thing as hardware that stops and continues multitasking programs. The computer is simply interrupted every 20ms to check whether another job needs to run. If yes, the scheduler "simply" exchanges the CPU context of the currently running job with that of the new one.
How does event driven software work? Can an SMSQE program respond to an event?

I use BGET (from a console) to step through my programs. I combine BGET with the printing of variables to "see" what is going on with my faulty programs. From what you are saying, BGET doesn't actually stop a program and wait for a keyboard event. It creates a loop that is constantly trying to read a key stroke directed to the appropriate channel.


Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Is SBASIC programming on SMSQE difficult?

Post by Tinyfpga »

I have recently been distracted by the discovery that, apparently, Python has overtaken French as the most popular "language" taught in primary schools.
It is described, variously, as "an easy language to learn, simple to use, concise, expressive, highly productive and popular because it is easily understood by humans."

Given my interest in learning how to program and that it is pre-installed in a Raspberry pi400, I thought I would make an effort to write a Python program so as to be able to compare it to SMSQE BASIC.

I have spent, at various times, five days trying to do this with the help of Youtube videos. The Pi Beginner’s guide is no help whatsoever if one wants to write an .ex program. Clearly I am not human enough.

In an online Python guide starting with the title "whetting your appetite" one rapidly finds the following paragraph:-

“Execution of a derived class definition proceeds the same as for a base class. When the class object is constructed, the base class is remembered. This is used for resolving attribute references: if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively if the base class itself is derived from some other class.”

I would love watch a video of a teacher trying to explain this to a classroom of disinterested students.

I learned more about writing a computer program by reading Dilwyn’s ancient online QL guides, than by reading the Pi400 guide, which is designed to appeal to young school children.

It slowly became clear that one has to invoke Tkinter (or something like it) if one is going to create a window. If you imagine that Qptr is difficult, just try using Tkinter.

I managed to use it only by slavishly copying code from the internet. Creating an .ex file took me a while to master. The process was not obvious.
I gave up using Python on a Pi because I found it easier to use when installed on a PC. (another process that was not “easy”)

Having written a windowing Python program with just a few lines of code, the challenge was to do the same with Qptr.
( I do not use Easyptr). The screenshot demonstrates equivalent programs from each language.

In my opinion neither OOP nor Python is easy to understand or use. The Python.exe file at 9Mbytes is 1600 times bigger than the SMS.obj file, and isn't the SMS Thing system a more advanced concept than the OOP paradigm?

I imagine that my procedure P_wdraw, for example, could be written in assembler and installed as a Thing. In that case it would act in a similar way to Python’s Tk() Object.

I have suggested that SBASIC is difficult. I can now say, “not half as difficult as the ultra popular Python programming language”.
BASIC vs PYTHON.JPG


stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

Re: Is SBASIC programming on SMSQE difficult?

Post by stevepoole »

Hi Folks,

I just spent an hour trying out Tofro's suggested BEEP timing idea, (using the 'wait' routine posted today), and came up with the minimum requirements :

5000 Def Proc tofros
5010 BEEP 32767,255: wait sec/100
5020 REPeat r: IF BEEPING: ELSE EXIT r
5030 BEEP: END DEFine

Call tofros, and it will buzz ok, but (inconsistantly) not on a real QL if you reduce the wait value! The second processor is very slow in replying !

The wait routine is luckily far more useful for much smaller values, and can be silent...

Steve.
_____________________


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

Re: Is SBASIC programming on SMSQE difficult?

Post by tofro »

Tinyfpga wrote:
tofro posted
Nope, there's no such thing as hardware that stops and continues multitasking programs. The computer is simply interrupted every 20ms to check whether another job needs to run. If yes, the scheduler "simply" exchanges the CPU context of the currently running job with that of the new one.
How does event driven software work? Can an SMSQE program respond to an event?

I use BGET (from a console) to step through my programs. I combine BGET with the printing of variables to "see" what is going on with my faulty programs. From what you are saying, BGET doesn't actually stop a program and wait for a keyboard event. It creates a loop that is constantly trying to read a key stroke directed to the appropriate channel.
No. What BGET (and other I/O calls) actually does is telling the system that the calling job waits for a keypress. As long as a job waits for a keypress and "could" otherwise run, it's not even scheduled - The scheduler will only activate the job at all if it detects the con_ device driver has a keypress available to satisfy the job's I/O request. That keeps jobs that are waiting for I/O from loading the system.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

Re: Is SBASIC programming on SMSQE difficult?

Post by stevepoole »

Hi Folks,

In the 'tofros' routine posted previously, the routine works fine too if you REMark out the wait call, because QPC does not use an 8049 for beeping.

So yes, 72nanosec pausing is possible, although as he points out, noisy, but only on emulators !

That is why I wrote the wait zip routine for (silent) backward compatibility....

Best Wishes,

Steve.
____________


Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Is SBASIC programming on SMSQE difficult?

Post by Tinyfpga »

I have been trying to create external procedures and then making them resident, without success. I have read pages 74,75 and 76 of the Qlib manual. When I try to LRESPR a BASIC object file SMSQE crashes.

I compiled part of the sample code found on page 75, as follows:-

Rem $$external
Def proc square(x)
Print x*x
End def

LRESPR,ing the _obj file crashes SMSQE-in-QPC2. What am I doing wrong?

The manual does not make clear what will be the effect of opening channels within an external procedure.


Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Is SBASIC programming on SMSQE difficult?

Post by Derek_Stewart »

Tinyfpga wrote:I have been trying to create external procedures and then making them resident, without success. I have read pages 74,75 and 76 of the Qlib manual. When I try to LRESPR a BASIC object file SMSQE crashes.

I compiled part of the sample code found on page 75, as follows:-

Rem $$external
Def proc square(x)
Print x*x
End def

LRESPR,ing the _obj file crashes SMSQE-in-QPC2. What am I doing wrong?

The manual does not make clear what will be the effect of opening channels within an external procedure.
Hi,

I tried to compile the external procedure with Qliberator v3.44 in QPC2 v5.02 & SMSQmulator v3.32 Java 11 and once compiled and loaded in to the SBASIC command list or resident extensions was pressent on the EXTRAS list of command and Functions.

But performing: SQUARE 2 did not display anything in Channel #1 and did not return to the command prompt.

Compiling and LRESPRing in Minerva v1.98 on Q-emulator and sQLux work as expected.

Is there a problem with SMSQ/E ?


Regards,

Derek
Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Is SBASIC programming on SMSQE difficult?

Post by Tinyfpga »

Given that Derek had no problems with $$external, I thought I would check the version of Qlib installed om my setups. I found that, although I thought I was using v3.36, I am, in fact, using v3.31 which does not support the directive.

Dylwin hosts 6 versions of Qlib on his site and states that:- "For now, at least, I will leave the older versions on this page for posterity and in case anyone has difficulty with the current versions, you can go back to an older version temporarily."

I am going to download them all (just in case he stops hosting the older versions) and then start with v3.36 and then test them all out.

On page 92 I found the following:- "In future we may develop a debugger for Q_Liberator code in which case the
TRACE option will allow code to be single stepped. Please write to us if you are interested in such a tool.

Apart from myself is anyone else interested in this facility?


Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Is SBASIC programming on SMSQE difficult?

Post by Tinyfpga »

Derek posted:- SQUARE 2 did not display anything in Channel #1 and did not return to the command prompt.
Is there a problem with SMSQ/E ?
I have updated my QPC2 setup with Qlib v3.36. REM $$external now works (kind of). A new instruction is added to SBASIC and works within a compiled program but if the instruction is used directly, the command prompt crashes.

I will try to update SMS2 and my Q68 next.


User avatar
RalfR
Aurora
Posts: 870
Joined: Fri Jun 15, 2018 8:58 pm

Re: Is SBASIC programming on SMSQE difficult?

Post by RalfR »

Tinyfpga wrote:I will try to update SMS2
How??? There is no update from TT for years.


4E75 7000
Post Reply