QB64.org Forum

Active Forums => Programs => Topic started by: STxAxTIC on March 07, 2020, 12:24:36 am

Title: Shorthand Basic
Post by: STxAxTIC on March 07, 2020, 12:24:36 am
For the sake of the life cycle I'm trying to push for any given program, here is a new thread for @bplus's excellent little machine, Shorthand Basic.

He describes it nicely here:

https://www.qb64.org/forum/index.php?topic=16.msg115312#msg115312 (https://www.qb64.org/forum/index.php?topic=16.msg115312#msg115312)

The main code is this:
Code: QB64: [Select]
  1. _TITLE "SB by bplus 2018-09-14" 'from BRUN v2?  does not use the makeover eval function?
  2. '2018-02-13 adding string array functions put and get, a god awlful amount of shuffling values around to simulate a numneric array
  3. 'get takes numbers out of the string array (of numbers) and puts it in a number variable, a yucky hack!  to get numeric arrays
  4.  
  5. '2018-02-05 BRUN started from Nano3 writtem in SmallBASIC
  6. 'added FB Eval modified for QB64
  7.  
  8. '2018-02-07 change the way variable assignments are made now n and s
  9. 'add theFile$ to BRUN title bar
  10. 'add cp to print in center of screen
  11. 'eliminate Dflag
  12. 'add locate = cr, mostly I want to just get to a row, let's call this row
  13. 'change variable assignment method and arrays and consts to manage
  14. 'modify record for number and string variables
  15. 'add lookup function
  16. 'more shared vaiables for processing in subs and functions
  17.  
  18. 'TO DO
  19. 'add a bunch of string stuff space! I need space!
  20. 'separate area for error reporting and BRUN messaging
  21. 'colors 3 digit number toy rgb system
  22. 'ink for fore color statement
  23. 'paper for back color
  24. 'add line one graphic to do it all?
  25. 'readFile(lineNum),  writeFile(lineNum)
  26. 'try to keep everything case insensitive including variables
  27.  
  28. CONST xmax = 1200
  29. CONST ymax = 720
  30. CONST nmax = 100
  31. CONST smax = 100
  32.  
  33.  
  34. SCREEN _NEWIMAGE(xmax, ymax, 32)
  35. _SCREENMOVE 100, 10
  36. COLOR _RGB32(100, 200, 255), _RGB32(0, 0, 68): CLS
  37.  
  38. debug = 0
  39.  
  40. 'variable tables
  41. DIM SHARED nName$(nmax), nValue(nmax), sName$(smax), sValue$(smax)
  42.  
  43. 'for evaluate
  44. COMMON SHARED EvalErr$, RAD, DEG
  45. EvalErr$ = ""
  46. RAD = _PI / 180.0
  47. DEG = 180 / _PI
  48.  
  49. 'for gosub
  50. DIM SHARED stackIndex AS INTEGER
  51. DIM SHARED stack(1000) AS INTEGER
  52.  
  53. 'for processing program lines
  54. DIM SHARED w$(250)
  55.  
  56. 'integers for main
  57. DIM i AS INTEGER, lineCnt AS INTEGER, nStop AS INTEGER, cl AS INTEGER, wc AS INTEGER, c AS INTEGER, OK AS INTEGER
  58. DIM theFile$, fLine$, temp$, pLine$, s$, fw$, es$, value$, wdx$
  59. DIM v, f, ansY, ansX, ans, nVal
  60. 'get started, do we have a program to run?
  61. IF COMMAND$ = "" THEN theFile$ = "test new string functions SB.txt" ELSE theFile$ = COMMAND$
  62. IF _FILEEXISTS(theFile$) AND RIGHT$(UCASE$(theFile$), 6) = "SB.TXT" THEN
  63.     _TITLE "SB: " + theFile$
  64.     lineCnt = 0: REDIM SHARED p$(0)
  65.     OPEN theFile$ FOR INPUT AS #1
  66.     WHILE EOF(1) = 0
  67.         LINE INPUT #1, fLine$
  68.         REDIM _PRESERVE SHARED p$(lineCnt)
  69.         p$(lineCnt) = wPrep$(fLine$)
  70.         lineCnt = lineCnt + 1
  71.     WEND
  72.     CLOSE #1
  73.     'debug check  p$() loaded
  74.     IF debug THEN
  75.         IF lineCnt > 40 THEN nStop = 40 ELSE nStop = lineCnt - 1
  76.         FOR i = 0 TO nStop
  77.             PRINT RIGHT$(" " + STR$(i), 2); " "; p$(i)
  78.         NEXT
  79.         INPUT "Here is listing of first 40 lines, press enter for run..."; temp$
  80.     END IF
  81.     cl = 0 'current line
  82.  
  83.  
  84.     stackIndex = 0
  85.  
  86.     WHILE cl < lineCnt
  87.         ERASE w$
  88.         pLine$ = p$(cl)
  89.         IF debug THEN PRINT: PRINT "Program line #, line:"; cl, pLine$
  90.         wc = wCnt(pLine$)
  91.         FOR i = 1 TO wc
  92.             w$(i) = Wrd$(pLine$, i)
  93.         NEXT
  94.         SELECT CASE LCASE$(w$(1))
  95.             CASE "c"
  96.                 CLS
  97.             CASE ".", ";", ","
  98.                 s$ = ""
  99.                 FOR i = 2 TO wc
  100.                     v = 0
  101.                     f = nLookUp%(w$(i), v)
  102.                     IF f THEN
  103.                         s$ = s$ + LTRIM$(STR$(v)) + " "
  104.                     ELSE
  105.                         temp$ = ""
  106.                         f = sLookUp%(w$(i), temp$)
  107.                         IF f THEN
  108.                             s$ = s$ + temp$
  109.                         ELSE
  110.                             s$ = s$ + w$(i) + " "
  111.                         END IF
  112.                     END IF
  113.                 NEXT
  114.                 s$ = RTRIM$(s$)
  115.                 IF w$(1) = "." THEN
  116.                     PRINT s$
  117.                 ELSEIF w$(1) = "," THEN
  118.                     PRINT s$,
  119.                 ELSEIF w$(1) = ";" THEN
  120.                     PRINT s$;
  121.                 END IF
  122.             CASE "cp"
  123.                 s$ = ""
  124.                 FOR i = 2 TO wc
  125.                     v = 0
  126.                     f = nLookUp%(w$(i), v)
  127.                     IF f THEN s$ = s$ + LTRIM$(STR$(v)) + " " ELSE s$ = s$ + w$(i) + " "
  128.                 NEXT
  129.                 s$ = RTRIM$(s$)
  130.                 PRINT SPACE$((150 - LEN(s$)) / 2); s$
  131.             CASE "l"
  132.                 ansY = Evaluate(w$(2))
  133.                 ansX = Evaluate(w$(3))
  134.                 IF EvalErr$ = "" THEN
  135.                     LOCATE ansY, ansX
  136.                 ELSE
  137.                     PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  138.                     EXIT WHILE
  139.                 END IF
  140.             CASE "@"
  141.                 s$ = ""
  142.                 FOR i = 4 TO wc
  143.                     v = 0
  144.                     f = nLookUp%(w$(i), v)
  145.                     IF f THEN s$ = s$ + LTRIM$(STR$(v)) + " " ELSE s$ = s$ + w$(i) + " "
  146.                 NEXT
  147.                 ansX = Evaluate(w$(2))
  148.                 ansY = Evaluate(w$(3))
  149.                 IF EvalErr$ = "" THEN
  150.                     _PRINTSTRING (ansX, ansY), s$
  151.                 ELSE
  152.                     PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  153.                     EXIT WHILE
  154.                 END IF
  155.             CASE "w"
  156.                 _DELAY VAL(w$(2))
  157.             CASE "?"
  158.                 s$ = ""
  159.                 FOR i = 3 TO wc
  160.                     v = 0: f = 0
  161.                     f = nLookUp%(w$(i), v)
  162.                     IF f THEN s$ = s$ + LTRIM$(STR$(v)) + " " ELSE s$ = s$ + w$(i) + " "
  163.                 NEXT
  164.                 PRINT s$;
  165.                 INPUT ""; temp$
  166.                 IF temp$ <> "q" THEN
  167.                     ans = Evaluate(temp$)
  168.                     IF EvalErr$ = "" THEN
  169.                         nRecord w$(2), ans
  170.                     ELSE
  171.                         PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  172.                         EXIT WHILE
  173.                     END IF
  174.                 END IF
  175.  
  176.             CASE "g"
  177.                 f = 0
  178.                 FOR i = 0 TO UBOUND(p$)
  179.                     IF Wrd$(p$(i), 1) = ":" AND Wrd$(p$(i), 2) = w$(2) THEN cl = i: f = 1: EXIT FOR
  180.                 NEXT
  181.                 IF f = 0 THEN PRINT "Error: could not find g's : "; w$(2): EXIT WHILE
  182.  
  183.             CASE "]"
  184.                 c = 1: f = 0
  185.                 FOR i = cl - 1 TO 0 STEP -1
  186.                     fw$ = Wrd$(p$(i), 1)
  187.                     IF fw$ = "[" THEN
  188.                         c = c - 1
  189.                         IF c = 0 THEN cl = i: f = 1: EXIT FOR
  190.                     ELSEIF fw$ = "]" THEN
  191.                         c = c + 1
  192.                     END IF
  193.                 NEXT
  194.                 IF f = 0 THEN
  195.                     PRINT "Error: could not find do to match loop on line "; cl
  196.                     EXIT WHILE
  197.                 END IF
  198.             CASE "x"
  199.                 c = 1: f = 0
  200.                 FOR i = cl + 1 TO UBOUND(p$)
  201.                     fw$ = Wrd$(p$(i), 1)
  202.                     IF fw$ = "]" THEN
  203.                         c = c - 1
  204.                         IF c = 0 THEN cl = i: f = 1: EXIT FOR
  205.                     ELSEIF fw$ = "[" THEN
  206.                         c = c + 1
  207.                     END IF
  208.                 NEXT
  209.                 IF f = 0 THEN
  210.                     PRINT "Error: could not find loop to match exit on line "; cl
  211.                     EXIT WHILE
  212.                 END IF
  213.  
  214.             CASE "i"
  215.                 es$ = ""
  216.                 FOR i = 2 TO wc
  217.                     es$ = es$ + w$(i) + " "
  218.                 NEXT
  219.                 es$ = RTRIM$(es$)
  220.                 'PRINT "evaluate this "; es$
  221.                 ans = Evaluate(es$)
  222.                 'PRINT "evaluated to "; ans
  223.                 IF EvalErr$ = "" THEN
  224.                     IF ans = 0 THEN
  225.                         cl = find(cl)
  226.                         IF cl = -1 THEN EXIT WHILE
  227.                     END IF
  228.                 ELSE
  229.                     PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  230.                     EXIT WHILE
  231.                 END IF
  232.             CASE "e"
  233.                 cl = find(cl)
  234.                 IF cl = -1 THEN EXIT WHILE
  235.  
  236.             CASE "z"
  237.                 EXIT WHILE
  238.  
  239.             CASE "s"
  240.                 f = 0
  241.                 FOR i = cl + 1 TO UBOUND(p$)
  242.                     IF Wrd$(p$(i), 1) = "r" THEN cl = i: f = 1: EXIT FOR
  243.                 NEXT
  244.                 IF f = 0 THEN
  245.                     PRINT "Could not find return for sub at line "; cl
  246.                     EXIT WHILE
  247.                 END IF
  248.             CASE "gs"
  249.                 f = 0
  250.                 FOR i = 0 TO UBOUND(p$)
  251.                     IF Wrd$(p$(i), 1) = "s" AND Wrd$(p$(i), 2) = w$(2) THEN f = 1: EXIT FOR
  252.                 NEXT
  253.                 IF f = 0 THEN
  254.                     PRINT "Error: could not find sub "; w$(2)
  255.                     EXIT WHILE
  256.                 ELSE
  257.                     stack(stackIndex) = cl: cl = i: stackIndex = stackIndex + 1
  258.                 END IF
  259.             CASE "r"
  260.                 stackIndex = stackIndex - 1
  261.                 cl = stack(stackIndex): stack(stackIndex) = 0
  262.  
  263.             CASE "n"
  264.                 es$ = ""
  265.                 FOR i = 3 TO wc
  266.                     es$ = es$ + w$(i) + " "
  267.                 NEXT
  268.                 es$ = RTRIM$(es$)
  269.                 ans = Evaluate(es$)
  270.                 IF EvalErr$ = "" THEN
  271.                     nRecord w$(2), ans
  272.                 ELSE
  273.                     PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  274.                     EXIT WHILE
  275.                 END IF
  276.  
  277.             CASE "$" 'record literal strings to variables here
  278.                 es$ = rightOf$(p$(cl), "{")
  279.                 es$ = leftOf$(es$, "}")
  280.                 sRecord w$(2), es$
  281.  
  282.             CASE "sf" 'string functions syntax: sf var sFunction parameters, according to function var will be string or number
  283.                 SELECT CASE w$(3)
  284.                     CASE "+" 'concant string varaible values
  285.                         temp$ = ""
  286.                         FOR i = 4 TO wc
  287.                             IF sLookUp%(w$(i), s$) > 0 THEN temp$ = temp$ + s$
  288.                         NEXT
  289.                         sRecord w$(2), temp$
  290.                     CASE "word"
  291.                         v = INT(Evaluate(w$(5)))
  292.                         OK% = sLookUp%(w$(4), s$)
  293.                         IF v > 0 AND OK% THEN
  294.                             sRecord w$(2), Wrd$(s$, v)
  295.                         ELSE
  296.                             PRINT "word error: could not get " + w$(5) + " word from variable " + w$(4)
  297.                         END IF
  298.                     CASE "spc"
  299.                         sRecord w$(2), SPACE$(INT(Evaluate(w$(4))))
  300.                     CASE "mid"
  301.                     CASE "instr"
  302.                     CASE "date"
  303.                 END SELECT
  304.  
  305.             CASE ">" 'into variable name at w$(2) at nplace w$(3) the str$ value of w$(4) +....
  306.                 'This sub stores into the w$(2) string variable (whether it exists or not)
  307.                 '  the value built up from w$(4) ++++ and made a string
  308.                 '  to the variable value at word location value of w$(3) a number variable
  309.                 '  the w$(3) value must be an existing n variable name
  310.  
  311.                 es$ = ""
  312.                 FOR i = 4 TO wc
  313.                     es$ = es$ + w$(i) + " "
  314.                 NEXT
  315.                 es$ = RTRIM$(es$)
  316.                 'PRINT "evaluate this "; es$
  317.                 ans = Evaluate(es$)
  318.                 'PRINT "evaluated to "; ans
  319.                 IF EvalErr$ = "" THEN
  320.                     OK = wPut(w$(2), w$(3), LTRIM$(STR$(ans)))
  321.                     IF OK = 0 THEN PRINT "Could not find number variable "; w$(3); " in line"; cl: EXIT WHILE
  322.                 ELSE
  323.                     PRINT "Evaluate Error: "; EvalErr$; " occured on line "; cl
  324.                     EXIT WHILE
  325.                 END IF
  326.  
  327.             CASE "<" ' put into var at w$(2)  from array w$(3) at array index w$(4)
  328.                 'briefly pull a number in string array stored as string and store value into variableat w$(2)
  329.                 ' this sub retrieves the word at w$(4) a number variable
  330.                 ' from the string variable at w$(3)
  331.                 ' and stores the value in number variable w$(2)
  332.                 value$ = ""
  333.                 OK% = sLookUp%(w$(3), value$)
  334.                 IF OK% = 0 THEN PRINT "Could not find string variable "; w$(3); " on line "; cl: EXIT WHILE
  335.                 nVal = 0
  336.                 OK% = nLookUp%(w$(4), nVal)
  337.                 IF OK% THEN
  338.                     wdx$ = Wrd$(value$, nVal)
  339.                     nRecord w$(2), VAL(wdx$)
  340.                 ELSE
  341.                     PRINT "Could not find number variable "; w$(4); " in line"; cl: EXIT WHILE
  342.                 END IF
  343.  
  344.         END SELECT
  345.         IF debug THEN
  346.             PRINT
  347.             PRINT " Here is number table:"
  348.             FOR i = 0 TO nmax
  349.                 IF nName$(i) <> "" THEN PRINT i, nName$(i), nValue(i)
  350.             NEXT
  351.             PRINT " Here is strings tables:"
  352.             FOR i = 0 TO smax
  353.                 IF sName$(i) <> "" THEN PRINT i, sName$(i), sValue$(i)
  354.             NEXT
  355.             INPUT "OK line processed "; OK
  356.             PRINT
  357.         END IF
  358.         cl = cl + 1
  359.     WEND
  360.     COLOR _RGB32(0, 0, 68), _RGB32(100, 200, 255)
  361.     LOCATE 43, 2: PRINT "SB run is done, press any..."
  362.     SLEEP
  363.     PRINT "Drag drop a *SB.txt file onto SB.exe to run."
  364.     SLEEP
  365.     END
  366.  
  367. FUNCTION wPut% (sVar$, nVar$, value$) '  nVar$ must exist   "Put" 'into variable name at w$(2) at nplace w$(3) the value at w$(4)
  368.     'if this function fails return false else return 1
  369.     DIM nValue
  370.     DIM OK, i AS INTEGER, wc AS INTEGER
  371.     DIM sVal$, b$
  372.     nValue = 0
  373.     OK = nLookUp%(nVar$, nValue)
  374.     IF OK = 0 THEN wPut% = 0: EXIT FUNCTION
  375.     sVal$ = ""
  376.     OK = sLookUp%(sVar$, sVal$)
  377.     b$ = ""
  378.     IF OK = 0 THEN 'no string var started
  379.         FOR i = 1 TO nValue - 1
  380.             b$ = b$ + "`" + " "
  381.         NEXT
  382.         b$ = b$ + value$
  383.         sRecord sVar$, b$
  384.         wPut% = 1
  385.     ELSE 'sVar$ started so get the string count and put the value in it or at end of it in position nValue
  386.         wc = wCnt(sVal$)
  387.         IF nValue > wc THEN 'new value is past current size
  388.             b$ = sVal$ + " "
  389.             FOR i = wc + 1 TO nValue - 1
  390.                 b$ = b$ + "`" + " "
  391.             NEXT
  392.             b$ = b$ + value$
  393.             sRecord sVar$, b$
  394.             wPut% = 1
  395.         ELSE 'new value replaces one in string
  396.             FOR i = 1 TO wc
  397.                 IF i <> nValue THEN b$ = b$ + Wrd$(sVal$, i) + " " ELSE b$ = b$ + value$ + " "
  398.             NEXT
  399.             sRecord sVar$, RTRIM$(b$)
  400.             wPut% = 1
  401.         END IF
  402.     END IF
  403.  
  404.  
  405. FUNCTION find% (ln AS INTEGER)
  406.     DIM i AS INTEGER, c AS INTEGER
  407.     DIM fw$
  408.     c = 1
  409.     FOR i = ln + 1 TO UBOUND(p$)
  410.         fw$ = Wrd$(p$(i), 1)
  411.         IF fw$ = "f" THEN
  412.             c = c - 1
  413.             IF c = 0 THEN find = i: EXIT FUNCTION
  414.         ELSEIF fw$ = "i" THEN
  415.             c = c + 1
  416.         ELSEIF fw$ = "e" AND c = 1 THEN
  417.             find = i: EXIT FUNCTION
  418.         END IF
  419.     NEXT
  420.     PRINT "Error: could not find e or f to match i in line "; ln
  421.     find = -1
  422.  
  423. SUB nRecord (n$, value)
  424.     DIM mt AS INTEGER, i AS INTEGER
  425.     DIM ln$
  426.     mt = -1
  427.     ln$ = LCASE$(n$)
  428.     FOR i = 0 TO nmax
  429.         IF nName$(i) = "" AND mt = -1 THEN mt = i
  430.         IF nName$(i) = ln$ THEN nValue(i) = value: EXIT SUB
  431.     NEXT
  432.     IF mt <> -1 THEN nName$(mt) = ln$: nValue(mt) = value
  433.  
  434. FUNCTION nLookUp% (nVarName$, value)
  435.     DIM i AS INTEGER
  436.     DIM ln$
  437.     ln$ = LCASE$(nVarName$)
  438.     FOR i = 0 TO nmax
  439.         IF nName$(i) = ln$ THEN value = nValue(i): nLookUp% = 1: EXIT FUNCTION
  440.     NEXT
  441.     value = -999: nLookUp% = 0
  442.  
  443. SUB sRecord (n$, value$)
  444.     DIM mt AS INTEGER, i AS INTEGER
  445.     DIM ln$
  446.     ln$ = LCASE$(n$)
  447.     mt = -1
  448.     FOR i = 0 TO smax 'check if name is used yet, if so set value$ to it
  449.         IF sName$(i) = "" AND mt = -1 THEN mt = i 'save the first open slot in case we need it
  450.         IF sName$(i) = ln$ THEN sValue$(i) = value$: EXIT SUB
  451.     NEXT
  452.     IF mt <> -1 THEN sName$(mt) = ln$: sValue$(mt) = value$
  453.  
  454. FUNCTION sLookUp% (nVarName$, value$)
  455.     DIM i AS INTEGER
  456.     DIM ln$
  457.     ln$ = LCASE$(nVarName$)
  458.     FOR i = 0 TO smax
  459.         IF sName$(i) = ln$ THEN value$ = sValue$(i): sLookUp% = 1: EXIT FUNCTION
  460.     NEXT
  461.     value$ = "": sLookUp% = 0
  462.  
  463.  
  464. 'this preps e$ string for actual evaluation function and makes call to it,
  465. 'checks results for error returns that or number if no error.
  466. FUNCTION Evaluate (e$)
  467.     IF debug THEN PRINT "Evaluate gets: "; e$
  468.     'Dim As String c, b, subst
  469.     DIM b$, c$, subst$, wd$, fun$
  470.     DIM v
  471.     b$ = "" 'rebuild string with padded spaces
  472.     'this makes sure ( ) + * / % ^ are wrapped with spaces, on your own with - sign
  473.     FOR i = 1 TO LEN(e$) 'filter chars and count ()
  474.         c$ = MID$(e$, i, 1)
  475.         IF c$ = ")" THEN
  476.             po = po - 1: b$ = b$ + " ) "
  477.         ELSEIF c$ = "(" THEN
  478.             po = po + 1: b$ = b$ + " ( "
  479.         ELSEIF INSTR("+*/%^", c$) > 0 THEN
  480.             b$ = b$ + " " + c$ + " "
  481.         ELSEIF INSTR(" -.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz<>=", c$) > 0 THEN
  482.             b$ = b$ + c$
  483.         END IF
  484.         IF po < 0 THEN EvalErr$ = "Too many )": EXIT FUNCTION
  485.     NEXT
  486.     IF po <> 0 THEN EvalErr$ = "Unbalanced ()": EXIT FUNCTION
  487.     e$ = wPrep$(b$)
  488.     FOR i = 1 TO 3
  489.         p = wIn(LCASE$(e$), Wrd$("rnd e pi", i))
  490.         WHILE p > 0
  491.             SELECT CASE i
  492.                 CASE 1: subst$ = LTRIM$(STR$(RND))
  493.                 CASE 2: subst$ = LTRIM$(STR$(EXP(1)))
  494.                 CASE 3: subst$ = LTRIM$(STR$(_PI))
  495.             END SELECT
  496.             e$ = wSubst$(e$, p, p, subst$)
  497.             p = wIn(LCASE$(e$), Wrd("rnd e pi", i))
  498.         WEND
  499.     NEXT
  500.     wc = wCnt(e$)
  501.     b$ = ""
  502.     FOR i = 1 TO wc
  503.         wd$ = Wrd$(e$, i)
  504.         v = 0
  505.         f = nLookUp%(wd$, v)
  506.         IF debug THEN PRINT "nLookup of "; wd$; " found:"; f; " value "; v
  507.         IF f THEN b$ = b$ + LTRIM$(STR$(v)) + " " ELSE b$ = b$ + wd$ + " "
  508.     NEXT
  509.     e$ = RTRIM$(b$)
  510.     IF debug THEN PRINT "Evaluate pre digests e to: "; e$
  511.     Evaluate = evalW(e$)
  512.  
  513. ' the recursive part of EVAL, eliminated DFlag, now check lcase$ of fun$
  514. FUNCTION evalW (s$)
  515.     DIM pop AS INTEGER, lPlace AS INTEGER, i AS INTEGER, rPlace AS INTEGER, wc AS INTEGER
  516.     DIM po AS INTEGER, funPlace AS INTEGER, recurs AS INTEGER, p AS INTEGER, o AS INTEGER
  517.     'Dim As String fun, w, test, inner, ops, op, middle
  518.     DIM a, b, innerV, m
  519.     DIM fun$, test$, inner$, w$, ops$, op$, middle$
  520.     IF debug THEN PRINT "EvalW gets: "; s$ 'debug or fun$ to watch recursive calls in reverse
  521.  
  522.  
  523.     pop = wIn(s$, "(") 'parenthesis open place
  524.     WHILE pop > 0
  525.         IF pop = 1 THEN
  526.             fun$ = "": lPlace = 1
  527.         ELSE
  528.             test$ = LCASE$(Wrd$(s$, pop - 1))
  529.             funPlace = wIn("int sin cos tan atan log exp sqr rad deg", test$) 'no asin or acos in QB64
  530.             IF funPlace > 0 THEN
  531.                 fun$ = test$: lPlace = pop - 1
  532.             ELSE
  533.                 fun$ = "": lPlace = pop
  534.             END IF
  535.         END IF
  536.         wc = wCnt(s$): po = 1
  537.         FOR i = pop + 1 TO wc
  538.             IF Wrd$(s$, i) = "(" THEN po = po + 1
  539.             IF Wrd$(s$, i) = ")" THEN po = po - 1
  540.             IF po = 0 THEN rPlace = i: EXIT FOR
  541.         NEXT
  542.         inner$ = ""
  543.         FOR i = (pop + 1) TO (rPlace - 1)
  544.             w$ = Wrd$(s$, i)
  545.             inner$ = inner$ + w$ + " "
  546.             IF wIn("( and or = < > <= >= <> + - * / % ^", w$) > 0 THEN recurs = 1
  547.         NEXT
  548.         IF recurs THEN innerV = evalW(inner$) ELSE innerV = VAL(inner$)
  549.         SELECT CASE LCASE$(fun$)
  550.             CASE "": m = innerV
  551.             CASE "int": m = INT(innerV)
  552.             CASE "sin": m = SIN(innerV)
  553.             CASE "cos": m = COS(innerV)
  554.             CASE "tan": m = TAN(innerV)
  555.                 'QB64 doesn't have these?
  556.                 'CASE "asin": IF DFlag THEN m = DEG * (Asin(innerV)) ELSE m = Asin(innerV)
  557.                 ' CASE "acos": IF DFlag THEN m = DEG * (acos(innerV)) ELSE m = acos(innerV)
  558.             CASE "atan": m = ATN(innerV)
  559.             CASE "log"
  560.                 IF innerV > 0 THEN
  561.                     m = LOG(innerV)
  562.                 ELSE
  563.                     EvalErr$ = "LOG only works on numbers > 0.": EXIT FUNCTION
  564.                 END IF
  565.             CASE "exp" 'the error limit is inconsistent in JB
  566.                 IF -745 <= innerV AND innerV <= 709 THEN 'your system may have different results
  567.                     m = EXP(innerV)
  568.                 ELSE
  569.                     'what the heck???? 708 works fine all alone as limit ?????
  570.                     EvalErr$ = "EXP(n) only works for n = -745 to 709.": EXIT FUNCTION
  571.                 END IF
  572.             CASE "sqr"
  573.                 IF innerV >= 0 THEN
  574.                     m = SQR(innerV)
  575.                 ELSE
  576.                     EvalErr$ = "SQR only works for numbers >= 0.": EXIT FUNCTION
  577.                 END IF
  578.             CASE "rad": m = innerV * RAD
  579.             CASE "deg": m = innerV * DEG
  580.             CASE ELSE: EvalErr$ = "Unidentified function " + fun$: EXIT FUNCTION
  581.         END SELECT
  582.         s$ = wSubst(s$, lPlace, rPlace, LTRIM$(STR$(m)))
  583.         pop = wIn(s$, "(")
  584.     WEND
  585.  
  586.     ops$ = "% ^ / * - + = < > <= >= <> and or not" 'all () cleared, now for binary ops (not not binary but is last!)
  587.     FOR o = 1 TO 15
  588.         op$ = Wrd$(ops$, o)
  589.         p = wIn(s$, op$)
  590.         WHILE p > 0
  591.             a = VAL(Wrd$(s$, p - 1))
  592.             b = VAL(Wrd$(s$, p + 1))
  593.             SELECT CASE op$
  594.                 CASE "%"
  595.                     IF b >= 2 THEN
  596.                         middle$ = LTRIM$(STR$(INT(a) MOD INT(b)))
  597.                     ELSE
  598.                         EvalErr$ = "For a Mod b, b value < 2."
  599.                         EXIT FUNCTION
  600.                     END IF
  601.                 CASE "^"
  602.                     IF INT(b) = b OR a >= 0 THEN
  603.                         middle$ = LTRIM$(STR$(a ^ b))
  604.                     ELSE
  605.                         EvalErr$ = "For a ^ b, a needs to be >= 0 when b not integer."
  606.                         EXIT FUNCTION
  607.                     END IF
  608.                 CASE "/"
  609.                     IF b <> 0 THEN
  610.                         middle$ = LTRIM$(STR$(a / b))
  611.                     ELSE
  612.                         EvalErr$ = "Div by 0"
  613.                         EXIT FUNCTION
  614.                     END IF
  615.                 CASE "*": middle$ = LTRIM$(STR$(a * b))
  616.                 CASE "-": middle$ = LTRIM$(STR$(a - b))
  617.                 CASE "+": middle$ = LTRIM$(STR$(a + b))
  618.                 CASE "=": IF a = b THEN middle$ = "1" ELSE middle$ = "0"
  619.                 CASE "<": IF a < b THEN middle$ = "1" ELSE middle$ = "0"
  620.                 CASE ">": IF a > b THEN middle$ = "1" ELSE middle$ = "0"
  621.                 CASE "<=": IF a <= b THEN middle$ = "1" ELSE middle$ = "0"
  622.                 CASE ">=": IF a >= b THEN middle$ = "1" ELSE middle$ = "0"
  623.                 CASE "<>": IF a <> b THEN middle$ = "1" ELSE middle$ = "0"
  624.                 CASE "and": IF a <> 0 AND b <> 0 THEN middle$ = "1" ELSE middle$ = "0"
  625.                 CASE "or": IF a <> 0 OR b <> 0 THEN middle$ = "1" ELSE middle$ = "0"
  626.                 CASE "not": IF b = 0 THEN middle$ = "1" ELSE middle$ = "0" 'use b as nothing should be left of not
  627.             END SELECT
  628.             s$ = wSubst$(s$, p - 1, p + 1, middle$)
  629.             'PRINT s$
  630.             p = wIn(s$, op$)
  631.         WEND
  632.     NEXT
  633.     IF debug THEN PRINT "evalW returns "; VAL(s$)
  634.     evalW = VAL(s$)
  635.  
  636.  
  637. 'return trimmed  source string s with one space between each word
  638. FUNCTION wPrep$ (ss$)
  639.     DIM s$, b$, c$
  640.     DIM p AS INTEGER, i AS INTEGER
  641.     s$ = LTRIM$(RTRIM$(ss$))
  642.     IF LEN(s$) = 0 THEN wPrep$ = "": EXIT FUNCTION
  643.  
  644.     'remove all double or more spaces
  645.     p = INSTR(s$, "  ")
  646.     WHILE p > 0
  647.         s$ = MID$(s$, 1, p) + MID$(s$, p + 2, LEN(s$) - p - 1)
  648.         p = INSTR(s$, "  ")
  649.     WEND
  650.     b$ = ""
  651.     FOR i = 1 TO LEN(s$)
  652.         c$ = MID$(s$, i, 1)
  653.         IF ASC(c$) > 31 THEN b$ = b$ + c$
  654.     NEXT
  655.     wPrep$ = b$
  656.  
  657. ' This duplicates JB word(string, wordNumber) base 1, space as default delimiter
  658. ' by returning the Nth word of source string s
  659. ' this function assumes s has been through wPrep
  660. FUNCTION Wrd$ (ss$, wNumber)
  661.     DIM s$, w$
  662.     DIM i AS INTEGER, c AS INTEGER
  663.     s$ = ss$ 'don't change ss$
  664.     IF LEN(s$) = 0 THEN Wrd$ = "": EXIT FUNCTION
  665.     w$ = "": c = 1
  666.     FOR i = 1 TO LEN(s$)
  667.         IF MID$(s$, i, 1) = " " THEN
  668.             IF c = wNumber THEN Wrd$ = w$: EXIT FUNCTION
  669.             w$ = "": c = c + 1
  670.         ELSE
  671.             w$ = w$ + MID$(s$, i, 1)
  672.         END IF
  673.     NEXT
  674.     IF c <> wNumber THEN Wrd$ = " " ELSE Wrd$ = w$
  675.  
  676. 'This function counts the words in source string s
  677. 'this function assumes s has been thru wPrep
  678. FUNCTION wCnt (s$)
  679.     DIM c AS INTEGER, p AS INTEGER, ip AS INTEGER
  680.     's = wPrep(s)
  681.     IF LEN(s$) = 0 THEN wCnt = 0: EXIT FUNCTION
  682.     c = 1: p = 1: ip = INSTR(p, s$, " ")
  683.     WHILE ip
  684.         c = c + 1: p = ip + 1: ip = INSTR(p, s$, " ")
  685.     WEND
  686.     wCnt = c
  687.  
  688. 'Where is word In source s, 0 = Not In source
  689. 'this function assumes s has been thru wPrep
  690. FUNCTION wIn (s$, wd$)
  691.     DIM wc AS INTEGER, i AS INTEGER
  692.     wc = wCnt(s$): wIn = 0
  693.     FOR i = 1 TO wc
  694.         IF Wrd$(s$, i) = wd$ THEN wIn = i: EXIT FUNCTION
  695.     NEXT
  696.  
  697. ' substitute string in s to replace section first to last words inclusive
  698. 'this function assumes s has been thru wPrep
  699. FUNCTION wSubst$ (s$, first, last, subst$)
  700.     DIM wc AS INTEGER, i AS INTEGER, subF AS INTEGER
  701.     DIM b$
  702.     wc = wCnt(s$): b$ = ""
  703.     FOR i = 1 TO wc
  704.         IF first <= i AND i <= last THEN 'do this only once!
  705.             IF subF = 0 THEN b$ = b$ + subst$ + " ": subF = 1
  706.         ELSE
  707.             b$ = b$ + Wrd$(s$, i) + " "
  708.         END IF
  709.     NEXT
  710.     wSubst$ = LTRIM$(RTRIM$(b$))
  711.  
  712. FUNCTION leftOf$ (source$, of$)
  713.     DIM posOf AS INTEGER
  714.     posOf = INSTR(source$, of$)
  715.     IF posOf > 0 THEN leftOf$ = MID$(source$, 1, posOf - 1)
  716.  
  717. FUNCTION rightOf$ (source$, of$)
  718.     DIM posOf AS INTEGER
  719.     posOf = INSTR(source$, of$)
  720.     IF posOf > 0 THEN rightOf$ = MID$(source$, posOf + LEN(of$))
  721.  

... And you can follow the link above for an example pong demo and the full help index.

To bump the number of working demos up by one - perhaps, because maybe this exists somewhere - here is a program that calculates the factorial of a number. Just compile the main code, save this file as facto SB.txt, and then drag+drop the txt onto the executable (or do the equivalent in linux).

Code: [Select]
n facto 6
n prod facto

: dofact
i facto = 1
    . prod
    z
f
i facto > 1
    n facto facto - 1
    n prod prod * facto
f
g dofact

.
.
.
.
.

For completeness, here is the list of commands and so on:

Code: [Select]
. 000 Help SB.txt FOR SB.exe (B+=MGA) rev 2018-09-14 Drag AND drop *B.txt file onto SB.exe TO RUN it.
. (All lines here are PRINT lines, drag AND drop this file onto SB.exe TO READ it without dots.)
. TO avoid punctuation, all executed lines start with keyword commands OR punctuation AS follows:
. ===========================================================================================================  VARIABLES
. Number variables are set st n IS first letter ON LINE, variable NAME IS NEXT, AND variable expression last.
. Use up TO 250 "words" FOR variable AND expression including previous number variables, operators: +-*/^%()<=>
. constants: e, pi, RND   trig functions (radians): COS(), SIN(), TAN(), atan(), conversion: rad(), deg(), INT()
. LOG(), EXP(), operators USING <, =, >, (NOT combinations >= <=) AND, OR, NOT, need TO be separated by spaces.
. example:  i = i + 1 becomes >>>>>   n i i+1
. angle = deg(atan(1.01) becomes >  n angle deg(atan(1.01))
. ===========================================================================================================  ARRAYS
. < arrayName index valueExpression - same AS arrayName(index) = valueExpression  (No DIM statement needed)
. > var arrayName index - same AS var = arrayName(index)
. ===========================================================================================================  OUTPUT
. FOR printing text:   . FOR PRINT with LINE feed,     , FOR PRINT AND TAB,      ; FOR PRINT AND STOP
. l row col    - FOR locating NEXT character cell FOR PRINT OR INPUT place
. a x y text   - FOR locating with graphic x, y pixel positions
. c  - TO CLEAR clutter
. variables in PRINT text will be replaced by their values, so be careful USING variable names in PRINT text.
. When there IS more than one parameter be careful NOT TO use a space in an expression FOR one of the parameters.
. =========================================================================================================== INPUT
. ? var prompt - syntax: ? IS keyword, variable NAME, use 250 words FOR prompt.
. ===========================================================================================================  EXECUTION FLOW
. : lineLabel - sets LINE label in program
. g lineLabel - redirects flow TO mark lineLabel ( DO NOT enter OR EXIT a SUB with go )
. s subLabel - marks start of GOSUB routine
. gs subLabel - redirects flow TO SUB routine
. r - signals EXIT back TO CALL POINT of SUB routine
. w - will pause the given amount of seconds
. z - will END program
. ===========================================================================================================  LOOPING
. [ - marks start of LOOP
. ] - marks the END of LOOP, required with DO
. x - commands EXIT from LOOP
. ===========================================================================================================  BOOLEAN BLOCKS
. i - starts one AND IS followed by Boolean expression TO evaluate
. e - optional, marks LINE TO GOTO IF Boolean evaluates false
. f - marks END of Boolean block
 
 
Title: Re: Shorthand Basic
Post by: bplus on March 07, 2020, 07:15:51 pm
Quote
He describes it nicely here:

https://www.qb64.org/forum/index.php?topic=16.msg115312#msg115312

I am moving that post here where it belongs:

SB - Shorthand Basic, renamed from BRUN2, originally Nano3. I thought I had updated the parser but no, same old Eval function as Nano, Plot I think got the updated Eval function here at QB64. Funny story, I renamed this to SB to piss off the ScriptBasic guy who wanted to own capital SB for his favorite Basic relegating "sb" to SmallBASIC for shorthand at Retro (maybe it's only funny to me). Also Simple Basic or Short Basic also work.

STxAxTIC already has the source SB.bas file upstairs and it will also be in the zip for the whole folder including a debugger of sorts.

You type up your code in a regular old txt file ending filename with " SB.txt"

Here is an example called "Infinite Pong the movie SB.txt"
Code: QB64: [Select]
  1. Infinite Pong the Movie (for SB by B+ 2018-09-19)
  2.  
  3. constants
  4. n p1y 2
  5. n p2y 43
  6. n pw 10
  7.  
  8. ball
  9. n bx 75
  10. n by 20
  11. n bdx 2
  12. n bdy 1
  13.  
  14. main
  15. [
  16.         c
  17.         gs P1
  18.         gs P2
  19.         gs B
  20.         w .1
  21. ]
  22.  
  23. s P1
  24.         n p1x bx - 5
  25.         l p1y p1x
  26.         ; 1111111111
  27. r
  28.  
  29. s P2
  30.         n p2x bx - 5
  31.         l p2y p2x
  32.         ; 2222222222
  33. r
  34.  
  35. s B
  36.         i bx + bdx < 7
  37.                 n bdx bdx * -1 + int(rnd * 3) - 1
  38.         f
  39.         i bx + bdx > 143
  40.                 n bdx bdx * -1 + int(rnd * 3) - 1
  41.         f
  42.         i by + bdy < 3
  43.                 n bdy bdy * -1
  44.                 n bdx bdx + int(rnd * 3) - 1
  45.         f
  46.         i by + bdy > 42
  47.                 n bdy bdy * -1
  48.                 n bdx bdx + int(rnd * 3) - 1
  49.         f
  50.         n bx bx + bdx
  51.         n by by + bdy
  52.         l by bx
  53.         ; O
  54. r
  55.  
  56.  
  57.  

You drag and drop (or copy and paste) the SB.txt file onto SB.exe and it runs it. There is no IDE or editor or File Mgt so everything is done in Windows Explorer in same folder.

Here is Infinite Pong the Movie in QB64 to compare:
Code: QB64: [Select]
  1. _TITLE "Infinite Pong the Movie.bas for QB64 B+ 2018-09-19"
  2. p1y = 1: p2y = 25 'paddle y
  3. bx = 30: by = 10: bdx = 2: bdy = 1 'ball x, y, dx, dy
  4.     CLS
  5.     p1x = bx - 5: _PRINTSTRING (p1x, p1y), "1111111111" ' draw paddle 1
  6.     p2x = bx - 5: _PRINTSTRING (p2x, p2y), "2222222222" ' draw paddle 2
  7.     IF bx + bdx < 6 THEN bdx = bdx * -1 + INT(RND * 3) - 1
  8.     IF bx + bdx > 74 THEN bdx = bdx * -1 + INT(RND * 3) - 1
  9.     IF by + bdy < 2 THEN bdy = bdy * -1: bdx = bdx + INT(RND * 3) - 1
  10.     IF by + bdy > 24 THEN bdy = bdy * -1: bdx = bdx + INT(RND * 3) - 1
  11.     bx = bx + bdx: by = by + bdy
  12.     _PRINTSTRING (bx, by), "O"
  13.     _LIMIT 10
  14.  
  15.  

Here is Help File for SB "000 Help SB.txt" (drag and drop on SB.exe or just read and ignore the . = Print":
Quote
. 000 Help SB.txt for SB.exe (B+=MGA) rev 2018-09-14 Drag and drop *B.txt file onto SB.exe to run it.
. (All lines here are print lines, drag and drop this file onto SB.exe to read it without dots.)
. To avoid punctuation, all executed lines start with keyword commands or punctuation as follows:
. ===========================================================================================================  VARIABLES
. Number variables are set st n is first letter on line, variable name is next, and variable expression last.
. Use up to 250 "words" for variable and expression including previous number variables, operators: +-*/^%()<=>
. constants: e, pi, rnd   trig functions (radians): cos(), sin(), tan(), atan(), conversion: rad(), deg(), int()
. log(), exp(), operators using <, =, >, (not combinations >= <=) and, or, not, need to be separated by spaces.
. example:  i = i + 1 becomes >>>>>   n i i+1
. angle = deg(atan(1.01) becomes >  n angle deg(atan(1.01))
. ===========================================================================================================  ARRAYS
. < arrayName index valueExpression - same as arrayName(index) = valueExpression  (No DIM statement needed)
. > var arrayName index - same as var = arrayName(index)
. ===========================================================================================================  OUTPUT
. For printing text:   . for print with line feed,     , for print and tab,      ; for print and stop
. l row col    - for locating next character cell for print or input place, l for locate
. @ x y text   - for locating with graphic x, y pixel positions, @ for at
. c  - to clear clutter, c for cls
. variables in print text will be replaced by their values, so be careful using variable names in print text.
. When there is more than one parameter be careful not to use a space in an expression for one of the parameters.
. =========================================================================================================== INPUT
. ? var prompt - syntax: ? is keyword, variable name, use 250 words for prompt. Input numbers only for var.
. ===========================================================================================================  EXECUTION FLOW
. : lineLabel - sets line label in program
. g lineLabel - redirects flow to mark lineLabel ( do not enter or exit a sub with go ), g for goto
. s subLabel - marks start of gosub routine, s for sub
. gs subLabel - redirects flow to sub routine, gs for gosub
. r - signals exit back to call point of sub routine, r for return
. w - will pause the given amount of seconds, w for wait
. z - will end program, z for last or end
. ===========================================================================================================  LOOPING
. [ - marks start of loop, think do
. ] - marks the end of loop, required with ], think loop
. x - commands exit from loop, think exit
. ===========================================================================================================  BOOLEAN BLOCKS
. i - starts one and is followed by Boolean expression to evaluate
. e - optional, marks line to goto if Boolean evaluates false
. f - marks end of Boolean block

38 line Manual, not bad!
It is now updated for this thread, before move and STxAxTIC's copy above had some artifacts left from last name change.

Here are some sample SB.txt programs that work last time I looked along with SB and SB debugger (see attached zip).

PS Oh hey! I did have something going for arrays, see Help < and > commands and "and one for the monkey problem" that was testing a string array.

PPS "Hello SB.txt" program testing ? = Input command symbol does not work for strings, it's expecting a number variable

PPPS SB is an anagram and palindrome of BS.
Title: Re: Shorthand Basic
Post by: bplus on March 07, 2020, 07:43:54 pm
Today I modified STxAxTIC's factorial app to test recursive property of gs command for GOSUB:

Code is more accurate in Quotes because it's in normal text:
Quote
try recursive calls to gosub (gs) for factorial b+ 2020-03-07
[
   ? factorialMe Enter a number to find it's factorial
   i factorialMe <> 0
      n Fac 1
      gs F!
      . Factorial = Fac
   e
      . Goodbye!
      z
   f
   .
]
s F!
   i factorialMe > 1
      n Fac Fac * factorialMe
      n factorialMe factorialMe - 1
      gs F!
   e
      r
   f
r

Yeah good, 10 is limit before e notation kicks in.
 
Title: Re: Shorthand Basic
Post by: bplus on March 07, 2020, 08:06:26 pm
Oh hey! and it looks like I did start on strings! Looky here from SB.bas
Code: QB64: [Select]
  1.             CASE "$" 'record literal strings to variables here
  2.                 es$ = rightOf$(p$(cl), "{")
  3.                 es$ = leftOf$(es$, "}")
  4.                 sRecord w$(2), es$
  5.             CASE "sf" 'string functions syntax: sf var sFunction parameters, according to function var will be string or number
  6.                 SELECT CASE w$(3)
  7.                     CASE "+" 'concant string varaible values
  8.                         temp$ = ""
  9.                         FOR i = 4 TO wc
  10.                             IF sLookUp%(w$(i), s$) > 0 THEN temp$ = temp$ + s$
  11.                         NEXT
  12.                         sRecord w$(2), temp$
  13.                     CASE "word"
  14.                         v = INT(Evaluate(w$(5)))
  15.                         OK% = sLookUp%(w$(4), s$)
  16.                         IF v > 0 AND OK% THEN
  17.                             sRecord w$(2), Wrd$(s$, v)
  18.                         ELSE
  19.                             PRINT "word error: could not get " + w$(5) + " word from variable " + w$(4)
  20.                         END IF
  21.                     CASE "spc"
  22.                         sRecord w$(2), SPACE$(INT(Evaluate(w$(4))))
  23.                     CASE "mid"
  24.                     CASE "instr"
  25.                     CASE "date"
  26.                 END SELECT
  27.  

And here is the some SB.txt test code for that:
Quote
test new string functions SB.txt B+ 2018-09-15
$ months {January February March April May June July August September October November December} < this is new string literal recorder
l 2*5 10/10  <I am just testing locate l here
[
   'c
   ? nMonth Enter month number to name >
   i nMonth > 0 and nMonth < 13
      sf xmonth word months nMonth  < sf stands for string function, xmonth is var to load word returns the nth word in string
      opps can't comment next lines because they are printing a formatted line
      ; The nMonth                 
      ; th Month of a year is xmonth
      next line adds period to end of formatted print line
      . .
   e
      x
   f
]

Run Output:
 


Is this boring like a proud parent yakking on and on about es child's first steps, first words.... ;)

Title: Re: Shorthand Basic
Post by: STxAxTIC on March 07, 2020, 09:19:20 pm
Ah, I didn't know this did recursion!

I remember a funny story regarding the recursion milestone with Sxript -  back in 2014, Luke blew my mind by writing its first recursive function, and I never explicitly told the parser to handle recursion. I was naive and I was shocked, but I became enlightened on that day.... So in this spirit I propose we turn "Luke" into a verb, roughly defined to say "the act of writing a factorial routine in your buddy's toy language". So in a sentence, I Luked Shorthand Basic in that post... Anyway, I ramble.

I like SB quite a bit - I'm gonna spend a minute combing through the examples and decide how to present this on a forum page. I designated a code box for the LISP code over at https://www.qb64.org/forum/index.php?topic=2290.0 (https://www.qb64.org/forum/index.php?topic=2290.0)... Will do similar in this case.

Of course @bplus, you're welcome to post it yourself. It won't be seen as masturbatory. You've got a full set of keys to the library. Thanks so much for your service so far.

OH AND -

For code boxes on these forums containing non-QB64 code, you don't need to use a quote. You can click the "code" button anyway and then manually delete the QB64 tag within.
Title: Re: Shorthand Basic
Post by: bplus on March 07, 2020, 09:32:06 pm
Thanks for your support STxAxTIC, I am going to see if I can get strings further along. If I decide I have to cave in to double quotes of bend over backwards to avoid them that will be time to hang it up.

I looked at SB code in QB64 code boxes, code boxes and quotes, quotes work best. QB64 code is doing caps in all wrong places and it looks ridiculous, code boxes are indenting way too far in but Quotes look just right. Don't worry for long stuff I will attach txt file or use code box, the manual quote is longest I will go in quote box.



Title: Re: Shorthand Basic
Post by: STxAxTIC on March 07, 2020, 09:36:39 pm
Ah, understood about code boxes.

Say man, I went through the same issues with strings in Sxript, and decided to borrow from LaTeX with respect to bracketing. I open strings with a back-tick ( ` ) and close with a single quote ( ' ). Sxript ignores double quotes and treats them as joe-character like a Y or a 7. This way code can be embedded into other languages without getting tangled in *its* string regime. Of course, going down this road also involves escape characters, where I adopted the backslash as done in the rest of the world. All in all, a Sxript string might look like:

Quote
`Bplus\'s language is "very" excellent.'

... and renders to

Quote
Bplus's language is "very" excellent.


So anyway - that's what I went with.
Title: Re: Shorthand Basic
Post by: luke on March 09, 2020, 08:35:08 am
Though as we discovered on discord, the ` has problems itself if it get interpreted as Markdown.
Title: Re: Shorthand Basic
Post by: bplus on March 09, 2020, 10:21:48 am
I am leaning towards a special command that loads a string into a variable. As a variable, it is one clump of characters and I can maintain using only the space character as my parsing delimiter and no other punctuation goal.

I have reworked Eval that fixed problem of differentiation between - for minus and - for negative values and uses Split instead of Word tools for parsing just haven't installed it yet. It should deliver values from array immediately instead of counting down a string every time a value is needed.

Fellippe has me thinking Snake Game as next round of needed functions plus need an input for strings (another special command).

Special command looks like this:
$stringVarName and the rest of the line is the string

May do that with numbers too:
#numberVarName number or expression with previous #variables

so n = n + 1 is #n n+1
Title: Re: Shorthand Basic
Post by: STxAxTIC on March 09, 2020, 06:32:02 pm
Luke makes a valid point about backtick ` and Discord. My alternative is to have a function quote() that does the same thing as wrap in ` '.
Title: Re: Shorthand Basic
Post by: bplus on October 21, 2020, 10:08:25 pm
Quote
I have reworked Eval that fixed problem of differentiation between - for minus and - for negative values and uses Split instead of Word tools for parsing just haven't installed it yet. It should deliver values from array immediately instead of counting down a string every time a value is needed.

Finally got around to installing new Eval tools and after a little fix all the old programs seem to be working bad news is its 100 lines longer and my interpreter is closer to 1 K LOC than .5 K.
Title: Re: Shorthand Basic
Post by: bplus on February 10, 2021, 12:20:41 pm
I am reworking this from scratch (no Eval function) because of the way I want to handle strings.
Rework is under Simple Interpreter name but may keep SB name because allot of commands are same.

Stumped for some time about how to get away from double quotes identifier for string literals and then how to do functions with them. Once you get them contained in variable names no problem but who wants to make a variable for every letter or word you want to build into a string.

New Syntax for executable lines
cmd,arg1;arg2;arg3;...Chr$(10) or if presence of CR+LF detected in program string then parsed with that.

The comma alerts code that this might be a command line.
Only one type: variable length strings
The only way to tell a string literal from a variable is that variables start with ' mark.
So neither a string nor a variable can use ; and a string can't start with a '.
To clear tabs out from indented code from WP all chars <33 are filtered before exec.
hmm... pretty much assuming no chars < 32 in the lines after first parse and tabs cleared for cmd.

So now all cmds are followed by comma instead of a space, same amount of bytes as SB and bare text for literals (minus ;) and syntax using just a few non-shift keys , ;

So far, very hard to remember to tick a variable name and not type a space after a comma.
Ticking variables is bad but ticking literals including numbers, worse!

Oh! just got an idea how I might reinsert Eval while reviewing progress here. I am debating converting it to string math since all the variables are strings and I have string math basics worked out.
Title: Re: Shorthand Basic
Post by: Pete on February 10, 2021, 01:00:35 pm
Well it's shorthand, but I wouldn't call it BASIC. I do get the fun factor in regard to manipulating code back into usable statements. There are a lot of condition hurdles to address. This reminds me of mennonite's Fig Basic project, bt with a totally different focus. Now if you will excuse me, I have to get back to my own rabbit hole.

Pete
Title: Re: Shorthand Basic
Post by: bplus on February 10, 2021, 01:46:01 pm
Well it's shorthand, but I wouldn't call it BASIC. I do get the fun factor in regard to manipulating code back into usable statements. There are a lot of condition hurdles to address. This reminds me of mennonite's Fig Basic project, bt with a totally different focus. Now if you will excuse me, I have to get back to my own rabbit hole.

Pete

You are right, not to be called BASIC nor Basic, only Basic inspired and coded under.

I just got a hint of how to do Subs and Functions, my GOSUB command gs, can carry any amount (within reason) of arguments with it! So use gs, cmd as an GOSUB call or as a psuedo Sub call, you will still use r, for Return come back from it. All Arguments are Global but you can name arguments with the sub's name to ignore them as needed in main code, or (man I get ideas when I write to you all) or use Local keyword with the variable name, so we know we can dump them whenever we are outside the subs. Something like that...


Update: Oh hey, how about !Basic, since ! is the symbol for NOT in C or some other PL's, I think.
Always the name is the hot topic for Interpreters ;-))
Title: Re: Shorthand Basic
Post by: STxAxTIC on February 10, 2021, 02:06:08 pm
I'm all for this.

Actually, I'm for both rabbitholes. Hear me out:

bplus: make your language as portable as humanly possible in the sense that I should be able to bootstrap a screen-0 kernel of it onto any other BAS project. Make something like MasterEval$(a$), where a$ is any valid code in your language, and MasterEval$ returns its evaluated result. Text in, text out.

Pete: make your text editor able to include bplus's language. (If done right, this surgery is less than 5 lines.) For instance, when I'm typing, I want to write expressions and evaluate them, and have the result is pasted in where I was typing.

(Even if you think this idea is extremely dumb, you should be designing for it's eventuality anyway.)
Title: Re: Shorthand Basic
Post by: bplus on February 10, 2021, 03:43:26 pm
I'm all for this.

Actually, I'm for both rabbitholes. Hear me out:

bplus: make your language as portable as humanly possible in the sense that I should be able to bootstrap a screen-0 kernel of it onto any other BAS project. Make something like MasterEval$(a$), where a$ is any valid code in your language, and MasterEval$ returns its evaluated result. Text in, text out.

Pete: make your text editor able to include bplus's language. (If done right, this surgery is less than 5 lines.) For instance, when I'm typing, I want to write expressions and evaluate them, and have the result is pasted in where I was typing.

(Even if you think this idea is extremely dumb, you should be designing for it's eventuality anyway.)
Oh I already have stuff for evaluating formulas as independent exe you can call in a shell from inside your Basic code.

I forgot what I called it reckon.exe or something, oh maybe tabulator....

Yes
https://www.qb64.org/forum/index.php?topic=3136.msg124241#msg124241
Title: Re: Shorthand Basic
Post by: Aurel on February 10, 2021, 03:47:55 pm
Mark 
do you have complete code of this program?
Title: Re: Shorthand Basic
Post by: bplus on February 10, 2021, 03:57:13 pm
Mark 
do you have complete code of this program?

@Aurel

If you are talking about the remake of SB, it's still WIP'd and wont post anything until it shapes up to be better than last version of SB. This is an experiment to see if I can solve my string woes, it's either this or dissolve my insistence on no double quotes.

The Tabulator code should be in Link, if that was what you meant.
Title: Re: Shorthand Basic
Post by: Pete on February 10, 2021, 06:11:33 pm
I'm all for this.

Actually, I'm for both rabbitholes. Hear me out:

bplus: make your language as portable as humanly possible in the sense that I should be able to bootstrap a screen-0 kernel of it onto any other BAS project. Make something like MasterEval$(a$), where a$ is any valid code in your language, and MasterEval$ returns its evaluated result. Text in, text out.

Pete: make your text editor able to include bplus's language. (If done right, this surgery is less than 5 lines.) For instance, when I'm typing, I want to write expressions and evaluate them, and have the result is pasted in where I was typing.

(Even if you think this idea is extremely dumb, you should be designing for it's eventuality anyway.)

Well, like I always say... There are no such things as dumb ideas, just dumb people who come up them them. :D (No, not you guys.)

Hey guys I finally got a little more progress on my WP, yesterday and today. I reworked a better find routine, and added print and save. Also fixed about 8 bugs. I have one nasty paste bug, and I don't want to face it until I have a really clear head. The replace feature will  be added soon, but initially just as a replace all. So...

The replace part, Bill, is what I think you are getting act.  So using the example above, you mean type in something like: idiot ^ 2 the editor erases that and replaces it with Clippy / 10. Something like that, right?

Pete
Title: Re: Shorthand Basic
Post by: STxAxTIC on February 10, 2021, 06:31:59 pm
The replace part, Bill, is what I think you are getting act.  So using the example above, you mean type in something like: idiot ^ 2 the editor erases that and replaces it with Clippy / 10. Something like that, right?

Right, or maybe something that keep the original input too, stick it after an = sign perhaps.
Title: Re: Shorthand Basic
Post by: SMcNeill on February 10, 2021, 06:37:19 pm
Something like {formula 3+4*12=}, and then it prints “3 + 4 * 12 = 51”.
Title: Re: Shorthand Basic
Post by: Pete on February 10, 2021, 07:53:31 pm
I've coded some stuff like that in the past. For instance...

FOR i = 1 to 50

Type "fo" and the line changes to: FOR i = 1 to 2: NEXT

Now type j and it changes to: FOR j = 1 to 2: NEXT

Now type 5 and it changes to: FOR j = 5 to 2 STEP -1: NEXT

Now press tab.

Now type 9 and it changes to: FOR j = 5 to 9: NEXT

Now press Enter, and it changes to:

FOR j = 5 to 9
_
NEXT

The underline represents the new cursor position, ready to put the goods inside the loop.

So 20 key presses gets reduced to just 7.

I've also seen editors that do equations, as discussed in this thread. Fun stuff, but it can get pretty involved to code all the conditions.

Pete
Title: Re: Shorthand Basic
Post by: bplus on February 11, 2021, 08:02:31 pm
Today I am happy to report killing a couple of bugs to mapping a program for all jumps: loops, labels and if blocks.

Now I think the way is clear to add ElseIf to If, Else, End IF code blocks, more testing of tests already passed before the mapping then I will test the new ElseIf.

ElseIf saves one from having to indent all the way to Europe with nested IF tests for making big complex decisions like a string of commands to "Select Case" on for an Interpreter :)

Oh that's a good goal, build an interpreter with your interpreter.
Title: Re: Shorthand Basic
Post by: bplus on February 12, 2021, 11:59:25 pm
Finally got caught up to SB without an Eval function so looks a bit like assembly and ei for ElseIf does work, at least in my first test. That syntax is god awful, half my errors are missed ticks for variables and another half using a comma instead of semi-colon to divide arguments. The Program map of loops, labels and if block markers is big help.

So going to convert everything over to:
Command space var|arg, arg, arg+chr$13+chr$10 <Notepad++ insists

comma and space for readability, so no spaces in the command but all you want there after.

So flipping code and shortening WIP name Simple Interpreter to Interpreter.

Oh wait variables still need to be distinguished from literals. Well there's no use fighting habits, literals to start with "

I'm thinking a line editor can add space after commas and trim variables on both side and literal left of ".

Probably use a ' comment symbol to tell exec not to look for commands on that line.

Sample of Test 6 for ei command:
Code: [Select]
Test 6 the New ei command.txt b+ 2021-02-12 ei AKA ElseIf
.,    Let's examine the common factors of some numbers:
.,
[,
.,
?,num;  Please enter a number to test >
<,<2;'num;2
i,'<2
x,
e,
%,Nmod2;'num;2
=,Even;'Nmod2;0
%,Nmod3;'num;3
=,Triple;'Nmod3;0
%,Nmod5;'num;5
=,Pentacle;'Nmod5;0
%,Nmod7;'num;7
=,Septacle;'Nmod7;0

i,'Even
., ;'num; is Even.
ei,'Triple
., ;'num; is Triple.
ei,'Pentacle
., ;'num; is Pentacle.
ei,'Septacle
., ;'num; is Septacle.
e,
+,Remaining;1;-.5;-.1667;-.0333;-.0048
., The probability of ;'num; not being factorable by 2,3,5,7 is;'Remaining
f,
f,
],
.,
.,       Thanks for playing.

Quick convert program
Commas to spaces, ; to comma + space, swap ' for space and no ' for ", easy :)


Title: Re: Shorthand Basic
Post by: bplus on February 13, 2021, 01:18:26 am
Easier on the eyes? I know it should be easier to code except numbers:
Code: [Select]
Test 6 the New ei command.txt b+ 2021-02-12 ei AKA ElseIf
.     Let's examine the common factors of some numbers:
.
[
.
? num, "  Please enter a number to test >
< <2, num, "2
i <2
x
e
% Nmod2, num, "2
= Even, Nmod2, "0
% Nmod3, num, "3
= Triple, Nmod3, "0
% Nmod5, num, "5
= Pentacle, Nmod5, "0
% Nmod7, num, "7
= Septacle, Nmod7, "0

i Even
.  , num, " is Even.
ei Triple
.  , num, " is Triple.
ei Pentacle
.  , num, " is Pentacle.
ei Septacle
.  , num, " is Septacle.
e
+ Remaining, "1, "-.5, "-.1667, "-.0333, "-.0048
.  The probability of , num, " not being factorable by 2 3 5 7 is, Remaining
f
f
]
.
.        Thanks for playing.
Title: Re: Shorthand Basic
Post by: bplus on February 14, 2021, 09:40:53 am
Eh! Syntax is a nightmare, trying to play nice inside IDE and Notepad++

" to start a literal was a bonehead idea, so was a bunch of other hair pulling combo's of non-shift keys around the spacebar. THWI!

Thank odin for Eval! Look how easy the above code becomes! (From inside the IDE)
Code: [Select]
    p$ = "["
    p$ = p$ + NL$ + "? num, Please enter a number to test > "
    p$ = p$ + NL$ + "i num < 2"
    p$ = p$ + NL$ + "x"
    p$ = p$ + NL$ + "e"
    p$ = p$ + NL$ + "i num % 2 = 0"
    p$ = p$ + NL$ + ". num, is Even."
    p$ = p$ + NL$ + "ei num % 3 = 0"
    p$ = p$ + NL$ + ". num, is Triple."
    p$ = p$ + NL$ + "ei num % 5 = 0"
    p$ = p$ + NL$ + ". num, is Pentacle."
    p$ = p$ + NL$ + "ei num % 7 = 0"
    p$ = p$ + NL$ + ".  num, is Septacle."
    p$ = p$ + NL$ + "e"
    p$ = p$ + NL$ + "remaining = 1 - .5, - .1667 - .0333 -.0048"
    p$ = p$ + NL$ + ". The probability of , num, not being factorable by 2 3 5 7 is , remaining,."
    p$ = p$ + NL$ + "f"
    p$ = p$ + NL$ + "f"
    p$ = p$ + NL$ + "]"
    p$ = p$ + NL$ + ". "
    p$ = p$ + NL$ + ".     Thanks for playing."

Just make sure the variables have commas around them.

Added a shot of the Program Map from a Debug Screen.

Hey @odin, I like the screenshot transparent backgrounds, <3


PS Just realized I could have kept the decimals as fractions as an additional calc for Eval.
Checkout Eval at work on that...
Title: Re: Shorthand Basic
Post by: STxAxTIC on February 14, 2021, 11:00:52 am
Alrighty, trying to glue this all together.

Heya bplus, is there a way you could explain this as if I just walked in? There is a mixture of history, other programs, links to other places - all over this thread. Maybe a 30 second video of you using this?

Or: How close are you to distilling this to the smallest black box possible? That is, output$ = bpluseval$(input$), and that's it. If you claim you're already here, I want to see the whole thing at once please.

The goal is to be able to paste your work brainlessly into a REPL-like shell and use it that way. That will tell me its ready for many greater purposes! (All I mean is integration into things like QLiza, or sending info around using pipecom.)
Title: Re: Shorthand Basic
Post by: bplus on February 14, 2021, 11:43:25 am
Alrighty, trying to glue this all together.

Heya bplus, is there a way you could explain this as if I just walked in? There is a mixture of history, other programs, links to other places - all over this thread. Maybe a 30 second video of you using this?

Or: How close are you you to distilling this to the smallest black box possible? That is, output$ = bpluseval$(input$), and that's it. If you claim you're already here, I want to see the whole thing at once please.

The goal is to be able to paste your work brainlessly into a REPL-like shell and use it that way. That will till me its ready to may greater purposes! (All I mean is integration into things like QLiza, or sending info around using pipecom.)

I don't know, I was up to 4 Am last night and up early this morning in crazy exuberant rant ;-))

Here's more of the story, I was trying this and that with Polish or is it German... verb at the start and the objects at the end, no that's reverse German so yeah that might be Polish ( @FellippeHeitor and I do not mean disrespect to Germans or Polish, Germans put the verb on the end, it's a fact The Germans were pretty nasty to Poles so they, in world where language is influenced by nasty or friendly neighbors, the Poles in retribution put their verbs at the start. LOL)   Know whose language, I nothing; Command System...

Wait what was the question?

The answer is I don't know but anyway...

Around 2 AM out of pure frustration and desperation, (maybe I am part German), I had this vision " = "
Another way to parse a command line, so I plugged-in my most recent Eval version from Plot and the sky's cleared and Heaven again was known, at least for Test 2, Test 1 was just a g and gs label check. I quit and went to bed because all my aggravation was instantly relieved when I started doing more things the Basic way. Debugging now a piece of cake, at least with 2 Tests. (I quit while I was ahead plus dead tired.)

So I am going to ride the high for a bit before I start on test #3, LOL

So now you know why I am not claiming I am "already there" but I can claim, I guess from experience you can and coulda used p$ = program string since the first SB.exe. I built a plotter from Eval, I built a Tabulator from Eval what more proof of concept is needed. You Stx, must know what properly functioning Eval can do for you look at all the amazing over-my-head stuff you build.

eg
Quote
The goal is to be able to paste your work brainlessly into a REPL-like shell and use it that way. That will till (tell?)* me its ready to may (my?)* greater purposes! (All I mean is integration into things like QLiza (yeah I want to integrate with Liza2)*, or sending info around using pipecom.) 
*Stuff in () added by me bplus.

What? LOL





Title: Re: Shorthand Basic
Post by: bplus on February 14, 2021, 12:20:07 pm
It is kind of cool to see a 'Mindless Reptilian' string embedded in the code asking you questions based on real time data it's processing and then maybe drawing stuff.

So what is REPL-like shell? It's probably not a reptile, more like a replace tile maybe.

Update: "https://en.wikipedia.org/wiki/Read–eval–print_loop" < to see what I am looking at copy/paste the whole dang string the blue line cuts to a different place, perhaps the REPL needs a look into.

Oh yeah from what I can make of Wiki, yeah, we're in the same area code. It even says Eval and the mention of S like snake.

Oh Hey! The S for SB1

In Basic like system the name of variable (function for Lisp) is followed by a formula ie after the = sign.
Yes Eval handles the after the = part (or after the Boolean inquiry of If or ElseIf) after the code plugs-in the correct values at Run-time.
Title: Re: Shorthand Basic
Post by: STxAxTIC on February 14, 2021, 01:10:25 pm
Opps was typing too fast and didn't proofread.

To make the point better, I have this hobby of taking programs and reducing them to a single line of input and a single line of output. (At some point you'll know what I mean, stop reading at any time.)

For instance, in the QLiza server project, the actual "Eliza" part is reduced to one line of code (ignore the top part, that will soon become pipecom):

Code: QB64: [Select]
  1.     IF (LEFT$(TheRequest, LEN(TheKey)) = TheKey) THEN
  2.         temp = TheRequest
  3.         temp = (RIGHT$(temp, LEN(temp) - LEN(TheKey)))
  4.         SELECT CASE TheKey
  5.             CASE "#="
  6.                 PRINT "Processing...";
  7.                 temp = ShellProcess$(ManageWhiteness$(temp), 128, 10)
  8.                 PRINT " Done."
  9.             CASE "' "
  10.                 temp = Eliza$(temp)
  11.         END SELECT
  12.     ELSE
  13.         temp = TheRequest
  14.     END IF

I've done the same with QBguy's Lisp interpreter:

Code: QB64: [Select]
  1.     LINE INPUT ">"; q$
  2.     r$ = DoLISP$(q$, env)
  3.     PRINT r$: PRINT

Not to mention, here is sxript and pipecom together in a text editor project:

Code: QB64: [Select]
  1. InsertString("=" + SxriptEval$(Projection$(ID1, ID2)), z)
  2. InsertString("=" + pipecom_lite$(Projection$(ID1, ID2)), z)
  3.  

Anyway, the whole idea is containing the entire thing in one function of one argument. Even if it means reverse-engineering old aspects of the works to make it interface nicely.

Title: Re: Shorthand Basic
Post by: bplus on February 14, 2021, 01:46:19 pm
Yeah I've seen your Lisp and checked it out some on Internet, who doesn't like simple systems!

My first foray into an Eval was so very Lisp like (at time I didn't know anything about Lisp nor Lambda Calculus, luv to banter those fancy names though right or wrong), my observation relearned again over weekend is that it is not easy to read what those coded lines are doing and it's a struggle to experiment with and debug, though probably learn decent thinking skills, try using verbs at the start of your sentences for awhile.

Now I forgot where I was going with this, man! almost 2PM time for lunch, that's where I am going...

Oh p$ the program string is sucked in thus:

(drag drop, Command$)
Open existingFilename.txt$ for Binary as #1
p$ = space$(lof(1))
get #1, p$
close #1

There's your input string.

What you do with that is your business. Or hey, in from _clipboard
p$ = _Clipboard$  ' notice the structure subject verb object there's your function name on one side and your formula on the other. =(p$, _clipboard$) not so easy to understand, perhaps I am another ruined coder from Basic experience.

IDE code
ReDim Shared NL$
NL$ = Chr$(10) ' you don't need the 13
p$ = "first program line"
[
p$ = p$ + NL$ + "Next line"
? Are we there yet.
i yeah
   x
f
]
. Ready to proceed with p$.

Out to lunch...
Title: Re: Shorthand Basic
Post by: bplus on February 15, 2021, 04:58:45 pm
@STx

Oh piss!

I get it now, you not only want a p$ in but you want a p$ out, to where? well that's on a need to know basis, just get the stuff in string form and p?ss it on, maybe to a file, maybe to the _clipboard, maybe mail it to Liza, maybe to the Recycle Bin through a filter.

You don't care about any shows in-between?

Well there goes my, "Infinite Pong the Movie.txt" ;(


Yeah so that will be awhile, I like show business.

Plus I am finding errors and bugs and aggravations and vexations: right and left here and there, just in frick'n test 1 from previous Interpreter Test #3 for SB1.
Fix Trimming variable names
Fix special ' ' if want to not Ltrim spaces between arguments
Found, not, broken in Eval, such a simple what? Function? not exactly more a pain in the nut
Oh! I know how I can fix that now, just go to Poland again! that will work easy without messing with Eval.

To piss strings, that's nothing. LOL
Title: Re: Shorthand Basic
Post by: SMcNeill on February 15, 2021, 05:13:26 pm
I remember with my math evaluator, NOT Is a PITA to sort.  If we're talking order of operations, it's a conditional OOO symbol.  It processes FOREMOST on the priority list with anything to the left of it, but low to anything to the right of it, except other binary operators.

Best trick I remember finding was to wrap parentheses internally where NOT appeared.

3 + NOT 4 + 3

Now, where does that NOT process? 

If you add parentheses,it makes sense as:

3 + (NOT 4 + 3)



If that explanation helps any.  It's NOT the easiest operator to describe order of operations of.
Title: Re: Shorthand Basic
Post by: bplus on February 15, 2021, 06:37:49 pm
For descent or is it ascent or decent?

I have it the very last in order of processing, everything else must be done before it gets handled (on the level it's at inside parenthesis).

I want to treat it like a simple function NOT(X)
If X = 0 then NOT = -1 Else NOT = 0 ' > what could possibly go wrong?!

So simple, you would think. Just like at Doctor's today, trying to explain why we don't get BP's regularly for my mother. He thinks it's a simple thing. I thought it would be a simple thing but ... well no words describe the dynamic that goes on (I recently watched Young Sheldon's Thanksgiving vacation Episode.) Dynamic same word base as dynamite!
Title: Re: Shorthand Basic
Post by: bplus on February 15, 2021, 07:19:23 pm
Recalling my problem in Eval,  it was taking -1 and turning it to - 1 (subtraction) and wasn't finding anything to subtract 1 from, kind of a funny joke.

I thought I had all my problems with - sign resolved. No, one more when a string starts with a -number.
Title: Re: Shorthand Basic
Post by: SMcNeill on February 15, 2021, 07:32:29 pm
FUNCTION KNOT (X AS LONG)
    KNOT = - (X + 1)
END FUNCTION

There's a basic function for it, as long as it's integers.  ;)
Title: Re: Shorthand Basic
Post by: bplus on February 15, 2021, 07:37:48 pm
Ah that's interesting! Gotta try it.
Title: Re: Shorthand Basic
Post by: bplus on February 15, 2021, 07:50:09 pm
No I think I just have to sneak in a 0 to have something to subtract from.
Title: Re: Shorthand Basic
Post by: bplus on February 16, 2021, 11:18:15 pm
New jump command, if expression evaluates to true, jump out of the loop.
Before you could only exit a loop from inside an if block

i condition 'IF condition
   x 'exit
f 'end if

3 lines

now,
jump condition, exits to outside loop

Code: [Select]
' Test 3 new j for jump command for SB1.txt b+ 2021-02-16
LoopCount = 0
[
LoopCount = LoopCount + 1
j LoopCount > 14
k = 0
[
; *;
' oh dang this is bad i need i for indexes back to If for that command!
k = k + 1
' dang I cant use k = LoopCount but >= works!
j k >= LoopCount
]
.
]
.  And we are out of the loop and done with this test with 14 lines of stars?

 


Also realized it a mistake to use single letter commands specially i for IF

Title: Re: Shorthand Basic
Post by: bplus on February 18, 2021, 02:17:30 am
Testing some cool new commands for SB1:
Code: [Select]
' Test 4 Arithmetics.txt b+ 2021-02-17
a = 1 
b = 2
c = 3
d = 4
e = 5
' yeah when I get to arrays...
f = e + a
g = e + b
h = e + c
i = e + d
j = e * 2

.  a = ;a;/  b = ;b;/  c = ;c;/  d = ;d;/  e = ;e;/ f = ;f;/  g = ;g;/  h = ;h;/  i = ;i;/  j = ;j
+ result;a;b;c;d;e;f;g;h;i;j
. a + b +... + j = ;result
* result;a;b;c;d;e;f;g;h;i;j
. a * b *... * j = ;result
& result;a;b;c;d;e;f;g;h;i;j
. a & b &... & j = ;result

a = 7
. a = ;a
+= a;3.3
. a += 3.3 is ;a
-= a;3.3
. a -= 3.3 is ;a
*= a;3.3
. a *= 3.3 is ;a
/= a;3.3
. a /= 3.3 is ;a

 


Such commands might save on some typing.
a = a + 10
a += 10

a = 1 + 6 + 7 - 3
+ a;1;6;7;-3

& for String Concatenate.

Also am rid all single letter commands, here is a peak at the program shown earlier in this thread, 2 letter If Block commands:
Code: [Select]
'Test 6 the New ei command.txt b+ 2021-02-12 ei AKA ElseIf

' name change update If, It, Io, Ix
' may be read: If,  If True, If Otherwise, If eXit

.      Let's examine the common factors of some numbers:
[
? num; (Enter only will end Run) Please enter a number to test >
If num < 2
Exit
Io
If num % 2 = 0
. /   ;             num; is Even.
It num % 3 = 0
. /   ;num            ; is Triple.
It num % 5 = 0
. /   ; num; is Pentacle.
It num % 7 = 0
. /   ;   num  ; is Septacle.
Io
remaining = 1 - 1/2 - 1/6 - 1/30 - 1/210
. /   ;The probability of ; num; not having a First Factor of 2, 3, 4, 5 or 7 is ; remaining;.
Ix
.
Ix
]
.
.     Thanks for playing.

Title: Re: Shorthand Basic
Post by: bplus on February 22, 2021, 05:20:26 pm
Update on test 3 with revisions to SB1:
Code: [Select]
' Test 3 new j for jump command for SB1.txt b+ 2021-02-16 mod 2-21
[
+= loopCount;1
Jmp loopCount > 14
k = 0
[
; *;
+= k;1
Jmp k = LoopCount
]
.
]
.  And we are out of the loop and done with this test with 14 lines of stars?


Here is Simple Prime Sieve using new Set and Get:
Code: [Select]
' Test ad Simple Prime Sieve.txt rev from SB.exe 2018-09-14 adopted from:
' Simple sieve 2.bas SmallBASIC 2015-04-29 found a faster sieve with BASIC 256
topN = 1000
limit = topN ^ .5
. Primes to ;topN
' take care of even numbers first
' prime the pump
[
+= i;1
Jmp i > topN
Set 0; i; composites
]
i = 4
[
Set 2; i; composites
+= i;2
Jmp i > topN
]
' now do odd numbers
i = 3
[
Get test; i; composites
If test = 0
If i < limit
j = 2 * i
[
Set i; j; composites
+= j;i
Jmp j > topN
]
Fi
Fi
i = i + 2
Jmp i > limit
]
i = 2
pCount = 0
[
Get test; i; composites
If test = 0
+= pCount;1
, i
Fi
+= i;1
Jmp i > topN
]
.
.
. / There are ;pCount;/ primes for the first ; topN;/ integers.


Here is one that was a tough nut to crack but found interesting problem with Execution Flow when a Loop ends ] just before an EI (ElseIF) or  EL (Else) when flow is supposed to jump to FI (End If AKA Final If line sB uses that, its IF in reverse, I thought clever)

The Monkey Problem a tough nut to crack:
Code: [Select]
' Test ab ...and 1 for the monkey.txt rev for SB.exe convert 2021-02-20
' from ... and 1 for the monkey problem.bas for JB 2.0 b 2018-02-11
' Completely rewritten 2021-02-21.

People = 5
nutStart = 100
[
. /          ... and one for the Monkey
.
. / There are 5 people and 1 monkey on an island.
. / Yesterday the amount of coconuts they collect is ; nutStart
' track nut inventory with:
nutsNow = nutStart
. / Last night, each person goes to the pile, takes a fith
. / gives 1 coconut to the monkey and hides the remaining.
. /  (No coconuts are cut into parts in this problem.)
.
p = 0
monkey = 0
nutsNow = nutStart
[
+= p;1
Jmp p > People
fith = Int( nutsNow / People )
If fith >= 1
-= nutsNow; fith
+= monkey; 1
-= fith;1
Fi
+= fith;0
set fith; p; piles
. / For person ;p;/ their pile is ; fith; coconut(s).
]
. / So the remaining coconuts after last night is ;nutsNow
. /                        ... and the monkey has ;monkey
.
. / This morning, they give the monkey a coconut and divide
. / the remaining pile by number of people, what is the size
. / of everyone's pile?
.
. / Coconuts starting today is ; nutsNow
If nutsNow > 0
monkey = monkey + 1
nutsNow = nutsNow -1
Fi
fith = int( nutsNow / People )
. / So each person gets ; fith;/ more coconuts.
p = 0
[
+= p;1
Jmp p > People
Get curr; p; piles
total = curr + fith
. / Person ;p; had hidden ;curr; and gets ;fith; so has ; total
-= nutsNow; fith
]
. / The monkey has ; monkey;/ coconuts.
. / There remains ; nutsNow; nuts for this author.
.
-= NutStart; 10
If nutStart > 0
loc 34; 5
. ZZZ... press any to see day with 10 less coconuts to start
Zzz
Cls
El
Exit
Fi
]
. /            Good bye!
End


So SB1 rewrite almost caught up to SB, better with ElseIf equaivalent but 200 lines more, programMap took about 100 so there is no searching for the place to go next while running and using split for everything so there is no running down a string over and over looking for delimiter #x, so overall should be faster performance.

Would like string function system added for this version to have significant update.
Title: Re: Shorthand Basic
Post by: NOVARSEG on February 22, 2021, 11:46:26 pm
@bplus

Quote
a = a + 10
a += 10

what about a = 10 + a

a = 10 +  ??

The complier might think a variable is missing.
Title: Re: Shorthand Basic
Post by: bplus on February 22, 2021, 11:56:57 pm
If you are advising:

a += 10

looks better than

+= a;10

which is what I have working now in my Interpreter built from QB64.

I agree, I will put on my ToDo List to change.
Title: Re: Shorthand Basic
Post by: NOVARSEG on February 23, 2021, 12:25:33 am

a$ = a$ + z$ is not the same as  a$ = z$ + a$

but

a = a + b  is the same as a = b + a
Title: Re: Shorthand Basic
Post by: bplus on February 23, 2021, 12:47:41 am
Ah! Now I see what you're getting at, the strings are converted to number with VAL() the instant they are to be used as number.

String Concatenation will use & symbol.
Title: Re: Shorthand Basic
Post by: SMcNeill on February 23, 2021, 12:57:18 am
a$ = a$ + z$ is not the same as  a$ = z$ + a$

but

a = a + b  is the same as a = b + a

Wouldn’t this just be a case of:

a$ += z$

Verses:

a$ = z$ + a$
Title: Re: Shorthand Basic
Post by: NOVARSEG on February 23, 2021, 01:03:11 am
guess so but what is the short hand for

a$ = z$ + a$
Title: Re: Shorthand Basic
Post by: bplus on February 23, 2021, 01:46:19 am
a &= b$   > ab

and yes that <>

b &= a   > ba

That will go in for sure.
Title: Re: Shorthand Basic
Post by: SMcNeill on February 23, 2021, 02:29:37 am
guess so but what is the short hand for

a$ = z$ + a$

a$ =+ z$

VS

a$ += z$



I mean, why not?
Title: Re: Shorthand Basic
Post by: NOVARSEG on February 23, 2021, 04:06:21 am

Ok that'll work, but we got more than 640 K of memory now a days.
Title: Re: Shorthand Basic
Post by: bplus on February 23, 2021, 08:04:48 am
Quote
a$ =+ z$

VS

a$ += z$


I mean, why not?

@SMcNeill

Yeah, why not? What could possibly go wrong with that? ;-)) on my ToDo List

Originally += was a first argument in string command and those are fairly easy to code but I should be able to work in variable first commands I started for strings. But =+ makes more sense reading wise.



Quote
Ok that'll work, but we got more than 640 K of memory now a days.

@NOVARSEG
Yeah we have extended memory devices but our own memory has a deadline.


Today I was going to see if I can just run SB1 from Notepad++ like I can with JB. Then I could Edit/Run repeat without the drag drop in between, that's such a drag. I think I can just setup a tiny script to SB1.exe with a -f to call with active NP++ file and  Notepad++ will add the filename for SB1 to Run. That way I can put programs in different folders. Then I have tabbed files at my fingertips.
Title: Re: Shorthand Basic
Post by: bplus on February 23, 2021, 02:03:15 pm
Update: Well no luck with Notepad++ (npp)

Had fully pathed exe and filename loaded on console line (npp has exec extension that runs a console window in a split window at bottom of screen) click OK from the script to run, there is a little jiggle in npp but no sign of the running program except when I try to exit npp or try again to run something. Then I am informed console is still running and I can't even exit npp until I kill whatever invisible thing is going on in the console. Oh, should have checked Task Master see what exactly was going on... Todo

I try other combinations of commands and curse Windows inability to use chm files where the Manual for Notepad resides without some fix to Windows, result big headache. I also tried Run from npp and SB1 loads and runs the default internal program not much help there but when try to add filename to Run command > file not found error: something.    ToDo Nap, Done!

Also ToDo try _ClipBoard if there is nothing coming in on command line.

Title: Re: Shorthand Basic
Post by: SMcNeill on February 23, 2021, 02:29:14 pm
@SMcNeill

Yeah, why not? What could possibly go wrong with that? ;-)) on my ToDo List

Originally += was a first argument in string command and those are fairly easy to code but I should be able to work in variable first commands I started for strings. But =+ makes more sense reading wise.

Honestly, if I was to adopt such shortcuts, I’d keep the implementation very simple.

+= says whatever is in front of the + goes to the left on what’s on the right of the equal sign.

=+ says whatever is left of the equal sign goes to the far right of the plus sign.

a += b + c would be the equivalent of a = a + b + c
a =+ b + c would be the equivalent of a = b + c + a

If you wanted a = b + a + c, then you’d just have to type that out without any shorthand.

a = “butter”
b = “pea”
c = “nut”
a =+ b + c

a is now “peanutbutter”.  ;)
Title: Re: Shorthand Basic
Post by: bplus on February 23, 2021, 04:27:35 pm
Honestly, if I was to adopt such shortcuts, I’d keep the implementation very simple.

+= says whatever is in front of the + goes to the left on what’s on the right of the equal sign.

=+ says whatever is left of the equal sign goes to the far right of the plus sign.

a += b + c would be the equivalent of a = a + b + c
a =+ b + c would be the equivalent of a = b + c + a

If you wanted a = b + a + c, then you’d just have to type that out without any shorthand.

a = “butter”
b = “pea”
c = “nut”
a =+ b + c

a is now “peanutbutter”.  ;)

Dang! Not how I was figuring it, my line of interpretation is
a$ = itself + whatever else you want to tack onto it.
a$ would have to be = "pea"
b$ = "nut" '(of course)
c$ = "butter"
a$ =+ b$ + c$

Well we can toss this around for awhile, more important fish to fry.

Update:
If Command$ turns up empty or Command$ file not found I have added a check of clipboard contents, display 100 chars from it, if that looks like something runnable to user he may approve it else default test program is offered up.

You can now edit a program in npp or your favorite txt editor, select all and copy to Clip, Run SB1 and those contents will be offered up to run.

You can write an SB1 program in your bas program and store it in clipboard in code, Shell a call to SB1 and see the offer of running the program from your app's Shell (theoretically, haven't tested yet.) Thus you can create and run SB1 programs on the fly in your bas app.
Title: Re: Shorthand Basic
Post by: bplus on February 24, 2021, 07:08:56 pm
I think I have a String Functions System worked out, nothing particularly clever but now clear sight of getting SB1 code off the rack and ready for test driving. First test demo of some basically needed String Functions:
Code: [Select]
' Test ag First String Functions.txt b+ 2021-02-23& 24 reworked $ functionName arg1, arg2,...

. Ways to assign a var
. var = numeric expression (this is for a variable expected to be a number)
. var ""literal  (starts immediately after 2nd ") probably fastest and cleanest, remember no space!
.
. Introducing: First String Functions Case Insensitive !!! put all literals right next to comma !!!
. HEAD    Syntax: var $ Head source$, endCharPos#            > var = mid$(source, 1, endCharPos)
. TAIL    Syntax: var $ Tail source$, headEndPos#            > var = mid$(source$, headEndPos + 1)
. MID1    Syntax: var $ Mid1 source$, charPos#               > var = mid$(source$, charPos#, 1)
. MID$    Syntax: var $ Mid$ source$, startPos#, nChars#     > var = Mid$(source$, startPos#, nChars#)
. INSTR2  Syntax: var $ Instr2 source$,literalMatch          > var = TS$(Instr(source$, find$)
. INSTR3  Syntax: var $ Instr3 start#, source$,literalMatch  > var = TS$(Instr(start#,source$, match$))
. LEN     Syntax: var $ Len source$                          > var = TS$(Len(source$))
. SPC     Syntax: var $ Spc amountOfSpaces#                  > var = SPC(amountOfSpaces)
. &       Syntax: var $ & a1,a2,a3,...                       > var = a1 + a2 + a3 + ...
hw ""Hello World!
char_H ""H
char_W ""W
. Did it take? show how hw was set in code:
' dot in next line should prevent activating "", it does.
. hw ""Hello World!
' test the "" method of variable assignment
. And hw has the value: ;hw;/ and char_H: ;char_H;/ and char_W: ;char_W
hwLen $ len hw
. And hw has the len of: ;hwLen
.
. Here we try String Functions involving MID$: Head, Tail, Mid$, Mid1
hello $ Head hw, 6
world $ Tail hw, 6
low $ Mid$ hw, 4, 4
first $ mid1 hw,1
' actually if the literal is numeric and positive you can have a space after comma.
seventh $ mid1 hw, 7
. /         Head 6 chars = *; hello ;*
. /      Tail from 6 + 1 = *; world ;*
. / Mid$ from 4, 4 chars = *; low ;*
. / What's at the first (first $ mid1 hw,1)and seventh positions? answer: ;first;/ and ;seventh
.
find_lh $ instr2 hw,h
find_UH $ instr2 hw, char_H
find_W $ instr2 hw, char_W
. / Instr2 has 2 arguments: Search string and the item to match.
. / Instr3 has 3 arguments: startPlaceOfSearch, the StringToSearch, theItemToFind.
.   Instr2 Tests:
. Any h's in ;hw;? Answer: ;find_lh
. Any H's in ;hw;? Answer: ;find_UH
. Any W's in ;hw;? Answer: ;find_W
. The original variable hw was derived from 1st letters at (find H) ;find_uH; and at (find W);find_W;.
. /     What the L? find all the places it's located, using Instr2, Instr3
.   Instr3 Test:
place $ Instr2 hw,l
[
If place
+= cnt;1
.  #;cnt; l resides at ;place;# in ;hw;.
+= place;1
place $ Instr3 place, hw,l
El
. /      That's all the L, we found.
Exit
Fi
]
. /     Testing $ spc n  for spaces and $ & arg1,arg2,arg3... concatenate with &
[
+= n;1
space $ spc n
bind $ & hw, space
; bind
chars = chars + hwLen + n
Jmp chars + hwlen + n + 1 > 128
]
.
. Goodnight!
zzz


My strategy is getting strings with all kinds of troublesome potential parsing characters on the loose, contained as values under variable names ASAP! Then! we can use normal parsing characters eg, spaces and commas, even ()'s (but not yet, that's for SB2 with a super evaluator).

PS There was an error in the code output seen in screen shot that I fixed in code. Today's quiz, can you find it?


Title: Re: Shorthand Basic
Post by: bplus on February 26, 2021, 01:52:51 pm
Another overhaul getting rid of Silly $ all over the place making both Str Functions and var assignments easier yet

myStr$ = "assign this value"

in SB1 now
mystr "assign this value

mySect$ = mid$(myStr$, 13)

mySect tail 12 
Edit: not 13, tail starts +1 from Head end, probably will replace tail with tail$ = rightOf$(source$, OfThisStr$)
mySect$ Tail this (which has a space on the end *this *)

A little story I was going to post an message about overhaul this morning and ran into bug with simple demo, now I have made it easier still to assign a variable, now a demo: attached

Ha! I wonder if the only person who might appreciate all these efforts is WhatsHisNameNow? that I knew from 3 forums now gone. But then there is Aurel and Ed and maybe Steve :)

Well back to the grindstone of testing...

BTW this is why I don't post code yet, I am overhauling everything when I see the slightest improvement in ease of use, one little detail "get rid of the silly looking $'s (that aren't that easy to type in first place)" and massive over haul. Then I have to check that the change doesn't mess up tests already working which require rewriting the effected sections...  it is a bit of a grind.
Title: Re: Shorthand Basic
Post by: bplus on February 26, 2021, 03:03:48 pm
Speaking of working out details, I've been going round and round and round about ? shorthand for Input.

I know our favorite Basic uses ? for short hand for PRINT in the IDE and I don't like to break with tradition without very good reason. IMHO ? is perfect for Input, you are asking for something and waiting for an answer.

I have been going round and round trying to deal with nothing, the user just presses enter. If run nothing through my numeric Eval it pitches a fit about not having a second operand for a binary operation, so the quick fix was make nothing 0 works fine for the numeric eval but! now I want to have all kinds of dealings with strings and Input has been setup to receive a String by varType$ because in coding when you get down to it, everything is string until you make something more of it by giving certain strings numeric significance, rising above nothing in value...
(I think that was "Run on" sentence, sorry. )

Btw switched over to Line Input which only takes 1 string but here come commas and potentially longer things. Yeah that's the right Input to use for SB1 and of course the thing with just enter is still there and setting it to 0 is terrible fix because maybe "" is the right answer so, this is 4 AM in morning last night...

So now I need a function empty to say in Boolean that the answer was no string return -1
isEmpty empty myAnswerFromInput?
If isEmpty
   GoTo label:
  (or) Exit
  (or) End
  (just don't do anything numeric with it to piss off Eval!)
Fi

or Jmp isEmpty

So now the coder of the Interpreter can decide WTH to do with "just enter" as it should be. :)
Title: Re: Shorthand Basic
Post by: SMcNeill on February 26, 2021, 06:46:37 pm
Wouldn’t IsEmpty simply be Nul?
Title: Re: Shorthand Basic
Post by: bplus on February 26, 2021, 10:13:18 pm
It be "" and that is trouble for numeric expression evaluator when trying to do Binary Ops without a 2nd Operand.

SB1 doesn't have String Eval so it handles strings in clunky way better than the nothing that SB had (except for Array-Strings) :)

String Eval is for SB2 when I go study Ed's code. At the moment all variables are string until they are needed to be numbers then they are and it's up to coder to use them carefully :)

This is not for great apps but for ad hoc help on the fly at Run Time.
Title: Re: Shorthand Basic
Post by: bplus on February 27, 2021, 11:04:44 am
Yeah I need a more general string compare function then it would just compare one string with another not just something that compares to "".


Title: Re: Shorthand Basic
Post by: bplus on February 28, 2021, 07:34:37 am
Well today is the day I get to more than double the string functions that SB1 will host. I am so excited, I am up 5 hours early!

I finally killed a bug way back from original parsing of program line that has been dogging me since first written in ParseProgramStr the same routine that maps the program. It came from a misremembering of what I thought a Filter function, written for the Sub, was doing. I didn't even know the bug existed and had been working around problems by reparsing program lines for numeric expression and string function processing. Again with the redundant processing of what should have been processed right the first time. I first became aware of it when I was trying to allow crazy spacing between first cmd/var of line and the next cmd/var. Along with case insensitive for commands, variables and labels I wanted as much space insensitive as possible as all literals will be picky enough to get right without dbl quote containment. Plus I learned Notpad++ likes to throw invisible tab chars at the end of lines. Such are invisible unless you highlight text for selection, then you see extra fat endings on the lines. The Filter was taking out tabs but it was also doing a trim to save time. Trouble was it was trimming every space out of the program line! ;-)) Yikes! I never noticed because I did a LeftOf$ the first space first before the filter. Then on case by case basis did more leftOf$ next spaces or ... anyway the fix was to filter out the whole program line of chars <32 and then parse by leftof$ stuff or splits on case by case basis.

Anyway the present list of string functions is:
Len, SPC, Mid$, Mid1, Head (revised yesterday), Tail(rev), Instr2, Instr3, $= for string comparison Boolean return
Head now looks for first string in source$ and returns all before that string or whole string if match not found
Tail takes the back end or nothing if match$ not found.
Head, Tail is like Mid$ with a string instead of number positions.
Empty was dumped for a line like this:
 isEmpty $= a1, 
(leaving no 2nd argument, Eval pissed off would Err$ = " Error: Binary Op missing operand."  but not Str Functions ;-))

And proposed additions (Looking at Ed's list for quick start):
Date
Time
Ucase
Lcase
Chr
Asc
Ltrim
Rtrim

String - not to be, Unicorned
Val - not to be, Unicorned (I think) might need in SB2 with Super Evaluator

B+:
Trim
Copy  + is replacement for String which only does 1 char, let's offer to copy more than 1 char, imagine an Astring copied that's like copying arrays. Astrings are array-like but you can insert items, delete items, append items without too much more coding like with DIM or REDIM _Preserve.
A$Sort + Ascending String sort
D$Sort
A#Sort
D#Sort
Split - with Astrings instead of arrays
Join - with Astrings instead of arrays

So am I missing anything obvious?

PS Yes, I already have concatenation:
CASE "&" '                                            Syntax: var & a1,a2,a3...   
Title: Re: Shorthand Basic
Post by: bplus on February 28, 2021, 11:10:26 am
Well it's coded, here is test code for Sorts:
Code: QB64: [Select]
  1. _TITLE "Sorts test" ' b+ 2021-02-28
  2. REDIM SHARED sa$(1 TO 20), na#(1 TO 20)
  3.  
  4. FOR i = 1 TO 20 'test arrays
  5.     sa$(i) = _TRIM$(STR$(INT(RND * 100)))
  6.     na#(i) = RND * 100
  7. DNQSort 1, UBOUND(na#)
  8. FOR i = 1 TO 20
  9.     PRINT na#(i)
  10.  
  11. SUB ASQSort (Start, Finish) 'sa$ needs to be   DIM SHARED !!!!     array
  12.     DIM i AS LONG, j AS LONG, x$
  13.     i = Start: j = Finish: x$ = sa$(INT((i + j) / 2))
  14.     WHILE i <= j
  15.         WHILE sa$(i) < x$: i = i + 1: WEND
  16.         WHILE sa$(j) > x$: j = j - 1: WEND
  17.         IF i <= j THEN
  18.             SWAP sa$(i), sa$(j)
  19.             i = i + 1: j = j - 1
  20.         END IF
  21.     WEND
  22.     IF j > Start THEN ASQSort Start, j
  23.     IF i < Finish THEN ASQSort i, Finish
  24. SUB DSQSort (Start, Finish) 'sa$ needs to be   DIM SHARED !!!!     array
  25.     DIM i AS LONG, j AS LONG, x$
  26.     i = Start: j = Finish: x$ = sa$(INT((i + j) / 2))
  27.     WHILE i <= j
  28.         WHILE sa$(i) > x$: i = i + 1: WEND
  29.         WHILE sa$(j) < x$: j = j - 1: WEND
  30.         IF i <= j THEN
  31.             SWAP sa$(i), sa$(j)
  32.             i = i + 1: j = j - 1
  33.         END IF
  34.     WEND
  35.     IF j > Start THEN DSQSort Start, j
  36.     IF i < Finish THEN DSQSort i, Finish
  37. SUB ANQSort (Start, Finish) 'na#  needs to be   DIM SHARED !!!!     array
  38.     DIM i AS LONG, j AS LONG, x#
  39.     i = Start: j = Finish: x# = na#(INT((i + j) / 2))
  40.     WHILE i <= j
  41.         WHILE na#(i) < x#: i = i + 1: WEND
  42.         WHILE na#(j) > x#: j = j - 1: WEND
  43.         IF i <= j THEN
  44.             SWAP na#(i), na#(j)
  45.             i = i + 1: j = j - 1
  46.         END IF
  47.     WEND
  48.     IF j > Start THEN ANQSort Start, j
  49.     IF i < Finish THEN ANQSort i, Finish
  50. SUB DNQSort (Start, Finish) 'na#$ needs to be   DIM SHARED !!!!     array
  51.     DIM i AS LONG, j AS LONG, x#
  52.     i = Start: j = Finish: x# = na#(INT((i + j) / 2))
  53.     WHILE i <= j
  54.         WHILE na#(i) > x#: i = i + 1: WEND
  55.         WHILE na#(j) < x#: j = j - 1: WEND
  56.         IF i <= j THEN
  57.             SWAP na#(i), na#(j)
  58.             i = i + 1: j = j - 1
  59.         END IF
  60.     WEND
  61.     IF j > Start THEN DNQSort Start, j
  62.     IF i < Finish THEN DNQSort i, Finish
  63.  

Here is the sort interface with SB1:
Code: QB64: [Select]
  1. FUNCTION SortWrapper$ (Astring$, SortType1to4 AS LONG) '------------------------------- Sorts Stuff
  2.     DIM i AS LONG
  3.     ' type 1 string ascending, 2 string descending, 3 numeric ascending, 4 numeric descending
  4.     'the arrays SA$ and NA# have been dim shared (1 to 1) need to unzip astring$
  5.     Split Astring$, CHR$(1), SA$(), 0
  6. ReDim NA#(1 To UBound(sa$))  ' <<<<<<<<< Edit yes missed this originally
  7.     IF SortType1to4 > 2 THEN 'convert into number
  8.         FOR i = LBOUND(sa$) TO UBOUND(sa$)
  9.             NA#(i) = VAL(SA$(i))
  10.         NEXT
  11.     END IF
  12.     SELECT CASE SortType1to4
  13.         CASE 1: ASQSort LBOUND(sa$), UBOUND(sa$)
  14.         CASE 2: DSQSort LBOUND(sa$), UBOUND(sa$)
  15.         CASE 3: ANQSort LBOUND(na#), UBOUND(na#)
  16.         CASE 4: DNQSort LBOUND(na#), UBOUND(na#)  '< edit case 4 was same as 3, now fixed
  17.     END SELECT
  18.     'now pack it backup in an Astring$
  19.     IF SortType1to4 > 2 THEN 'convert back into string
  20.         FOR i = LBOUND(na#) TO UBOUND(na#)
  21.             SA$(i) = _TRIM$(STR$(NA#(i)))
  22.         NEXT
  23.     END IF
  24.     SortWrapper$ = Join$(SA$(), CHR$(1))
  25.  

Next up see what wacky thing I did not anticipate '-))
MileStone: LOC just exceeded 1K, the 4 different sorts kind of expensive and redundant but I think faster than a one size fits all Variable Types and Sort Types.

Already I see I will need to REDIM NA# to SA$ bounds, after lunch.

EDIT: code above needed two fixes as pointed at with Commented Edit lines.
Title: Re: Shorthand Basic
Post by: bplus on February 28, 2021, 09:49:13 pm
Yes the Split function and the Sort Functions are working, a couple of fixes to Sort shown above in Edits.

Sort Test Code:
Code: [Select]
[
cnt = cnt + 1
jmp cnt > 20
rLen = int(rnd * 10) + 2
b "
cnt2 = 0
[
cnt2 = cnt2 + 1
jmp cnt2 > rLen
rChar = int(rnd * 26) + 65
rStr chr rChar
b & b, rstr
]
set AstringS, cnt, b
r = int(rnd * 100 * 100)
set AstringN, cnt, r
loc cnt, 1
; b
row = cnt + 21
loc row, 1
; r
]
saSort a$Sort AstringS
sdSort d$Sort AstringS
naSort a#sort AstringN
ndSort d#Sort AstringN
cnt = 0
[
+= cnt,1
jmp cnt > 20
get sa, saSort, cnt
get sd, sdSort, cnt
get na, naSort, cnt
get nd, ndSort, cnt
at 20, cnt
; sa
at 40, cnt
; sd
row = cnt + 21
at 20, row
; na
at 40, row
; nd
]
Zzz


Those were the String Functions I was most concerned working OK. Next up is to test the remainder of the functions using v 1.5 now. :)
Title: Re: Shorthand Basic
Post by: Aurel on March 01, 2021, 03:42:38 am
WOW Mark
You have more  string functions than I in m(A)...well ..fine !!!
heh you say LOC over 1K...dude use more spaghetti code to minimize amount of lines..ok?
Title: Re: Shorthand Basic
Post by: bplus on March 01, 2021, 01:40:36 pm
Hey Aurel,

What's micro(A) in LOC?
Do you have ElseIf equivalent? Do you map your program out before execution of lines?
Both new for me in SB1.


Today's update, just have Join to work out, there may be several different ones. Then will post code for you all to test drive.

BTW I notice all the functions in my Numeric Eval and Ed Davis more versatile Eval have 0 (Rnd) or 1 Arguments, what do we do for 2 or more? ;-))
Title: Re: Shorthand Basic
Post by: Ed Davis on March 01, 2021, 03:08:09 pm
BTW I notice all the functions in my Numeric Eval and Ed Davis more versatile Eval have 0 (Rnd) or 1 Arguments, what do we do for 2 or more? ;-))

Something like this:

Code: QB64: [Select]
  1. sub get2values(userstr as string, sym as string, n1 as double, n2 as double)
  2.     nextsym userstr, sym    ' skip fun
  3.     expect "(", userstr, sym
  4.     n1 = numeric_expr(0, userstr, sym)
  5.     expect ",", userstr, sym
  6.     n2 = numeric_expr(0, userstr, sym)
  7.     expect ")", userstr, sym
  8.  

And then in primary():
Code: QB64: [Select]
  1.             case "atan2": call get2values(userstr, sym, n, n2): primary = _atan2(n, n2)
  2.  
Title: Re: Shorthand Basic
Post by: bplus on March 01, 2021, 11:51:31 pm
OK finally got Join thing worked out. Join just takes the psuedo array Split made for array substitute to use Set and Get so we have array like storage and access functions. Join splits by same delimiter Split used to Join to make an Astring, then rejoins it with User spec'd delimiter like space, comma or NL$ = Chr$(13) + Chr$(10) maybe to file the string in lines.

Test and demo code:
Code: [Select]
' Test ak Remaining SFunctions 2-28.txt
' along with testing regular "easy to code" SFunctions get more practice with
' Set and Get our array substitute.

' oh try another way to assign with &
day date
clock time
xpix = xmax - 200
tag xpix, 10, clock
tag xpix, 30, day

sp1 chr 32
sp7 ncopy 7, sp1
test & sp7, B is Fat Left and Right!, sp7
. test string: ";test;"
bltrim ltrim test
brtrim rtrim test
btrim trim test
bshout ucase test
bwhisper lcase test
.
. ltrim B ";bltrim;"
.
. rtrim B ";brtrim;"
.
. B is looking trim ";btrim;"
.
. SHOUTING: ";bshout;"
.
. whisper: ";bwhisper;"
.
' Building an Astring with nCopy of embedded delimiter (space) to split it, brilliant!
fatx10 ncopy 10, fat!
'trim the fat
fatx10 trim fatx10
.
. fatx10
x10 split fatx10, sp1
. x10 split fatx10, sp1 is;
cnt = 1
hyph chr 45
[
x get x10, cnt
. /   ; cnt;.;/ ; x
'OK for fun lets mod with concatenation (binding I am calling it)
x & cnt,hyph,x
'test modified x debug
'. x
' and back into the Astring changed
' set is like a(i) = change ( I was doing change first )
set x10, cnt, x
'debug
'. x10
+= cnt, 1
jmp cnt > 10
]
'another way to assign a string
& c,+,
. & c,+, is ;c

'checks on our new join delimiter
c1 asc c
. c1 asc c is ;c1
c2 chr c1
. c2 chr c1 is ;c2

'' this needs fixed I am too tired to think straight
'' I think it was x10 that needed a trim, YES!
'' and this kind of join is really a rejoin
'' that converts an Astring into another type of Astring
j join x10,c
. j join x10, c is ; j


Oh I changed the ps (_PrintString) clone and renamed it Tag Syntax: Tag Xpix, Ypix, Label$

Also more news on the ? Input front, I now have 2 cmds n? and ?n because who the hell's going to remember which side the n is supposed to go ? And n? or ?n is to inform the Input code that we want a 0 instead of an empty string if user just presses Enter key. And that reminds me of another change, I am preloading the variables Table, names and values with MT for empty string, Xmax for screen width, Ymax for screen height, Rmax for max Row number and Cmax for At or Loc commands, At is Locate with Col, Row reversed to match Basic graphics where X comes before Y just like in the alphabet. :) Have it both ways dang it!

So Steve there is our answer to += or =+ we shall offer both and not challenge 60+ year minds with pickiness of left or right placement. ;-))

And screen shot:
 


And after taking nap today, I got an idea for surprise package to include with SB1, I am eager about.

Title: Re: Shorthand Basic
Post by: Aurel on March 02, 2021, 01:07:06 am
What's micro(A) in LOC?
currently cca 1400

Do you have ElseIf equivalent?
no ..i have only ELSE

Do you map your program out before execution of lines?
well yes i transform code into array of tokens and array of token types.

Mark i will try your...SB1
Title: Re: Shorthand Basic
Post by: bplus on March 02, 2021, 12:13:50 pm
Code: QB64: [Select]
  1. Mark i will try your...SB1
  2.  

Oh thanks Aurel, that's nice. I will be sure that it requires Stable v 1.5 because you should like that too! ;-))
Title: Re: Shorthand Basic
Post by: bplus on March 02, 2021, 12:37:50 pm
I had a revelation this morning, just treat the inside of [ contents ] 

[Bplus off on a tangent:
(instead of () to maintain the a goal of SB to avoid top row keys that need shift, maybe I should call this one handed Basic, or Basic with one arm tied behind my back, dang this could actually be a Basic for the one handed not a bad idea ) More ToDO then to be consistent with that idea, there goes any $ what so ever! no more!!!! crap also ha, ha.]

as a program line to do first! How simple is that! well we'll see.

Connecting to Ed Davis, Numeric/String Eval functions, here because he is helping me think about how to handle SFunctions like I have already with numeric Evaluations. I started to post there but here is more appropriate, I think, they are obviously intertwined subjects in my mind.
https://www.qb64.org/forum/index.php?topic=3697.msg130605#msg130605
Title: Re: Shorthand Basic
Post by: bplus on March 02, 2021, 12:55:24 pm
Yeah I like that, rename this project oh basic, short for one handed basic. Always like o it's looks like a ball or a..., well.

oh, qm  no more ? too, now qm, no # sign now n, no $ sign now v or s? v for variable as all is string anyway, exclamation mark, em...

bplus you are some kind of nut, em

Yeah so who is doing basic with one hand tied behind their back, qm  bplus. Oh wait + is up there too, oh no em.
bt then qm ok so + is shifty too. ewh what about all those symbols for math? Yikes! =,- still ok. t for + can it be done qm

x for *

one handed or oh hell em

maybe 2 for 1 like qm, em, cm.. + then is tw as + is The Way to be. The Tao would be proud if it had feelings.

next up ^

or &

qm


Title: Re: Shorthand Basic
Post by: bplus on March 02, 2021, 01:45:27 pm
& is bind

Stx would say ^ is hat but I like "up" for power symbol.

Any one see this?






Title: Re: Shorthand Basic
Post by: Aurel on March 03, 2021, 03:59:40 am
Yeah AMSTRAD...dogy games ...ha ha !!!

BpAkaMark...you should call it SB (pssst...script...pssstBasic ) ..he he
so you say that i must use new 1.5 hmm..i can ask why but better not ..L:O:L (Y)

by the way where is complete code ?
Title: Re: Shorthand Basic
Post by: bplus on March 03, 2021, 09:34:15 am
Quote
by the way where is complete code ?

Here with some untested, undocumented graphics commands:(attached)

OK I tested download and seems to be working on my machine OK.

All the Tests included in Folder are working on my machine.

New untested graphics:
Ink command for setting drawing or printing color
Ink 3 arg _RGB or 4 arg _RGB
eg Ink 255, 0, 0  'for red
eg Ink 255, 255, 0, 128  'for yellow alpha layer

Paper command for back color, 3 arg only
for white:
Paper 255, 255, 255

This was late last night I forgot if Paper does a Cls or just sets Shared as _unsigned long Paper, Ink

So for pset use:
Pix x, y

Line:
Line x1, y1, x2, y2

Box:
Box x1, y1, Width, Height

FBox (filled box)
FBox x1, y1, w, h

Circle:
Circ x, y, r

Filled Circle:
Fcirc x, y, r

Filled Triangle (you can make your own triangles with 3 lines)
Ftri x1, y1, x2, y2, x3, y3


Man was I in crazy state yesterday, low blood sugar? We were testing mom's heart monitor for over an hour trying to get the thing to send a test reading. Get to try again later this week with more tech guys on the other end of phone. Every minute of test mom asks how long is this going to take why are we doing this, meanwhile the is beeping like a loud annoying timer gone off, eventually the dog joins in with barking Yikes! what a symphony.

So my mind got a bit scattered for posts above.

Oh crap, I do want transparent paper available too, for printing with clear background color.

Yeah so I was testing random pix with random color and got such an unrandom result I threw in the towel for the day. This was after a session of updating Help for SB1 in which the words would not line up for me in head and not working well with Notepad++ on extra wide because I don't know what width others would be reading the text.

WARNING: the only places where numeric expressions are evaluated are:
Main:
var = expression
+ Sumvar, a2, a3, a4...  and Sumvar = total of Args after first
- MinusVar, a2, a3, a4    MinusVar = a2 - a3 - a4...
* Prodvar, a

+= var, change < literal number only,  change would be easy to run through eval

Yeah run numeric args through eval for Loc, At, Tag,... why am I not doing this?
Title: Re: Shorthand Basic
Post by: bplus on March 03, 2021, 10:45:24 am
Quote
so you say that i must use new 1.5 hmm..i can ask why but better not ..L:O:L (Y)

'sOK

Which would you rather do:

b4 v1.5
Code: QB64: [Select]
  1. DIM x AS LONG, y AS LONG, z AS LONG, xa AS LONG, xb AS LONG, xc AS LONG, xd AS LONG, xe AS LONG

'aftr v 1.5
Code: QB64: [Select]
  1. DIM AS LONG x, y, z, xa, xb, xc, xd, xe
Title: Re: Shorthand Basic
Post by: Aurel on March 03, 2021, 02:06:27 pm
Dang...BP
u use same as me in ruben interpreter...!""#%$#$%$&
he he

So for pset use:
Pix x, y


ok Mark i will...

I am using old 1.3 portable version 32bit...

WOW you use lot of SUBS and FUNCTIONS...
 
Title: Re: Shorthand Basic
Post by: Aurel on March 03, 2021, 02:40:58 pm
Ok i just changed 21 23 line to work with older version and voila it work
foe some examples i am not sure that work properly ...but ok!
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Shorthand Basic
Post by: bplus on March 03, 2021, 04:02:39 pm
Yep! that's probably all the changes needed for v1.4 compatible at least, probably v1.3 too.
Title: Re: Shorthand Basic
Post by: bplus on March 04, 2021, 12:53:34 pm
Update confirmed that IF and EI (ElseIf) do make Boolean Evaluations I don't have to set the TF test into a different var.

ToDo get the rest of the numeric arguments to work that way or confirm they refuse to play nice amongst non numeric arguments and comma splitters and variable substitutions... that would be really helpful for Loc, At, Tag and All the graphics commands. Then I think I can setup a similar thing for String Evaluation but wait and see how numeric evals fit in other commands.

Re:Random points on a SB1 screen
Holy moley the thing Luke showed us in discussion of getting random points struck in full force trying to do random pixels and even random boxes on SB1 screens way way way too regular diagonal patterns, Yikes!

I was so desperate to get rid of that, I set up a PtDeck in SB1 with a shuffle Sub (I tried this first in an SB1 program but it ran way too slow to be of any practical use, and I got a good taste of just how slow things run in the Interpreter!). So the PtDeck puts 1024 * 672 numbers into an array, 1 for each point on screen. then I shuffle them and have a shared index to pass through the deck so each point is visited once before we repeat the same point after reshuffling the deck. So, much nicer randomness, still some streaks but that is from regularity of coloring, I hope. And if I want more true randomness I think all I have to do is shuffle the deck of points before each draw so theoretically you could draw the same point twice in row or 5 times or 1,000,000 but don't bet on it.

So now I have everything messing up very nicely, thank you very much!

New (case insensitive) command for SB1 is Syntax: RndPt varContainer
example of use:
RndPt xy
RndX = xy % xmax
RndY = int( xy / ymax )

Qb64 does this stuff instantly compared to SB1 that is still working to fill a screen:
Code: QB64: [Select]
  1. _Title "Random Screen Test" 'b+ 2021-03-04
  2. Screen _NewImage(1024, 672, 32)
  3. _Delay .25
  4. ReDim As Long deck(688127), i, cnt, deckidx, pt, x, y
  5. For i = 0 To 688127
  6.     deck(i) = i
  7. GoSub shuffle
  8.     cnt = cnt + 1
  9.     deckidx = deckidx + 1
  10.     If deckidx >= 688128 Then
  11.         GoSub shuffle
  12.         deckidx = 0
  13.         cnt = 0
  14.     End If
  15.     pt = deck(deckidx)
  16.     x = pt Mod 1024
  17.     y = Int(pt / 672)
  18.     If cnt Mod 3 = 0 Then
  19.         c = _RGB32(0, 190, 0, Int(Rnd * 255))
  20.     ElseIf cnt Mod 3 = 1 Then
  21.         c = _RGB32(255, 255, 255, Int(Rnd * 255))
  22.     Else
  23.         c = _RGB32(0, 0, 255, Int(Rnd * 255))
  24.     End If
  25.     Circle (x, y), 1, c
  26. shuffle:
  27. For i = 688127 To 1 Step -1
  28.     Swap deck(i), deck(Int(Rnd * (i + 1)))
  29.  

Another fine mess!
(see attachment)

SB1 equivalent:
Code: QB64: [Select]
  1. ' Test al First Graphics Test.txt b+ 2021-03-03
  2. ' OK dang it! I made some special arrangements in SB1 to make a deck of pts
  3. ' to shuffle those points and to access the next point to be dealt with rndPt command  
  4. paper 0, 0, 0
  5. ratio = ymax / xmax
  6. top = 688217
  7. [
  8.         += cnt, 1
  9.  
  10.         'ink 0, 0, 0, 1
  11.         'fbox 0, 0, xmax, ymax
  12.         'jmp cnt > 300
  13.        
  14.         rndpt rp
  15.        
  16.         x1 = rp % xmax
  17.         y1 = int( rp / ymax )
  18.        
  19.         'x2 = ( rnd * xmax + c ) % xmax
  20.         'y2 = ( rnd * ymax + c ) % xmax
  21.         'w = rnd * 100
  22.         'h = rnd * 67
  23.  
  24.         'every 3rd color is green white or blue with rnd? alpha
  25.         if (( cnt %3)= 0)
  26.                 r = 0
  27.                 g = 190
  28.                 b = 0
  29.         ei (( cnt %3)= 1)
  30.                 r = 255
  31.                 g = 255
  32.                 b = 255
  33.         el
  34.                 r = 0
  35.                 g = 0
  36.                 b = 255
  37.         fi     
  38.         a = int(rnd * 255)
  39.         ink r, g, b, a
  40.         'box x1, y1, w, h
  41.         'pix x1, y1
  42.         fcirc x1, y1, 1
  43.         'fbox x1, y1, w, h
  44. ]
  45.  
  46.  

SB1 Labors for same mess:
(compare 2 attched screen shots)

Title: Re: Shorthand Basic
Post by: Aurel on March 05, 2021, 07:45:34 am
Interesting
but why you insist on rnd * 255...
it is simplier to made rand(255) i have that made using api
infact i have RND(1) - from 0 to 1  ,and RAND(max) from 0 to max
just thinking  aloud.....

Also Mark may i ask you why you have so many ReDim in your code..??
It is strange to me ...by the way do you have array implemented ?
Title: Re: Shorthand Basic
Post by: bplus on March 05, 2021, 11:31:02 am
Quote
but why you insist on rnd * 255...
it is simplier to made rand(255) i have that made using api
infact i have RND(1) - from 0 to 1  ,and RAND(max) from 0 to max
just thinking  aloud.....

Yeah maybe Rnd() would be better, now when code sees Rnd it substitutes a RND value as if it were another var to substitute in a value or sees pi and puts in 3.1415.. or sees e puts in 2.7182... Maybe same difference?

All the Redim's is because using OPTION  _EXPLICIT and never have to use DIM when REDIM covers everything.

Arrays are single dimension use SET to store a value
SET Astring index isValue 
same as A(i) = isValue

and then GET a value from an Astring:
myVar Get Astring index
compare to:
myVar = A(i)

The Prime Sieve Test  used Get and Set for storing First Factors (no I think it was last factors to avoid check if array had a value stored already) you could continue Prime Sieve by factoring any given number up to 1000.

If you want 2D of more use calculated indexes to convert to single number then Get or Set that index.
Just have to track row width for the Astring.

say screen is 1024 x 700
Then index of (x, y) = (5, 327)  is 5 + 327 * 1024 = 334853








Title: Re: Shorthand Basic
Post by: Aurel on March 05, 2021, 02:52:32 pm

Quote
All the Redim's is because using OPTION  _EXPLICIT and never have to use DIM when REDIM covers everything.

oh ..i don't know that ..
ok so you have array ..that is nice ....shame on me I still don't have it in m(A)
thanks for reply...
Title: Re: Shorthand Basic
Post by: bplus on March 05, 2021, 03:31:01 pm
oh ..i don't know that ..
ok so you have array ..that is nice ....shame on me I still don't have it in m(A)
thanks for reply...
With these tools you can turn strings into arrays:
https://www.qb64.org/forum/index.php?topic=1511.msg129084#msg129084

And NOT have to worry about DIM keyword or "Subscript out of bounds errors"

On the same principle as above I am using variable length strings
https://www.qb64.org/forum/index.php?topic=3681.0
Title: Re: Shorthand Basic
Post by: Aurel on March 05, 2021, 05:53:22 pm
Quote
Subscript out of bounds errors

in a compiler i am using there is no such a type of errors
also i don't use any kind of UDT in microA

but thanks ..something similar u was use in ruben

well i have in plan to use different container for array...assoc
Title: Re: Shorthand Basic
Post by: bplus on March 15, 2021, 03:10:47 pm
As per @STxAxTIC great suggestion, I should explain that SB1 is abandoned due to the limitation Eval was imposing (in my mind) of only being able to handle numeric expressions.

I had a great breakthrough March 7, 2021 (and in memory of my Father's B-Day!) with the Fval$ evaluator that does all strings and that includes numbers! It's simple, it's versatile, it's easy and no recursive calls to evaluate a line of code. It does put a greater burden on the coder to write a numeric expression but it's a cool new challenge.

I have restarted my little interpreter with Fval$ as my base evaluator and we go from Shorthand to One Handed!
You should be able to write all your code for interpreter with one hand, no capitals required nor upper row shifted characters. One handed? What should we call such a thing? One handed, One Handed... OH!  LOL

Anyway this project continues here:
https://www.qb64.org/forum/index.php?topic=3723.0
Transformed! It no longer looks like Basic specially on the Right side of an variable = expression.