Author Topic: Shorthand Basic  (Read 9219 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Shorthand Basic
« Reply #45 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$
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Shorthand Basic
« Reply #46 on: February 23, 2021, 01:03:11 am »
guess so but what is the short hand for

a$ = z$ + a$

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #47 on: February 23, 2021, 01:46:19 am »
a &= b$   > ab

and yes that <>

b &= a   > ba

That will go in for sure.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Shorthand Basic
« Reply #48 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?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Shorthand Basic
« Reply #49 on: February 23, 2021, 04:06:21 am »

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

Offline bplus

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

Offline bplus

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


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Shorthand Basic
« Reply #52 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”.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

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

Offline bplus

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


SB1 Test ag First String Functions.PNG
* SB1 Test ag First String Functions.PNG (Filesize: 45.19 KB, Dimensions: 1029x699, Views: 133)
« Last Edit: February 25, 2021, 12:11:09 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #55 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.
SB1 mod test of new var assignment and new string function format.PNG
* SB1 mod test of new var assignment and new string function format.PNG (Filesize: 35 KB, Dimensions: 1039x332, Views: 136)
« Last Edit: February 26, 2021, 02:36:37 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shorthand Basic
« Reply #56 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. :)
« Last Edit: February 26, 2021, 03:07:30 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Shorthand Basic
« Reply #57 on: February 26, 2021, 06:46:37 pm »
Wouldn’t IsEmpty simply be Nul?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

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

Offline bplus

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