Author Topic: oh One-Handed Interpreter  (Read 13774 times)

0 Members and 1 Guest are viewing this topic.

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: oh One-Handed Interpreter
« Reply #45 on: May 26, 2021, 11:08:50 pm »
@bplus, I downloaded the interpreter from the post with the ZIP file and tried to run this script, but it got a ton of errors. I wonder if I have the most current copy of the interpreter.


Update: I now have the arguments to the Screen and Graphics commands being run through Fval$ so you don't need to create extra variables for simple row, col cals or x, y's for a graphic but this required making the argument delimiter a semi-colon to distinguish from the comma delimiter in all SFunctions.

A new command for center printing a line with plug-in variables,
Code: [Select]
cpr row; my text with plug-in ;here1; and ;here2;.
All the demos have been updated with new delimiter for appropriate commands and Test oh ac Fval$ Tester has been rewritten and I feature it now:

Code: [Select]
'Test ac Fval$ Tester.txt by b+ 2020-03-07 mod 2021-02-21 mod 2021-03-09
' I wrote in cpr just for this demo! Plus
[
cpr 2;*** Fval$ Tester ***
cpr 5;Arith: a[1,1] > 2,  s[1,1] > 0,  x[2,3] > 6,  d[12,4] > 3     Constants: e = exp[1], pi = pi[1]
cpr 7;Math: modulus use m[3,2] > 1   power use p[2,3] > 8   log[], exp[], sqr[], int[], rnd[multiplier]
cpr 9;Trig (radians): sin[], cos[], tan[], asin[], acos[], atan[]     Angle Conversion: rad[degrees], deg[radians]
cpr 11;Boolean: #=# use eq[ , ] for = numbers    noteq[ , ] for <>    lt[ , ] for <    lte[ , ] for <= 
cpr 13; gt[ , ] for >   gte[ , ] for >=   and[,,, ]   or[,,, ]   not[ ]    seq[$,$] for string equal
cpr 16;Get the cheat sheet and test string functions! Here a most:
cpr 17;mid1, mid2, mid3, in2, in3, time, date, CAP, low, rtrim, ltrim, trim, spc, len

' first test ever of fval$ working on arguments to loc, at, tag, graphics...
loc a[17,3];5

inps (just enter to quit) Enter an expression to evaluate; expression
Jmp seq[expression,mt]
result = fval[expression]
at 5;22
cpr 22;The Tester came up with this: ;result
cpr 25;Wait 5 secs...
Wait 5
Cls
]
.
. Goodbye!

 
Test oh ac Fval$ Tester.PNG


New zip package contains bas, exe for Windows 10, demo.txts and updated, oh cheat sheet.txt with change log now.

Update:
See the first post of this thread for most recent version of oh.bas and zip package.
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #46 on: May 26, 2021, 11:43:15 pm »
Most recent zip package is in the first post:
oh v 2021-03-27A
The latest cheat sheet / manual is very next post (or in zip).

Run oh.exe (after you have compiled the bas source, unless an exe there already)
Load file "Test oh ac Fval$ Tester.txt"
select 'Load' by clicking and select the file from files and directory navigator selector.
When file selected it will be displayed for you to read through and decide to Run or Edit or Load a different file.
 
oh File displayed.PNG


Select Run by clicking...

Run through Syntax Check and the file is running, it is waiting for something to test try 1+ 1 to see if 2
Type a[1,1] <<< and those are square brackets that's add function
 
oh 1 + 1.PNG

and Enter
 
And the tester answers for 5 secs and prompts for another test.PNG

Tester responses

Warning this is not Basic like in way you command it everything is done through function[arg1,arg2,arg3...] syntax
A is for add, x is for multiple because m is used for modulus, d for divide, s subtract

Opps just ran into error myself let recheck. dah! forgot the second ]
 
ex1.PNG


Make sure you use [] square brackets for everything, can't print them in programs because then code starts looking for Function so whenever I say {} I mean [] in those programs.

If there is a particular function or set of them that is hanging you up let me know so I can explain further.

Thank you for giving this program a look see!

« Last Edit: May 27, 2021, 12:11:44 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #47 on: May 27, 2021, 12:07:48 am »
edit: oops thought I was modifying above post, sorry.

I know how this stuff is suppose to work and I can't imagine what it is like for someone new trying it out so your feed back is important for me and for others. Thanks

This Interpreter is like a library of some nice functions built in like Sorting, saving stuff to clipboard, Extended math with Strings, very simple Load and Save File from array you've processed in your program, circle fill and triangle fills and it is pretty easy to add your own stuff (well easy for me to say and do). Graphics too slow for serious games but nice for diagramming or plotting maybe.
« Last Edit: May 27, 2021, 12:23:42 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #48 on: June 03, 2021, 11:34:56 pm »
OK just modified first post of this thread with new update to oh fixing the divide$ function.

Now this program works as intended to find precision Square Roots to 100 digits which was testing code for a String Math extension to Square Roots.

oh interpreter program:
Code: [Select]
' Test oh High Precision Square Root b+ 2021-06-03 now with divide$ fixed
' stores square root in clipboard
[
'remember everything strings
inps Enter a number to find it's square root;n
if seq[n,mt]
end
fi
guess = divide[n,2.1]
other = n
loopCnt = 0
[
loopCnt = a[loopCnt,1]
. Loop Count: ;loopCnt;
if seq[mid3[guess,1,105],mid3[lastGuess,1,105]]
sr = mid3[other,1,101]
. square root of ;n; is:
. sr
. len(other) = ;len[sr]
clipout sr
exit
el
lastGuess = guess
sum = add[guess,other]
guess = divide[sum,2]
other = divide[n,guess]
fi
]
]


You can compare it to this in String Math thread:
https://www.qb64.org/forum/index.php?topic=2921.msg133040#msg133040
(oh that was modified for negative numbers)
« Last Edit: June 03, 2021, 11:36:54 pm by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: oh One-Handed Interpreter
« Reply #49 on: June 07, 2021, 02:14:10 am »
Nice work B+
...even syntax is little bit esoteric to me ..heh !
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #50 on: June 07, 2021, 01:29:41 pm »
Thanks @Aurel

I think one of it's best features is String Math and if you are following that thread you will see mine is loaded with bugs.
Just today I finally got a single decimal point that crept into a 10,000! calculation. Supposed to have 35660 digits I was getting 35661 because of a single dang dot! Turns out I had to change all my Integers to Long as I originally did not think I would be dealing with strings over 32K chars. Now 10000! is perfect but takes too long... working on that.

I did get the inverse of Stx number down to 2 secs from 19? But before it was coming under a sec with faulty subtr$ or divide$ functions, oddly the Fibonacci terms were reporting correctly from the beginning.
« Last Edit: June 07, 2021, 01:34:03 pm by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: oh One-Handed Interpreter
« Reply #51 on: June 08, 2021, 08:17:10 am »
Quote
Turns out I had to change all my Integers to Long
well i don't know that they are different in qb64..in o2 i think that are same .
In my interpreter i am using FLOAT type for variables ..but Long or Int type give
the fastest operations in any language..
on the other side string operations are time consumig..aka slower
work with type CHAR or BYTE are quicker, for big buffers in m(A) i am using CHAR.
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #52 on: June 15, 2021, 10:24:17 pm »
I have loaded the oh Interpreter with the latest String Math package with the fixes and improvements and new sqrroot[] addition. As usual the first post in this thread has the latest zip package and the 2nd as per usual shows a current copy of the manual and change log (included in zip).

Here is the new part of change log:
Quote
*** 2021-06-15 String Math update
6/15 A number of fixes and improvements to the String Math package including new sqrroot[number]
     Function. Unfortunately with the new fixes the inverse of STx number takes a bit longer than
    it did, it's a wonder it was getting correct results originally. When testing all the
    programs I noticed the nl "constant" I had forgotten all about. This is doing double spaced
    lines because it is Chr$(13)+Chr$(10) probably should be one or other, not both together.
    Since last update we created new programs:
    Aurels Henon code, Bresenham Circle Fill, First 100 digit Fibonacci, Sqr Root estimating.
    A version of the last program became part of the String Math package update!
« Last Edit: June 15, 2021, 10:27:18 pm by bplus »