Oxygen Basic

Programming => Example Code => Data Processing => Topic started by: Aurel on March 24, 2019, 01:42:12 AM

Title: microB tokenizer
Post by: Aurel on March 24, 2019, 01:42:12 AM
f***
Title: Re: microB tokenizer
Post by: Aurel on March 26, 2019, 09:51:57 AM
A
Title: Re: microB tokenizer
Post by: Aurel on August 25, 2019, 02:12:32 AM
C
Title: Re: microB tokenizer
Post by: jack on August 25, 2019, 03:20:03 AM
Aurel, there are a number of places where you use Sub instead of Function, even though O2 will tolerate that, it does not look good to me
I translated you code to FreeBASIC because my PC is a Mac and therefore O2 is not available, it seems to run ok
Title: Re: microB tokenizer
Post by: Aurel on August 25, 2019, 03:36:20 AM
f**k
Title: Re: microB tokenizer
Post by: Aurel on August 25, 2019, 03:39:09 AM
j
Title: Re: microB tokenizer
Post by: jack on August 25, 2019, 03:59:43 AM
Aurel, here's the output , I replaced MessageBox with a simple Print
Code: [Select]
Number of tokens: 15
Number of lines: 1
2
+
3
+
4
*
(
-
2
+
3
)
*
0.55
EOL

15
RESULT=7.2
Title: Re: microB tokenizer
Post by: jack on August 25, 2019, 04:04:07 AM
I use name SUB when routine is small and when don't require Returned value.
if is larger then I use FUNCTION.
Code: [Select]
sub tokenizer(src as string) as int
about 8 more similar to that
Title: Re: microB tokenizer
Post by: jack on August 25, 2019, 04:56:24 AM
Jack
In o2 it is the same to use SUB or FUNCTION
from OxigenBasic doc
Quote
Oxygen Basic Procedures
...
function   Defines a procedure that returns a value.
sub   Defines a procedure that does not return a value.
Title: Re: microB tokenizer
Post by: Aurel on August 25, 2019, 05:18:55 AM
A
Title: Re: microB tokenizer
Post by: Aurel on April 15, 2020, 11:14:28 AM
T
Title: Re: microB tokenizer
Post by: JRS on April 15, 2020, 07:20:04 PM
Aurel,

ScriptBasic works great as an embedded scripting solution with O2.

The reverse is also true with O2 embedded in ScriptBasic via the DLLC extension module.
Title: Re: microB tokenizer
Post by: Aurel on April 15, 2020, 10:05:09 PM
f***
Title: Re: microB tokenizer
Post by: JRS on April 15, 2020, 11:05:56 PM
Another idea is to use O2's JIT compiler feature to execute your expressions in another thread.
Title: Re: microB tokenizer
Post by: Aurel on May 12, 2020, 01:38:19 AM
J
Title: Re: microB tokenizer
Post by: Aurel on May 12, 2020, 01:40:10 AM
S
Title: Re: microB tokenizer
Post by: Aurel on May 17, 2020, 10:24:24 PM
-
Title: Re: microB tokenizer
Post by: Aurel on May 20, 2020, 02:24:16 PM
F
Title: Re: microB tokenizer
Post by: Aurel on June 18, 2020, 01:23:00 PM
F
Title: Re: microB tokenizer
Post by: JRS on June 20, 2020, 05:48:39 PM
I think it's suppose to look like this. Your fern may need watering.  ;D

250K iterations.

Have you thought about upgrading to Windows 10?

Code: Script BASIC
  1. ' ScriptBasic GFX - Fern
  2.  
  3. IMPORT gfx.sbi
  4.  
  5. s = gfx::Window(640,500,"ScriptBasic GFX Fern")
  6. RANDOMIZE(gfx::Time())
  7. SPLITA STRING(3,"0") BY "" TO xy
  8.  
  9. SUB Fern
  10. r = RND() % 100
  11. IF r <= 10 THEN
  12.    SPLIT "0,0,0,0.16,0,0" BY "," TO a,b,c,d,e,f
  13. ELSE IF r > 1 AND r <=86 THEN
  14.    SPLIT "0.85,0.04,-.04,0.85,0,1.60" BY "," TO a,b,c,d,e,f
  15. ELSE IF r > 86 AND r <=93 THEN
  16.    SPLIT "0.2,-.26,0.23,0.22,0,0.16" BY "," TO a,b,c,d,e,f
  17. ELSE
  18.    SPLIT "-.15,0.28,0.26,0.24,0,0.44" BY "," TO a,b,c,d,e,f
  19. END IF
  20. newx = ((a * xy[1]) + (b * xy[2]) + e)
  21. newy = ((c * xy[1]) + (d * xy[2]) + f)
  22. xy[1] = newx
  23. xy[2] = newy
  24. gfx::pixelRGBA s, INT(xy[1]*40+300), INT(-xy[2]*40+450), 0, 210, 55, 255
  25. END SUB
  26.  
  27. ts = gfx::Time()
  28. FOR w=1 TO 250000
  29.     Fern
  30. NEXT
  31. te = gfx::Time()
  32. gfx::stringColor s, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff
  33. gfx::Update
  34. WHILE gfx::KeyName(1) <> "+escape"
  35. WEND
  36. gfx::Close
  37.  
Title: Re: microB tokenizer
Post by: Aurel on June 21, 2020, 12:35:59 AM
n
Title: Re: microB tokenizer
Post by: JRS on June 21, 2020, 09:45:03 AM
If your projects are not meant to be shared, running on deprecated OS platforms doesn't matter. Enjoy your hobby programming.