Author Topic: Shorthand Basic  (Read 9513 times)

0 Members and 1 Guest are viewing this topic.

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #75 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...
AE_QB64.png
 
AE_QB64_2.png
« Last Edit: March 03, 2021, 02:15:12 pm by Aurel »
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #76 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!
 
Mark1.png
//////////////////////////////////////////////////////////////////
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 #77 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.

Offline bplus

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

Random Scren Test QB64.PNG
* Random Scren Test QB64.PNG (Filesize: 1.68 MB, Dimensions: 1023x700, Views: 216)
Random Screnn Test SB1 equiv.PNG
* Random Screnn Test SB1 equiv.PNG (Filesize: 2.06 MB, Dimensions: 1025x698, Views: 232)
« Last Edit: March 04, 2021, 12:58:36 pm by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #79 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 ?
« Last Edit: March 05, 2021, 07:47:20 am by Aurel »
//////////////////////////////////////////////////////////////////
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 #80 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








« Last Edit: March 05, 2021, 11:36:44 am by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #81 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...
//////////////////////////////////////////////////////////////////
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 #82 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
« Last Edit: March 05, 2021, 03:32:28 pm by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Shorthand Basic
« Reply #83 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
//////////////////////////////////////////////////////////////////
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 #84 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.