Hi frankmar98
I alse tried the montecarlo pi estimation, but with modifications. This ran about x10 times faster.
--------
The most improved part of the interpreter, are the drawing commands.
Yes, drawing command (sketch commands) in C.Basic is very fast.
I've also made a montecaro pi estimation.
Sample Program - Montecaro
This archive includes 2 g1m files and 1 text files.
- MONTECAR.g1m
- WAIT.g1m
- MONTECAR.txt
- WAIT.txt
The g1m files can run both in genuine Casio Basic and C.Basic.
What I want to introduce here is some extended commands of C.Basic.
C.Basic is very fast. If you also overclock (with Ftune2) it's too fast. So some program like the MONTECAR.g1m has a problem.
This program detects EXE key by Getkey. This runs tooo fast, The problem is ...
you press EXE key to start this program, then the program draws something and wait for your EXE press (2nd press) to start montecaro estimation. But B.Basic is too fast, so it detects the 1st EXE key press by Getkey even you have not press the 2nd press of EXE. The program does not run as you expected.
I wanted to use quite same g1m file to run in both of genuine Casio Basic and C.Basic, so I added some trick. Please see the first 5 lines (see below). This still run in genuine Casio Basic.
'MONTECAR.g1m
200->L
'/Prog "WAIT",32
While L
Dsz L
WhileEnd
CoordOff
GridOff
AxesOff
LabelOff
ViewWindow -2.8,1.3,0,-1.0087,1.0087,0
S-L-Normal
0->I:0->O
Circle 0,0,1
Text 1,3,"C="
Text 7,1,"_pi_="
Text 51,3,"EXE:Start"
Text 58,5,"AC:Quit"
While Getkey<>31
WhileEnd
Text 51,1," "
Text 51,3,"(-):Stop "
Do
1-2Ran#->X
1-2Ran#->Y
Plot X,Y
X^<2>+Y^<2><1=>Isz I
Isz O
Text 1,11,O
Text 7,11,4I/O
If Getkey=41:Then
Text 51,1,"EXE:Start"
While Getkey<>31
WhileEnd
Text 51,1," "
Text 51,3,"(-):Stop "
IfEnd
LpWhile 1
'-------------------
The first 5 lines are to add wait for the very fast case, but this is not necessary for genuine Casio Basic.
'/Prog "WAIT",32
' is for comment out, it works in also C.Basic.
But '/ in C.Basic allows to process expression after the '/.
'/ helps to keep compatibility.
Then use extended Prog command that allows to have parameters.
Prog "WAIT",32
is transferring parameter 32 to sub program WAIT.
I have translated brief explanation for Prog.
'WAIT.g1m
Local l
Locate 1,4," == Wait a moment =="
0->%:0->L
Do
Isz L
LpWhile %<l
ClrText
Then WAIT.g1m use C.Basic original command Local to receive the parameter transferred from the main program.
Local command is prepared to set scope of variables to local within a program. It also can set only small letter variables as local.
the transferred number 32 is received by local small letter variable l (small L).
Explanation of Local
I hope this may make you more interested.
== Edit ==
Sorry, I need to explain about special variable %. The % is clock variable that returns current clock. 128 ticks is 1 sec.
== Edit ==
I replaced text files included archive Montecar.zip to files created by C.Basic.
C.Basic can load the text file and automatically convert and run. So these text file includes extra characters that is not shown in calc display.
.
Edited by Krtyski, 22 January 2017 - 05:54 AM.