Author Topic: Shorthand Basic  (Read 18092 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #15 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

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #16 on: February 10, 2021, 03:47:55 pm »
Mark 
do you have complete code of this program?
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #17 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.
« Last Edit: February 10, 2021, 05:23:10 pm by bplus »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Shorthand Basic
« Reply #18 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Shorthand Basic
« Reply #19 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.
You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Shorthand Basic
« Reply #20 on: February 10, 2021, 06:37:19 pm »
Something like {formula 3+4*12=}, and then it prints “3 + 4 * 12 = 51”.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Shorthand Basic
« Reply #21 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #22 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.
« Last Edit: February 11, 2021, 08:04:00 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #23 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 :)


« Last Edit: February 13, 2021, 12:12:01 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #24 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #25 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...
SB1 test 2.PNG
* SB1 test 2.PNG (Filesize: 23.76 KB, Dimensions: 597x700, Views: 174)
SB1 Program Map.PNG
* SB1 Program Map.PNG (Filesize: 15.25 KB, Dimensions: 901x411, Views: 196)
SB1 Eval chomping down the value for remaining.PNG
* SB1 Eval chomping down the value for remaining.PNG (Filesize: 17.99 KB, Dimensions: 732x687, Views: 197)
« Last Edit: February 14, 2021, 10:09:52 am by bplus »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Shorthand Basic
« Reply #26 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.)
« Last Edit: February 14, 2021, 01:03:24 pm by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #27 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





« Last Edit: February 14, 2021, 11:53:02 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #28 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.
« Last Edit: February 14, 2021, 12:45:51 pm by bplus »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Shorthand Basic
« Reply #29 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.

You're not done when it works, you're done when it's right.