-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpreter
More file actions
3721 lines (3268 loc) · 73.9 KB
/
Copy pathinterpreter
File metadata and controls
3721 lines (3268 loc) · 73.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$ Filename "ruben4.exe"
Include "RTL32.inc"
Include "awinh.inc"
#LOOKAHEAD
'timers
'indexbase 0
Declare Function GetTickCount Lib "kernel32.dll" () As Long
FLOAT startTime,EndTime,RTime
'must be in global scope +++++++++++++++++++++++++
INT fseed = 0x12345678 ' seed number
INT kut = 0 ' global angle / kut |__
INT turtlex=0,turtley=0
string source ' src buffer
string lines[40000] 'lines array
'sys pt = strptr txt 'buffer base pointer
'sys i.j,p 'indexes and pointer
string CRLF=Chr(13)+Chr(10)
string temp$=""
INT TRUE = 1
INT FALSE = 0
NumberFormat 4,1,0,0,0,0
STRING Look,CR = chr(13),LF=chr(10)
Look = " " ' Yes, that space is IMPORTANT!!!! Remove and DIE!!!
STRING Stream,ts
INT StreamPos ' Read position in stream
'++++++++++++++++++++++++++++++++++++++++++++++++
% LR_LOADTRANSPARENT = &H20
% LR_LOADMAP3DCOLORS = &H1000
INT TransparentMap3D = LR_LOADTRANSPARENT Or LR_LOADMAP3DCOLORS
INT win,win2,mpanel
INT winstyle
INT button0,button1,button2,button3,button4,button5
INT edit1,edit2,edit3
INT Lbox,static1,static2,static3,richedit1,hpbar
INT statB0,statB1,statB2
INT ed1ID,ed2ID,ed3ID,pbID
INT b1ID,b2ID,b3ID,b4ID,b5ID,b6ID,b7ID
INT LboxID
LboxID=300
INT st1ID,st2ID
INT reID
b0ID=99
b1ID=100
b2ID=101
b3ID=102
b4ID=103
b5ID=104
'-----------------
ed1ID=200
ed2ID=201
ed3ID=202
'----------------
st1ID=350
st2ID=351
st3ID=352
INT statB0id=360,statB1id=361,statB2id=362
'----------------
reID=400
'----------------
pbID = 70
'loadbmp
'##########################################
INT bmpB0,bmpS1
bmpB0 = LoadImage(0,"data/xpNew.bmp",0,24,24,16)
bmpS1 = LoadImage(0,"data/rubenX.bmp",0,82,82,16)
'##########################################
STRING src[15000]
'*******************************************
'************* GLOBALS *********************
STRING arg0[4096]
STRING arg1[4096]
STRING arg2[4096]
STRING arg3[4096]
STRING arg4[4096]
STRING arg5[4096]
STRING arg6[4096]
STRING arg7[4096]
STRING arg8[4096]
STRING arg9[4096]
STRING arg10[4096]
STRING arg11[4096]
STRING arg12[4096]
STRING arg13[4096]
STRING arg14[4096]
STRING arg15[4096]
STRING arg16[4096]
STRING arg17[4096]
STRING arg18[4096]
STRING arg19[4096]
STRING arg20[4096]
'command token
sys tok[4096]
'******************************************
'-----------COMMAND TOKENS---------
%R_UNKNOWN=0
%R_WTEXT=1
%R_MSG=2
%R_IF=3
%R_ENDIF=4
%R_LOOPTO=5
%R_SHIFT=6
%R_SET=7
%R_WFORM=8
%R_PIX=9
%R_LINE=10
%R_TXCOLOR=11
%R_DEFINT=12
%R_NARRAY=13
%R_JUMP=14
%R_LABEL=15
%R_CIRCLE =16
%R_WINCOLOR = 17
%R_RECT = 18
%R_CONTROL = 20
%R_WAIT = 50
%R_CALL = 51
%R_FUNC = 52
%R_ENDFUNC = 53
%R_MBOXGTW = 54
%R_OFF = 55
%R_MOUSEMOVE = 56
%R_MOUSEX = 57
%R_MOUSEY = 58
%R_LEFTMBDOWN = 59
%R_ONPAINT = 60
%R_CLIP = 61
INT perr = 0
'******************************************
'intList ->->->->->->->->
INT varLastPos=0
INT varID=0
STRING varName[100]
FLOAT varValue[100]
'var type list
' 1 - INT
' 2 - FLOAT
' 3 - STRING
INT varType[100]
'array index /id/
'4 ARRAY-INT [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
INT arrIndex=0
STRING arrStack[32] 'array stack hold array name
STRING arrType[32] 'array type 1->INT , 2->STRING
STRING arrSize[32] 'array size
STRING arrID[32] 'array ID -> hold array index(identifier)
'array store
STRING arr01[4096],arr02[4096],arr03[4096],arr04[4096],arr05[4096],arr06[4096],arr07[4096],arr08[4096]
STRING arr09[4096],arr10[4096],arr11[4096],arr12[4096],arr13[4096],arr14[4096],arr15[4096],arr16[4096]
'5 ARRAY-FLOAT
'6 ARRAY-STRING
'*******************************************
String arg[20]
sys dPos[20]
'---array of global variables -------------
string gArrInt[100]
'*******************************************
'program Counter PC--------------------------
INT PC=0,LineNum=0,executed=0,Start=0,EndCode=0,perr=0,key=0
INT EventOn=0,waitpos=0
INT MMoveOn=0,MMovePos=0
INT GetMouseX=0,GetMouseY=0
INT LeftBDownON=0,LeftBDownPos=0
INT PaintOn = 0,PaintPos=0
'----------------------------------------------------
'FOR stack--------------------------------
INT forStart,fc[100],forEnd[100]
INT fPush,fStep[100],forPos[100]
STRING fStack[16]
'-- LABEL STACK -------------------
INT LabelCounter
INT labelPos[1000]
STRING labelName[1000]
'-- FUNC STACK --------------------
INT gPush,retPos
INT funcPos[1000]
INT gStack[1000]
INT subpos[1000]
STRING FuncName
'-------------------------------------------
INT hControl
'-------------------------------------------
winstyle = WS_HIDDEN
'winstyle = WS_SYSMENU
'GLOBALS for drawing to DC --------------------------------------------
INT hdc, hdcMem, hbmMem, oldBmp, oldBrush, oldPen, oldFont, fColor,bColor
INT textX,textY,hBrush
INT ww,hh
String tBuffer
'create main window ****************************************************
win = SetWindow("RUBEN",40,40,750,572,0, winstyle)
'***********************************************************************
INT mainClose=0
'create buttons ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'button0 = SetButton(win,124,6,40,32,"NEW",0x50000080|LR_LOADTRANSPARENT,0x200,b0ID)
'SendMessage button0 , BM_SETIMAGE, 0, bmpB0
statB0 = SetStatic(win,100,6,24,24,"",0x5000030E,0,statB0id)
SendMessage statB0 ,370, 0, bmpB0
button1 = SetButton(win,100,6,90,24,"OpenFile",0x50000000,0x200,b1ID)
'set bitmap on button 1
'SendMessage button1 , BM_SETIMAGE, 0, bmpB1
button2 = SetButton(win,594,60,80,24,"MSG-PANEL",0x50000000,0x200,b2ID)
'button3 = SetButton(win,380,14,100,24,"Load X",0x50000000,0x200,b3ID)
'button4 = SetButton(win,490,14,70,24,"GetLCount",0x50000000,0x200,b4ID)
button5 = SetButton(win,196,6,84,24,"RUN",0x50000000,0x200,b5ID)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create edit control
edit1 = SetEditBox(win,100,60,488,23,"edit 1",0x50004000,0x200,ed1ID)
'create listboxes ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Lbox = SetListBox(win,594,88,140,440,"LB 1",0x50B00140,0x200,LboxID)
'create static control
static1 = SetStatic(win,656,6,60,16,"RubenDev:",0,0x200,st1ID)
'upper edit
static2 = SetEditBox(win,100,40,488,18,"",0x50004000,0x200,st1ID)
'crete static control with bitmap
static3 = SetStatic(win,8,6,82,82,"",0x5000030E,0x200,st3ID)
SendMessage static3 ,370, 0, bmpS1
'create Rich Edit control
INT reStyle = WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_HSCROLL|ES_AUTOVSCROLL|ES_AUTOHSCROLL|ES_SUNKEN
String tbuffer=""
' tbuffer = "defINT n,s,e" + Chr(13)
'tbuffer=tbuffer + "Set n = 1,s=2,e=3" + Chr(13)
'tbuffer=tbuffer + "wFORM 100, 0, 400, 300, #MMS,0," + Chr(34) +"New Caption!" +Chr(34) +Chr(13)
'tbuffer=tbuffer + "doFOR number, start, end" + Chr(13)
'tbuffer=tbuffer + "wTEXT xPos , yPos ,"+ Chr(34) +"New Text" + Chr(34)
'INT reStyle = 0x508010C4 /::src code line::
richedit1 = SetRichEdit(win,8,88,580,440,tbuffer,reStyle ,0x200,reID)
'setFont
ControlFont(richedit1,16,400,0,"Courier New")
INT LCount = 0
INT parseCount=0,runCount=0
'GetCommandline / recieve command line from editor /
IF parseCount=0 AND runCount=0
string fName=""
fName = GetCommandLine()
'fName = chr(34) + fname + chr(34)
'print fname
if fname<>""
LoadfromFile()
end if
End If
sys eMSG
'-----------------------------------------------------------
'GoSub AddListboxItems
'-----------------------------------------------------------
' msg loop -->>>
Wait()
'------------<<<
'============================================================================================================
Function WndProc (byval hwnd as long,byval wMsg as long, byval wParam as long,byval lparam as long) as long callback
Select hwnd
'>>>>>>>>>>>>>>>>>>>>>>>>>
Case win
'>>>>>>>>>>>>>>>>>>>><<<
Select wMsg
'----------------------------
'Case WM_CLOSE
'print "wmClose-detected"
'If win=1
'CloseWindow(win)
'EndProgram()
'End If
CASE WM_DESTROY
PostQuitMessage(0)
'-------------------------------------------------------------
Case WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
Select controlID
Case b1ID
If notifycode=0
doOpen()
End If
Case b2ID ' open message panel
If notifycode=0
msgPanel()
End If
Case b3ID
If notifycode=0
'LoadFromFile()
End If
Case b4ID
If notifycode=0
GetLineCount()
End If
Case b5ID
'RUN
If notifycode=0
ParseCode()
'print "ParseError:" + Str(perr)
If perr=0 then RunCode()
'print "Run-Over!"
End If
End Select
End Select 'msg
'------------------------------------------
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Case win2
Select wMsg
Case WM_PAINT
If win2 <> 0
BitBlt(hDC, 0, 0, ww, hh, hdcMem, 0, 0, SRCCOPY)
End If
Case WM_CLOSE
If win2 <> 0
'print "OutWindow Closed!"
CleanUp()
CloseWindow(win2)
SendMessage win,WM_DESTROY,0,0:parseCount=0:runCount=0
ExitProcess 0
'win2=0
End If
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'processing events ::::::::::::::::::::::::::::::::::::::
CASE WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
'
'for button onclick
'IF notifyCode=0
'search control ID
'For controlID = 100 TO 500
'Next
'END IF
'---------------------------------------------------
CASE WM_MOUSEMOVE
GetMouseX = LoWord(lParam)
GetMouseY = HiWord(lParam)
IF MMovePos > WaitPos
'GetMouseX = LoWord(lParam)
'GetMouseY = HiWord(lParam)
MMoveOn = 1
'
If MMoveOn = 1
If eventOn = 1
Runcode()
MMoveOn=0
End if
end if
END IF
'-------------------------------------------------
CASE WM_LBUTTONDOWN
IF LeftBDownPos > WaitPos
LeftBDownON = 1
If LeftBDownON = 1
Runcode()
LeftBDownON = 0
End If
END IF
End Select 'msg
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Case mpanel
Select wMsg
Case WM_CLOSE
If mpanel <> 0
'CleanUp()
CloseWindow(mpanel)
End If
End Select
'------------------------------------------
End Select
'/////////////////////////////////////////////
Return DefWindowProc hwnd,wMsg,wParam,lParam
'/////////////////////////////////////////////
End FUNCTION
'============================================================
SUB msgPanel
winstyle = WS_SYSMENU
mpanel = SetWindow("RUBEN - Message Panel",300,200,380,320,0,winstyle)
hpbar = SetProgressbar(mpanel,40,60,300,16,1,300,2,0,0x200,pbID)
End SUB
'########################################################
SUB AddListboxItems
bstring i$ : i$=""
SendMessage LBox,LB_RESETCONTENT,0,""
For n = 0 To 10
i$ = Str(n) + "...." + Str(dpos[n])
SendMessage Lbox,LB_ADDSTRING,0,i$
Next n
End SUB
'#########################################################
'#########################################################
SUB LoadFromFile
STRING args,src
INT qPos,sf
bstring info
' remove the executable information
' get quote position
qPos = Instr(1,fName, Chr(34))
qPos = Instr(qPos+1,fName, Chr(34))
'print str(qpos)
args = Mid(fName,qPos+1,254)
src = Trim(args)
If len(src) = 0
args="No Source"
'info=args : IF LEN(info)=0 then info = "No Source"
end if
'print args...if is empty then compiler trow F ???
SendMessage edit1,WM_SETTEXT,0,strptr args
source = GetFile src
If Len(source)=0
args="No Source"
MsgBox (args, "Source Not Found!")
SendMessage win,WM_CLOSE,0,0 : parseCount=0:runCount=0
Return
End If
'SendMessage richedit1,WM_SETTEXT,0,strptr source
ParseCode()
'print "Parsed...."
parseCount=1 'prevent double PARSE
If perr=0
'print "Run..."
RunCode()
runCount=1 ' prevent double RUN
End if
'print "EXEC::"+str(executed)
RETURN
End SUB
'************************************************************
Sub doOpen
bstring fR
dir=""
bstring sep=chr 0
filter="All Files"+sep+"*.*"+sep+"Text files"+sep+"*.txt"
'filter="text"+sep+"*.txt"+sep+
'"basic"+sep+"*.bas;*.o2bas"+sep+
'"include"+sep+"*.inc"+sep+
'"header"+sep+"*.h"+sep+
'sep
title="Test File Opening Dialog"
hwnd=0
fR = FileDialog(dir,filter,title,0,0,"txt")
SendMessage edit1,WM_SETTEXT,0,fR
bstring tx = getfile fR
SendMessage richedit1,WM_SETTEXT,0,tx
End Sub
'*************************************************************
SUB GetLineCount
LCount = SendMessage richedit1,EM_GETLINECOUNT,0,0
EndCode=LCount
bstring count$ = ""
count$ = Str(LCount)
SendMessage edit1,WM_SETTEXT,0,count$
count$=""
RETURN
End SUB
SUB PARSECODE
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'MsgBox "START PARSER...","PARSE CODE..."
SendMessage LBox,LB_RESETCONTENT,0,""
ClearGlobalArray()
PC=0
INT Lpos
INT LLen
INT EPos=0
STRING c$=""
string LText=""
string pText=""
'reset var position %%%%
varLastPos=0
'%%%%%%%%%%%%%%%%%%%%%%%
'GetLineCount()
FillArray()
'+++ main loop +++++++++++++++++++++++++++++++
For Lpos = 1 TO LCount
'set pc
'print "LPOS:" + Str(LPos)
PC=Lpos
'print "PC:" + Str(pc)
'clear locals
c$="":LText="":Epos=0
LText = lines[LPos]
'skip empty line-----------------
'IF LText = "" THEN Goto toNext
'Left trim whitespace -----------
LText = LTrim(Ltext)
UpdateWindow static2:UpdateWindow edit1
SendMessage static2,WM_SETTEXT,0,strptr(Ltext)
'SendMessage edit1,WM_SETTEXT,0,strptr(pc$)
'get position of first empty space ----------
Epos = INSTR (LText," ")
IF EPos <> 0
'get left from empty space
c$ = Left(LText,Epos-1)
ELSE
'get substring argument
c$= Mid(Ltext,1,Len(Ltext))
END IF
c$ = Trim(c$)
c$=Ucase(c$)
'..................................
'print "C$:"+c$
'check command :::
If c$="DEFN"
parse_DEFINT()
End If
If c$="IF"
parse_IF()
End If
If c$="ENDIF"
parse_ENDIF()
End If
If c$="SET"
parse_SET()
End If
If c$="NARRAY"
parse_ARRAYN()
End If
If c$="WFORM"
parse_WINDOW()
End If
If c$="FOR"
parse_FOR()
End If
If c$="NEXT"
parse_NEXT()
End If
If c$ = "TXCOLOR"
parse_TxColor()
End If
If c$="WTEXT"
parse_wtext()
End If
If c$="MBOXGETW"
parse_MBoxGetWord()
End If
If c$="LINE"
parse_LineXY()
End If
If c$="CIRCLE"
parse_Circle()
End If
If c$="RECT"
parse_Rect()
End If
If c$="PIX"
parse_PsetXY()
End If
If c$="JUMP"
parse_JUMP()
End If
If c$="LABEL"
parse_LABEL()
End If
'.......................'
'... EVENTS-MESSAGES ...'
'.......................'
If c$="WAIT"
parse_WAIT()
End If
If c$="@MOUSEMOVE"
parse_MOUSEMOVE()
End if
If c$="@ONPAINT"
parse_ONPAINT()
End If
If c$="@LEFTMBDOWN"
parse_LeftButtonDown()
End if
If c$="@MOUSEX"
parse_MOUSEX()
End if
If c$="@MOUSEY"
parse_MOUSEY()
End if
If c$="@OFF"
parse_OFF()
End If
'......................
If c$="REDRAW"
parse_REDRAW()
End If
If c$="WCOLOR"
parse_WINCOLOR()
End If
If c$="WCON"
parse_WINCONTROL()
End If
Next Lpos
string showerror
showerror=Str(perr)
'MsgBox ("...END PARSING !","")
Return
End SUB
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
' END PARSER
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'------ FILL GLOBAL STRING ARRAY ------------------------------
SUB FillArray
'initial
'=======
b=1 'start of line
i=0 'lines array index
j=1 'char index
'
'splitter loop
'=============
'
DO
select asc(source,j)
case 0
if j-b>0 then
i++
lines[i]=mid(source,b,j-b)
end if
exit do
case 10 'LF TERMINATED LINES
i++
lines[i]=mid(source,b,j-b)
b=j+1
case 13 'CR AND CRLF TERMINATED LINES
i++
lines[i]=mid(source,b,j-b)
if asc(source,j+1)=10 then j++ 'SKIP LF
b=j+1
end select
j++
END DO
'array filed
LCount=i
'print "Line Count:" +str(Lcount)
'MsgBox "Source Array filled...","OK!"
End SUB
'---CLEAR GLOBAL STRING ARRAY ----------------------------------
SUB ClearGlobalArray
INT n
For n = 0 TO 1000
arg0[n]=""
arg1[n]=""
arg2[n]=""
arg3[n]=""
arg4[n]=""
arg5[n]=""
arg6[n]=""
arg7[n]=""
arg8[n]=""
arg9[n]=""
arg10[n]=""
arg11[n]=""
arg12[n]=""
arg13[n]=""
arg14[n]=""
arg15[n]=""
arg16[n]=""
arg17[n]=""
arg18[n]=""
arg19[n]=""
arg20[n]=""
Next n
'print "GLOBAL LIST - CLEARED!"
RETURN
End SUB
'________________________________________________________________
SUB parse_WINDOW
'print "WINDOW"
'***********************************************************
Int cc,nArg,n : nArg=7
string buffer=""
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,7,Len(temp$)-2)
temp$=Ltrim(temp$)
'cc = Tally temp$,","
'tally2- by Charles
cc = Tally(temp$,",")
ParseArgs()
'if wrong numOfArgs
If nArg <>(cc+1)
MsgBox "Wrong Number of arguments!","ERROR-Parse Window"
perr=1
Return
End If
'store key
arg0[PC] = "WFORM" : tok[PC] = R_WFORM
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
Return
End Sub
'_____________________________________________________________
SUB parse_WINCONTROL
'syn WCON $BUTTON,x,y,w,h,style,id
'***********************************************************
Int cc,nArg,n : nArg=7
string buffer=""
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,5,Len(temp$)-2)
temp$=Ltrim(temp$)
cc = Tally(temp$,",")
ParseArgs()
'if wrong numOfArgs
If nArg <>(cc+1)
MsgBox "Wrong Number of arguments!","ERROR-Parse WinControl"
perr=1
Return
End If
'store key
arg0[PC] = "WCON" : tok[PC] = R_CONTROL
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
End Sub
'parse doFOR ---------------------------------------------
SUB parse_FOR
'LoopTo
INT cc,nArg
temp$ = ""
temp$ = lines[PC]
'print "(for)TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,4,Len(temp$)-2)
temp$=Ltrim(temp$)
cc = Tally(temp$,",")
ParseArgs()
nArg=cc+1
'if wrong numOfArgs
If nArg <>(cc+1)
MsgBox "Wrong Number of arguments!","ERROR-Parse LoopTo"
perr=1
Return
End If
'store key
arg0[PC] = "FOR" : tok[PC] = R_LOOPTO
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
End SUB
'--------------------------------------------------------
'parse Next step
SUB parse_NEXT
'shift
INT cc,nArg
temp$ = ""
temp$ = lines[PC]
'print "(for)TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,6,Len(temp$)-2)
temp$=Ltrim(temp$)
cc = Tally(temp$,",")
ParseArgs()
nArg=cc+1
'if wrong numOfArgs
If nArg <>(cc+1)
MsgBox "Wrong Number of arguments!","ERROR-Parse Window"
perr=1
Return
End If
'store key
arg0[PC] = "SHIFT" : tok[PC] = R_SHIFT
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
End SUB
'parse IF ----------------------------------------------
SUB parse_IF
'print "IF command found!"
INT cc,n,nArg
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,3,Len(temp$)-2)
temp$= Trim(temp$)
cc = Tally(temp$,",")
nArg=cc+1
'print "Number of arguments :" + Str(nArg)
If nArg > 3
MsgBox "Number of arguments OUT of range!","ERROR-Parse IF"
perr=1
Return
End If
ParseArgs()
arg0[PC] = "IF" : tok[PC] = R_IF
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
'print arg0[PC] + arg1[PC] + arg2[PC] + arg3[PC]
END SUB
'parse ENDIF ----------------------------------------------
SUB parse_ENDIF
arg0[PC] = "ENDIF" : tok[PC] = R_ENDIF
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
END SUB
'parse DEFINT-------------------------------------------
SUB parse_DefINT
'print "DEFN - DEFineNumber "
INT cc,n,nArg
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,5,Len(temp$)-2)
temp$=Ltrim(temp$)
cc = Tally(temp$,",")
nArg=cc+1
'print "Number of arguments :" + Str(nArg)
If nArg > 20
MsgBox "Number of arguments OUT of range!","ERROR-Parse INT"
perr=1
Return
End If
ParseArgs()
'set variable name & value position of variable in array
INT pos=0
pos = varLastPos + 1
For n = 1 TO nArg
varName[pos] = arg[n]
varValue[pos] = 0
varType[pos] = 1
'print "VAR:" + varName[pos] + " = " + Str(pos)
pos = pos + 1
Next n
'set last variable position in array
varLastPos = pos
'store key
arg0[PC] = "DEFN" : tok[PC] = R_DEFINT
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
End SUB
'[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
SUB parse_ARRAYN
'print "NARRAY command found!"
STRING arrName ,ts,asize ',arrType,arrSize,arrID,ts
INT cc,n,nArg,bo,bc
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,7,Len(temp$)-2)
temp$=Ltrim(temp$)
cc = Tally(temp$,",")
nArg=cc+1
'print "Number of arguments :" + Str(nArg)
If nArg > 20
MsgBox "Number of arguments OUT of range!","ERROR-Parse INT"
perr=1
Return
End If
ParseArgs()
'set array name ,value position of variable in array
IF arrIndex < 33
'arrIndex=arrIndex+1
n=1
For n = 1 TO nArg
ts=arg[n]
bo=INSTR(ts,"[")
arrName=mid(ts,1,bo-1) 'get name $
bc=instr(1,ts,"]")
aSize= mid(ts,bo+1,(bc-1)-2) 'get size $
'--------------------
arrIndex=arrIndex+1
'--------------------
arrType[arrIndex] = "1" 'arr type
arrSize[arrIndex] = asize 'arr size
arrID[arrIndex] = str(arrIndex) 'arr id
arrStack[arrIndex]= arrName 'arr name(stack for search...)
'print "ARRAY:" + arrStack[arrIndex] 'name
'print "TYPE:" + arrType[arrIndex]
'print "SIZE:" + arrSize[arrIndex]
'print "ID:" + arrID[arrIndex]
Next n
END IF
'set last variable position in array
'varLastPos = pos
'store key
arg0[PC] = "NARRAY" : tok[PC] = R_NARRAY
SendMessage Lbox,LB_ADDSTRING,0,arg0[PC]
perr=0
End SUB
'-------------------------------------------------------
SUB parse_SET : ' set a = (expr),b=expr,c=expr
INT ec,n,nArg,eqPos,cc
String ex$="",v$=""
temp$=""
temp$ = lines[PC]
'print "TEMP:"+temp$
temp$=Ltrim(temp$)
temp$=Mid(temp$,4,Len(temp$)-2)
temp$=Ltrim(temp$)
'print "TEMP:" + temp$
'check if comma is outside of quote/more expressions