Knoware.no

Anything QL Software or Programming Related.
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Knoware.no

Post by pjw »

dilwyn wrote:<>Neat, although what is JVA_SGET? Is it a SMSQmulator specific Java command?
Thanks :) Yes, the same program can be used in both QPC2 and SMSQmulator.


Per
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Knoware.no

Post by pjw »

For those who are not used to doing business this way:

If you copy some code from, say QL Forum that you want to try out in SBASIC, select the desired code in Windows (I cant remember if this works in Mac/Linux, but I think it does) and copy it to the clipboard (CTRL+c), then switch to QPC2/SMSQmulator

If the code has line numbers then focus on window #0, and, presuming youve attached Stuff_obj to ALT+v, press that key combination. The code should now be in SBASIC and ready to run or save.

If, however, the code doesnt have line numbers, then type ED <ENTER> in window #0 first.. In the SBASIC editor (presumably window #2) type the first line number you wish to use, say 100<SPACE> then do the ALT+v. The program should now be in SBASIC and ready to run or save.

For the incorrigible hackers amongst you, the code for the STUFF command is available under Toolkits at Knoware.no. Just note that it was written a very long time ago, so I cant vouch for its elegance or efficiency; I just know from long experience that it appears to work, even under more strenuous conditions than is asked of it with this simple application - but is just too much trouble to revisit at this time.


Per
dont be happy. worry
- ?
Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: Knoware.no

Post by Silvester »

That's very useful, thanks, Per. Whats puzzling is that I don't need to use EMU_SYNCSCRAP, to start a job, it just appears to work without it.

BTW anyone else lost the use of reset with ALT+CTRL+SHIFT+TAB when using wireless keyboard?


David
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Knoware.no

Post by pjw »

Silvester wrote:That's very useful, thanks, Per. Whats puzzling is that I don't need to use EMU_SYNCSCRAP, to start a job, it just appears to work without it.
I promise you wont be happy without the "JVA Syncscrap job" in the long run.. ;)
Silvester wrote:BTW anyone else lost the use of reset with ALT+CTRL+SHIFT+TAB when using wireless keyboard?
Ive never been able to use this key combination in SMSQmulator under Windows, let alone with a wireless keyboard.


Per
dont be happy. worry
- ?
Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: Knoware.no

Post by Silvester »

Perhaps, I've only tried it without sync job a few dozen times, although I am running Lubuntu and not Windows.

On Lubuntu 21.04 you can get at the config file to stop special keys being trapped (/home/david/.config/openbox/lxqt-rc.xml). But ALT+CTRL+SHIFT+TAB is not used anyway, don't know whether there is similar file in Windows.

Thankfully RESET keyword does same.

PS. Just got to keep remembering it's CTRL+C then ALT+V for QL (but back to CTRL+V otherwise!)

PPS. Just discovered you do need the sync job running to be able to copy from QL to system buffer !


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

Re: Knoware.no

Post by Tinyfpga »

I have tried to use the keyword VALID% from the the very good knoware site and I don't knowwhere I have gone wrong.

I have been trying to convert various programs I wrote in Microsoft's Visual Basic. All these programs use plain text
entries to describe financial transactions.

Examples as follows:-

Code: Select all

12FEB 123.45 OVH- A1,STAT,V;PAPER FROM RYMAN'S;CC1
12FEB JOB1,12.45+45.56+(34*2)
In Visual Basic it is not too difficult to parse these texts because it is fairly easy to determine if dates, numbers and expressions are valid and expression can be resolved with VB's Evaluation software.

I have tried the keyword EVAL (I found this on Dilwyn's site) but a runtime error is caused if an invalid expression
is "EVALed"

I know that VALID% was not designed to validate numerical expressions (It would be great if it could), but I thought I would experiment with VALID% to see what it does do, as follows:-
VALIDobj.zip
(579 Bytes) Downloaded 45 times
--------------------------------------------------

Code: Select all

Open #2,scr_300x12a200x300
Open #3,con_300x120a200x312
Paper #2,7 : Ink #2,0 : Cls #2 : Border #2,1,0
Paper #3,7 : Ink #3,0 : Cls #3 : Border #3,1,0

At #2,0,17 : Print #2, "Example of VALID%"
At #3,1,10 : Print #3, "Type to test Press x to quit"


Rep p
    At #3,4,4 : Input #3,a$

    t=VALID%(3,a$)

    At #3,6,4 : Print #3,"               " : At #3,6,4 : Print #3,a$,t
    If a$="x" : Exit p
End Rep p

rem: Tried to use VALID% to determine if a string is a valid number
rem:  and failed. What am I doing wrong?

rem: note if VALID_bin not installed then runtime error = 19; Indices wrong

rem: Odd results as follows:-
rem:  Any valid number returns 1, including numbers starting with a + or -
rem:  Any string starting with a non numeric character returns 0. Except +-
rem:  Any string starting with a number returns 1!!
------------------------------------------------------

If the above program seems odd it is because I do not use the SMSQ/E interpreter but prefer compiled programs running
in a window.
Last edited by Tinyfpga on Mon Oct 18, 2021 1:05 pm, edited 1 time in total.


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

Re: Knoware.no

Post by Tinyfpga »

Following on from my last post:- How about greatly extending VALID% such that it could validate a larger variety of strings such as dates, formatted numbers (eg. two decimal points) and numerical expressions.

One can see that I have no idea how to post SB source or object code. I can't find instructions on how to do this on this forum. Although I can easily UNZIP programs on SMSQ/E, I am unable to ZIP them.


User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Knoware.no

Post by NormanDunbar »

tinyfpga wrote:One can see that I have no idea how to post SB source or object code. I can't find instructions on how to do this on this forum.
I fixed it for you! (With the use of my moderator's hat!)

To format code, simply press the "Code" button on the toolbar just above the edit window. Then type or paste your code stuff bewteen these flags:

Code: Select all

[code]Your code goes here
[/code]


HTH

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Knoware.no

Post by pjw »

Tinyfpga wrote:I have tried to use the keyword VALID% from the the very good knoware site and I don't knowwhere I have gone wrong.
VALID% is incredibly lazy! It leaves all the hard work to S*BASIC. Anything that S*BASIC will accept is fine with VALID%, so x% = "+4" is fine with S*BASIC, so is fine with VALID% too. But while x%='abc' causes the interpreter to gag, VALID% just tells you that this is an error and continues. Theres an article that describes how VALID% works in numbing detail here.
Tinyfpga wrote:I have been trying to convert various programs I wrote in Microsoft's Visual Basic. All these programs use plain text
entries to describe financial transactions.

Examples as follows:-

Code: Select all

12FEB 123.45 OVH- A1,STAT,V;PAPER FROM RYMAN'S;CC1
12FEB JOB1,12.45+45.56+(34*2)
In Visual Basic it is not too difficult to parse these texts because it is fairly easy to determine if dates, numbers and expressions are valid and expression can be resolved with VB's Evaluation software.<>
There are too many different ways to format data, especially when coming from "foreign" sources, that it doesnt make sense to extend VALID% to cover all that. You need to write a bespoke parser for your data. There is some help though. There are a number of other commands on Knoware (and elsewhere, of course) to make string parsing easier. Have you looked at my other string toolkits at Strings and Text? If you can export your data in comma-delimited format you may be able to use IMPARSE to extract one term at a time. That might save some fiddle. But I cant see much regularity, apart from the date, in the data sample above, so that could prove complicated to parse.
I dont know of any really useful tools to compute "12.45+45.56+(34*2)" from a string. I wrote some weird programs that used a daughter SBASIC as a slave to do that kind of computation, but it is awkward and liable to crash. If you have the inclination you could see if you could do something with my SB Slave. I used a similar method to input ad hoc functions as a string into a program to calculate their roots and draw their graphs, so it can be done - for fun or if you really need to ;)
Sorry I cant be of more help.


Per
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Knoware.no

Post by pjw »

Tinyfpga wrote:Following on from my last post:- How about greatly extending VALID% such that it could validate a larger variety of strings such as dates, formatted numbers (eg. two decimal points) and numerical expressions.

One can see that I have no idea how to post SB source or object code. I can't find instructions on how to do this on this forum. Although I can easily UNZIP programs on SMSQ/E, I am unable to ZIP them.
From your attachment:

> Tried to use VALID% to determine if a string is a valid number
> and failed. What am I doing wrong?

Try:
x% = 5+4: PRINT x%, gets you 9
x% = "5+4": PRINT x%, gets you 5. Why?
Because S*BASIC doesnt evaluate expressions inside strings, but it does extract any valid number it finds until the first invalid character: "+" in that position is not a valid character so number extraction is terminated.
So to test what VALID% will do, try it out in the interpreter first!

> note if VALID_bin not installed then runtime error = 19; Indices wrong
This is because SBASIC thinks you are trying to use an array that has not been DIMensioned yet. SBASIC doesnt know about VALID% until youve LRESPRed it. Try t=VALIX%(3,a$) at the console. SBASIC say Huh, wots VALIX%?

> Odd results as follows:-
> Any valid number returns 1, including numbers starting with a + or -
Thats 'cause they are valid! Try
PRINT VALID%(3, 32768)
at the console and youll find that it is not valid 'cause integers only go up to 32767. As I said before, VALID% will only accept what the interpreter accepts. Thats the whole point of VALID%!

> Any string starting with a non numeric character returns 0
Try
x% = "1abc": PRINT x%
then
x% = "abc": PRINT x%: REMark KAAABOOOM!
PRINT VALID%(3, "abc")
simply prints 0

> Any string starting with a number returns 1!!
Not any, try
PRINT VALID%(2,"1e999")
However, admittedly, VALID%(1, string$) is pretty useless as EVERYTHING is accepted, even
PRINT VALID%(1,"1e999")
- because "1e999" is a valid string!

I hope this clears things up?


Per
dont be happy. worry
- ?
Post Reply