forked from boxgaming/qbjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqb2js.js
3006 lines (2997 loc) · 140 KB
/
qb2js.js
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
async function _QBCompiler() {
// Option _Explicit
// $Console
// Only
const FILE = 1;
const TEXT = 2;
const False = 0;
const True = ! False;
const PrintLineMapping = False;
const PrintTokenizedLine = False;
const PrintDataTypes = True;
var lines = QB.initArray([{l:1,u:0}], {line:0,text:''}); /* CODELINE */
var jsLines = QB.initArray([{l:1,u:0}], {line:0,text:''}); /* CODELINE */
var methods = QB.initArray([{l:1,u:0}], {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}); /* METHOD */
var types = QB.initArray([{l:1,u:0}], {line:0,name:'',argc:0,args:''}); /* QBTYPE */
var typeVars = QB.initArray([{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}); /* VARIABLE */
var globalVars = QB.initArray([{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}); /* VARIABLE */
var localVars = QB.initArray([{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}); /* VARIABLE */
var warnings = QB.initArray([{l:1,u:0}], {line:0,text:''}); /* CODELINE */
var exportLines = QB.initArray([{l:1,u:0}], ''); /* STRING */
var exportConsts = QB.initArray([{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}); /* VARIABLE */
var exportMethods = QB.initArray([{l:1,u:0}], {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}); /* METHOD */
var dataArray = QB.initArray([{l:1,u:0}], ''); /* STRING */
var dataLabels = QB.initArray([{l:1,u:0}], {text:'',index:0}); /* LABEL */
var modLevel = 0; /* INTEGER */
var currentMethod = ''; /* STRING */
var currentModule = ''; /* STRING */
var programMethods = 0; /* INTEGER */
if (QB.func_Command() != "" ) {
await sub_QBToJS( QB.func_Command(), FILE, "");
await sub_PrintJS();
QB.halt(); return;
}
async function sub_QBToJS(source/*STRING*/,sourceType/*INTEGER*/,moduleName/*STRING*/) {
if (QB.halted()) { return; }
currentModule = moduleName;
await sub_ResetDataStructures();
if ( moduleName == "" ) {
QB.resizeArray(jsLines, [{l:1,u:0}], {line:0,text:''}, false); /* CODELINE */
}
if ( sourceType == FILE) {
await sub_ReadLinesFromFile( source);
} else {
await sub_ReadLinesFromText( source);
}
await sub_FindMethods();
programMethods = (QB.func_UBound( methods));
await sub_InitGX();
await sub_InitQBMethods();
var selfConvert = 0; /* INTEGER */
var isGX = 0; /* INTEGER */
isGX = False;
if ( sourceType == FILE) {
selfConvert = (await func_EndsWith( source, "qb2js.bas"));
}
if ( selfConvert) {
await sub_AddJSLine( 0, "async function _QBCompiler() {");
} else if ( moduleName != "" ) {
await sub_AddJSLine( 0, "async function _" + moduleName + "() {");
} else if ( sourceType == FILE) {
await sub_AddJSLine( 0, "async function init() {");
}
if (! selfConvert && moduleName == "" ) {
await sub_AddJSLine( 0, "QB.start();");
}
if (! selfConvert && moduleName == "" ) {
var mtest = {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}; /* METHOD */
if ((await func_FindMethod( "GXOnGameEvent" , mtest, "SUB")) ) {
await sub_AddJSLine( 0, " await GX.registerGameEvents(sub_GXOnGameEvent);");
isGX = True;
} else {
await sub_AddJSLine( 0, " await GX.registerGameEvents(function(e){});");
await sub_AddJSLine( 0, " QB.sub_Screen(0);");
}
}
await sub_AddJSLine( 0, "");
await sub_InitData();
await sub_ConvertLines( 1, await func_MainEnd(), "");
if (! selfConvert && ! isGX && moduleName == "" ) {
await sub_AddJSLine( 0, "QB.end();");
}
await sub_ConvertMethods();
if ( selfConvert) {
await sub_AddJSLine( 0, "this.compile = async function(src) {");
await sub_AddJSLine( 0, " await sub_QBToJS(src, TEXT, '');");
await sub_AddJSLine( 0, " var js = '';");
await sub_AddJSLine( 0, " for (var i=1; i<= QB.func_UBound(jsLines); i++) {");
if ( PrintLineMapping) {
await sub_AddJSLine( 0, " js += '/* ' + i + ':' + this.getSourceLine(i) + ' */ ' + QB.arrayValue(jsLines, [i]).value.text + '\\n';");
} else {
await sub_AddJSLine( 0, " js += QB.arrayValue(jsLines, [i]).value.text + '\\n';");
}
await sub_AddJSLine( 0, " }");
await sub_AddJSLine( 0, " return js;");
await sub_AddJSLine( 0, "};");
await sub_AddJSLine( 0, "this.getWarnings = function() {");
await sub_AddJSLine( 0, " var w = [];");
await sub_AddJSLine( 0, " for (var i=1; i <= QB.func_UBound(warnings); i++) {");
await sub_AddJSLine( 0, " w.push({");
await sub_AddJSLine( 0, " line: QB.arrayValue(warnings, [i]).value.line,");
await sub_AddJSLine( 0, " text: QB.arrayValue(warnings, [i]).value.text");
await sub_AddJSLine( 0, " });");
await sub_AddJSLine( 0, " }");
await sub_AddJSLine( 0, " return w;");
await sub_AddJSLine( 0, "};");
await sub_AddJSLine( 0, "this.getSourceLine = function(jsLine) {");
await sub_AddJSLine( 0, " if (jsLine == 0) { return 0; }");
await sub_AddJSLine( 0, " var line = QB.arrayValue(jsLines, [jsLine]).value.line;");
await sub_AddJSLine( 0, " line = QB.arrayValue(lines, [line]).value.line;");
await sub_AddJSLine( 0, " return line;");
await sub_AddJSLine( 0, "};");
await sub_AddJSLine( 0, "");
await sub_AddJSLine( 0, "return this;");
await sub_AddJSLine( 0, "}");
} else if ( moduleName != "" ) {
await sub_AddJSLine( 0, "return this;");
await sub_AddJSLine( 0, "}");
await sub_AddJSLine( 0, "const " + moduleName + " = await _" + moduleName + "();");
} else if ( sourceType == FILE) {
await sub_AddJSLine( 0, "};");
}
}
async function sub_ResetDataStructures() {
if (QB.halted()) { return; }
QB.resizeArray(lines, [{l:1,u:0}], {line:0,text:''}, false); /* CODELINE */
QB.resizeArray(methods, [{l:1,u:0}], {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}, false); /* METHOD */
QB.resizeArray(types, [{l:1,u:0}], {line:0,name:'',argc:0,args:''}, false); /* QBTYPE */
QB.resizeArray(typeVars, [{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}, false); /* VARIABLE */
QB.resizeArray(globalVars, [{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}, false); /* VARIABLE */
QB.resizeArray(localVars, [{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}, false); /* VARIABLE */
QB.resizeArray(warnings, [{l:1,u:0}], {line:0,text:''}, false); /* CODELINE */
QB.resizeArray(dataArray, [{l:1,u:0}], '', false); /* STRING */
QB.resizeArray(dataLabels, [{l:1,u:0}], {text:'',index:0}, false); /* LABEL */
if ( modLevel == 0) {
QB.resizeArray(exportMethods, [{l:1,u:0}], {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}, false); /* METHOD */
QB.resizeArray(exportConsts, [{l:1,u:0}], {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}, false); /* VARIABLE */
}
currentMethod = "";
programMethods = 0;
}
async function sub_InitData() {
if (QB.halted()) { return; }
if ((QB.func_UBound( dataArray)) < 1) {
return;
}
var ds = ''; /* STRING */
ds = "[" + (await func_Join( dataArray , 1, - 1, ",")) + "]";
await sub_AddJSLine( 0, "QB.setData(" + ds + ");");
var i = 0; /* INTEGER */
var ___v7055475 = 0; for ( i= 1; i <= (QB.func_UBound( dataLabels)); i= i + 1) { if (QB.halted()) { return; } ___v7055475++; if (___v7055475 % 100 == 0) { await QB.autoLimit(); }
await sub_AddJSLine( 0, "QB.setDataLabel('" + QB.arrayValue(dataLabels, [ i]).value .text + "', " + (QB.func_Str( QB.arrayValue(dataLabels, [ i]).value .index)) + ");");
}
}
async function sub_PrintJS() {
if (QB.halted()) { return; }
var i = 0; /* INTEGER */
var ___v5334240 = 0; for ( i= 1; i <= (QB.func_UBound( jsLines)); i= i + 1) { if (QB.halted()) { return; } ___v5334240++; if (___v5334240 % 100 == 0) { await QB.autoLimit(); }
await QB.sub_Print([QB.arrayValue(jsLines, [ i]).value .text]);
}
}
async function sub_ConvertLines(firstLine/*INTEGER*/,lastLine/*INTEGER*/,functionName/*STRING*/) {
if (QB.halted()) { return; }
var typeMode = 0; /* INTEGER */
typeMode = False;
var jsMode = 0; /* INTEGER */
jsMode = False;
var i = 0; /* INTEGER */
var indent = 0; /* INTEGER */
var tempIndent = 0; /* INTEGER */
var m = {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}; /* METHOD */
var totalIndent = 0; /* INTEGER */
totalIndent = 1;
var caseCount = 0; /* INTEGER */
var loopMode = QB.initArray([{l:1,u:100}], 0); /* INTEGER */
var loopLevel = 0; /* INTEGER */
var caseVar = ''; /* STRING */
var currType = 0; /* INTEGER */
var loopIndex = ''; /* STRING */
var ___v5795186 = 0; for ( i= firstLine; i <= lastLine; i= i + 1) { if (QB.halted()) { return; } ___v5795186++; if (___v5795186 % 100 == 0) { await QB.autoLimit(); }
indent = 0;
tempIndent = 0;
var l = ''; /* STRING */
l = (QB.func__Trim( QB.arrayValue(lines, [ i]).value .text));
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var c = 0; /* INTEGER */
c = (await func_SLSplit( l, parts , True));
if ( c < 1) {
continue;
}
if ( PrintTokenizedLine) {
await sub_AddJSLine( 0, "//// " + (await func_Join( parts , 1, - 1, "|")));
}
var js = ''; /* STRING */
js = "";
var first = ''; /* STRING */
first = (QB.func_UCase( QB.arrayValue(parts, [ 1]).value));
if ( jsMode == True) {
if ( first == "$END" ) {
jsMode = False;
await sub_AddJSLine( 0, "//-------- END JS native code block --------");
} else {
await sub_AddJSLine( i, QB.arrayValue(lines, [ i]).value .text);
}
} else if ( typeMode == True) {
if ( first == "END" ) {
var second = ''; /* STRING */
second = (QB.func_UCase( QB.arrayValue(parts, [ 2]).value));
if ( second == "TYPE" ) {
typeMode = False;
}
} else {
var tvar = {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}; /* VARIABLE */
tvar.typeId = currType;
tvar.name = QB.arrayValue(parts, [ 1]).value;
tvar.type = (QB.func_UCase( QB.arrayValue(parts, [ 3]).value));
if ( tvar.type == "_UNSIGNED" ) {
tvar.type = tvar.type + " " + (QB.func_UCase( QB.arrayValue(parts, [ 4]).value));
}
await sub_AddVariable( tvar, typeVars);
}
} else {
if ( first == "CONST" ) {
var constParts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var constCount = 0; /* INTEGER */
constCount = (await func_ListSplit( (await func_Join( parts , 2, - 1, " ")) , constParts));
var constIdx = 0; /* INTEGER */
var ___v2895625 = 0; for ( constIdx= 1; constIdx <= constCount; constIdx= constIdx + 1) { if (QB.halted()) { return; } ___v2895625++; if (___v2895625 % 100 == 0) { await QB.autoLimit(); }
var eqi = 0; /* INTEGER */
eqi = (QB.func_InStr( QB.arrayValue(constParts, [ constIdx]).value , "="));
if ( eqi < 1) {
await sub_AddWarning( i, "Invalid Const syntax: [" + QB.arrayValue(constParts, [ constIdx]).value + "]");
} else {
var cleft = ''; /* STRING */ var cright = ''; /* STRING */
cleft = (QB.func_Left( QB.arrayValue(constParts, [ constIdx]).value , eqi - 1));
cright = (QB.func_Mid( QB.arrayValue(constParts, [ constIdx]).value , eqi + 1));
js = js + "const " + cleft + " = " + (await func_ConvertExpression( cright, i)) + "; ";
await sub_AddConst( cleft);
}
}
} else if ( first == "DIM" || first == "REDIM" || first == "STATIC" ) {
js = (await func_DeclareVar( parts , i));
} else if ( first == "SELECT" ) {
caseVar = await func_GenJSVar();
js = "var " + caseVar + " = " + (await func_ConvertExpression( (await func_Join( parts , 3, - 1, " ")) , i)) + "; ";
js = js + "switch (" + caseVar + ") {";
indent = 1;
caseCount = 0;
} else if ( first == "CASE" ) {
if ( caseCount > 0) {
js = "break; ";
}
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "ELSE" ) {
js = js + "default:";
} else if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "IS" ) {
js = js + "case " + caseVar + " " + (await func_ConvertExpression( (await func_Join( parts , 3, - 1, " ")) , i)) + ":";
} else {
var caseParts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var cscount = 0; /* INTEGER */
cscount = (await func_ListSplit( (await func_Join( parts , 2, - 1, " ")) , caseParts));
var ci = 0; /* INTEGER */
var ___v3019480 = 0; for ( ci= 1; ci <= cscount; ci= ci + 1) { if (QB.halted()) { return; } ___v3019480++; if (___v3019480 % 100 == 0) { await QB.autoLimit(); }
js = js + "case " + (await func_ConvertExpression( QB.arrayValue(caseParts, [ ci]).value , i)) + ": ";
}
}
caseCount = caseCount + 1;
} else if ( first == "FOR" ) {
var fstep = ''; /* STRING */
fstep = "1";
var eqIdx = 0; /* INTEGER */
var toIdx = 0; /* INTEGER */
var stepIdx = 0; /* INTEGER */
var fcond = ''; /* STRING */
fcond = " <= ";
stepIdx = 0;
var fi = 0; /* INTEGER */
var ___v7747401 = 0; for ( fi= 2; fi <= (QB.func_UBound( parts)); fi= fi + 1) { if (QB.halted()) { return; } ___v7747401++; if (___v7747401 % 100 == 0) { await QB.autoLimit(); }
var fword = ''; /* STRING */
fword = (QB.func_UCase( QB.arrayValue(parts, [ fi]).value));
if ( fword == "=" ) {
eqIdx = fi;
} else if ( fword == "TO" ) {
toIdx = fi;
} else if ( fword == "STEP" ) {
stepIdx = fi;
fstep = (await func_ConvertExpression( (await func_Join( parts , fi + 1, - 1, " ")) , i));
}
}
var fvar = ''; /* STRING */
fvar = (await func_ConvertExpression( (await func_Join( parts , 2, eqIdx - 1, " ")) , i));
var sval = ''; /* STRING */
sval = (await func_ConvertExpression( (await func_Join( parts , eqIdx + 1, toIdx - 1, " ")) , i));
var uval = ''; /* STRING */
uval = (await func_ConvertExpression( (await func_Join( parts , toIdx + 1, stepIdx - 1, " ")) , i));
if ((QB.func_Left( (QB.func__Trim( fstep)) , 1)) == "-" ) {
fcond = " >= ";
}
loopIndex = await func_GenJSVar();
js = "var " + loopIndex + " = 0;";
js = js + " for (" + fvar + "=" + sval + "; " + fvar + fcond + uval + "; " + fvar + "=" + fvar + " + " + fstep + ") {";
js = js + " if (QB.halted()) { return; } ";
js = js + loopIndex + "++; ";
js = js + " if (" + loopIndex + " % 100 == 0) { await QB.autoLimit(); }";
indent = 1;
} else if ( first == "IF" ) {
var thenIndex = 0; /* INTEGER */
var ___v140176 = 0; for ( thenIndex= 2; thenIndex <= (QB.func_UBound( parts)); thenIndex= thenIndex + 1) { if (QB.halted()) { return; } ___v140176++; if (___v140176 % 100 == 0) { await QB.autoLimit(); }
if ((QB.func_UCase( QB.arrayValue(parts, [ thenIndex]).value)) == "THEN" ) {
break;
}
}
js = "if (" + (await func_ConvertExpression( (await func_Join( parts , 2, thenIndex - 1, " ")) , i)) + ") {";
indent = 1;
} else if ( first == "ELSEIF" ) {
js = "} else if (" + (await func_ConvertExpression( (await func_Join( parts , 2, (QB.func_UBound( parts)) - 1, " ")) , i)) + ") {";
tempIndent = - 1;
} else if ( first == "ELSE" ) {
js = "} else {";
tempIndent = - 1;
} else if ( first == "NEXT" ) {
if ( c > 1) {
var nparts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var npcount = 0; /* INTEGER */
var npi = 0; /* INTEGER */
npcount = (await func_ListSplit( (await func_Join( parts , 2, - 1, " ")) , nparts));
var ___v7607236 = 0; for ( npi= 1; npi <= npcount; npi= npi + 1) { if (QB.halted()) { return; } ___v7607236++; if (___v7607236 % 100 == 0) { await QB.autoLimit(); }
js = js + "} ";
indent = indent - 1;
}
} else {
js = js + "}";
indent = - 1;
}
} else if ( first == "END" ) {
if ((QB.func_UBound( parts)) == 1) {
js = "QB.halt(); return;";
} else {
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "SELECT" ) {
js = "break;";
}
js = js + "}";
indent = - 1;
}
} else if ( first == "SYSTEM" ) {
js = "QB.halt(); return;";
} else if ( first == "$IF" ) {
if ((QB.func_UBound( parts)) > 1) {
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "JAVASCRIPT" ) {
jsMode = True;
js = "//-------- BEGIN JS native code block --------";
}
}
} else if ( first == "DO" ) {
loopLevel = loopLevel + 1;
loopIndex = await func_GenJSVar();
js = "var " + loopIndex + " = 0;";
if ((QB.func_UBound( parts)) > 1) {
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "WHILE" ) {
js = js + " while (" + (await func_ConvertExpression( (await func_Join( parts , 3, - 1, " ")) , i)) + ") {";
} else {
js = js + " while (!(" + (await func_ConvertExpression( (await func_Join( parts , 3, - 1, " ")) , i)) + ")) {";
}
QB.arrayValue(loopMode, [ loopLevel]).value = 1;
} else {
js = js + " do {";
QB.arrayValue(loopMode, [ loopLevel]).value = 2;
}
indent = 1;
js = js + " if (QB.halted()) { return; }";
js = js + loopIndex + "++; ";
js = js + " if (" + loopIndex + " % 100 == 0) { await QB.autoLimit(); }";
} else if ( first == "WHILE" ) {
loopLevel = loopLevel + 1;
loopIndex = await func_GenJSVar();
js = "var " + loopIndex + " = 0;";
js = js + " while (" + (await func_ConvertExpression( (await func_Join( parts , 2, - 1, " ")) , i)) + ") {";
js = js + " if (QB.halted()) { return; }";
js = js + loopIndex + "++; ";
js = js + " if (" + loopIndex + " % 100 == 0) { await QB.autoLimit(); }";
indent = 1;
} else if ( first == "WEND" ) {
js = "}";
loopLevel = loopLevel - 1;
indent = - 1;
} else if ( first == "LOOP" ) {
if (QB.arrayValue(loopMode, [ loopLevel]).value == 1) {
js = "}";
} else {
js = "} while ((";
if ((QB.func_UBound( parts)) < 2) {
js = js + "1));";
} else {
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "UNTIL" ) {
js = "} while (!(";
}
js = js + (await func_ConvertExpression( (await func_Join( parts , 3, (QB.func_UBound( parts)) , " ")) , i)) + "))";
}
}
loopLevel = loopLevel - 1;
indent = - 1;
} else if ( first == "_CONTINUE" ) {
js = "continue;";
} else if ((QB.func_UCase( l)) == "EXIT FUNCTION" ) {
js = "return " + functionName + ";";
} else if ((QB.func_UCase( l)) == "EXIT SUB" ) {
js = "return;";
} else if ( first == "EXIT" ) {
js = "break;";
} else if ( first == "TYPE" ) {
typeMode = True;
var qbtype = {line:0,name:'',argc:0,args:''}; /* QBTYPE */
qbtype.line = i;
qbtype.name = (QB.func_UCase( QB.arrayValue(parts, [ 2]).value));
await sub_AddType( qbtype);
currType = (QB.func_UBound( types));
} else if ( first == "EXPORT" ) {
if ( c > 1) {
var exparts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var excount = 0; /* INTEGER */
excount = (await func_ListSplit( (await func_Join( parts , 2, - 1, " ")) , exparts));
var exi = 0; /* INTEGER */
var ___v8144900 = 0; for ( exi= 1; exi <= excount; exi= exi + 1) { if (QB.halted()) { return; } ___v8144900++; if (___v8144900 % 100 == 0) { await QB.autoLimit(); }
await sub_ParseExport( QB.arrayValue(exparts, [ exi]).value , i);
}
continue;
} else {
}
} else if ( first == "CALL" ) {
var subline = ''; /* STRING */
subline = (QB.func__Trim( (await func_Join( parts , 2, - 1, " "))));
var subend = 0; /* INTEGER */
subend = (QB.func_InStr( subline, "("));
var subname = ''; /* STRING */
if ( subend == 0) {
subname = subline;
} else {
subname = (QB.func_Left( subline, subend - 1));
}
if ((await func_FindMethod( subname, m, "SUB")) ) {
var subargs = ''; /* STRING */
if ( subname == subline) {
subargs = "";
} else {
subargs = (QB.func_Mid( subline, (QB.func_Len( subname)) + 2, (QB.func_Len( subline)) - (QB.func_Len( subname)) - 2));
}
js = (await func_ConvertSub( m, subargs, i));
} else {
await sub_AddWarning( i, "Missing Sub [" + subname + "], ignoring Call command");
}
} else if ( c > 2 || first == "LET" ) {
var assignment = 0; /* INTEGER */
assignment = 0;
var j = 0; /* INTEGER */
var ___v7090379 = 0; for ( j= 1; j <= (QB.func_UBound( parts)); j= j + 1) { if (QB.halted()) { return; } ___v7090379++; if (___v7090379 % 100 == 0) { await QB.autoLimit(); }
if (QB.arrayValue(parts, [ j]).value == "=" ) {
assignment = j;
break;
}
}
var asnVarIndex = 0; /* SINGLE */
asnVarIndex = 1;
if ( first == "LET" ) {
asnVarIndex = 2;
}
if ( assignment > 0) {
js = (await func_RemoveSuffix( (await func_ConvertExpression( (await func_Join( parts , asnVarIndex, assignment - 1, " ")) , i)))) + " = " + (await func_ConvertExpression( (await func_Join( parts , assignment + 1, - 1, " ")) , i)) + ";";
} else {
if ((await func_FindMethod( QB.arrayValue(parts, [ 1]).value , m, "SUB")) ) {
js = (await func_ConvertSub( m, (await func_Join( parts , 2, - 1, " ")) , i));
} else {
js = "// " + l;
await sub_AddWarning( i, "Missing or unsupported method: '" + QB.arrayValue(parts, [ 1]).value + "' - ignoring line");
}
}
} else {
if ((await func_FindMethod( QB.arrayValue(parts, [ 1]).value , m, "SUB")) ) {
js = (await func_ConvertSub( m, (await func_Join( parts , 2, - 1, " ")) , i));
} else {
js = "// " + l;
if ( first == "GOTO" ) {
await sub_AddWarning( i, "Missing or unsupported method: '<a href='https://xkcd.com/292/' target='_blank'>GOTO</a>'");
} else {
await sub_AddWarning( i, "Missing or unsupported method: '" + QB.arrayValue(parts, [ 1]).value + "' - ignoring line");
}
}
}
if (( indent < 0) ) {
totalIndent = totalIndent + indent;
}
await sub_AddJSLine( i, (await func_LPad( "" , " " , ( totalIndent + tempIndent) * 3)) + js);
if (( indent > 0) ) {
totalIndent = totalIndent + indent;
}
}
}
}
async function sub_ParseExport(s/*STRING*/,lineIndex/*INTEGER*/) {
if (QB.halted()) { return; }
var exportedItem = ''; /* STRING */
var ef = {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}; /* METHOD */
var es = {line:0,type:'',returnType:'',name:'',uname:'',argc:0,args:'',jsname:'',sync:0}; /* METHOD */
var ev = {type:'',name:'',jsname:'',isConst:0,isArray:0,arraySize:0,typeId:0}; /* VARIABLE */
var exportName = ''; /* STRING */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var found = 0; /* INTEGER */
found = False;
var c = 0; /* INTEGER */
c = (await func_SLSplit( s, parts , False));
if ((await func_FindMethod( QB.arrayValue(parts, [ 1]).value , es, "SUB")) ) {
if ( c > 2) {
exportName = QB.arrayValue(parts, [ 3]).value;
} else {
exportName = QB.arrayValue(parts, [ 1]).value;
}
exportedItem = es.jsname;
es.name = exportName;
await sub_AddExportMethod( es, currentModule + "." , True);
exportName = "sub_" + exportName;
await sub_RegisterExport( exportName, exportedItem);
found = True;
}
if ((await func_FindMethod( QB.arrayValue(parts, [ 1]).value , ef, "FUNCTION")) ) {
if ( c > 2) {
exportName = QB.arrayValue(parts, [ 3]).value;
} else {
exportName = QB.arrayValue(parts, [ 1]).value;
}
exportedItem = ef.jsname;
ef.name = exportName;
await sub_AddExportMethod( ef, currentModule + "." , True);
exportName = "func_" + exportName;
await sub_RegisterExport( exportName, exportedItem);
found = True;
}
if ((await func_FindVariable( QB.arrayValue(parts, [ 1]).value , ev, False)) ) {
if ( ev.isConst == True) {
if ( c > 2) {
exportName = QB.arrayValue(parts, [ 3]).value;
} else {
exportName = QB.arrayValue(parts, [ 1]).value;
}
exportedItem = ev.jsname;
ev.name = exportName;
exportedItem = ev.jsname;
if ( exportName == "" ) {
exportName = QB.arrayValue(parts, [ 1]).value;
}
ev.name = exportName;
await sub_AddExportConst( currentModule + "." + exportName);
await sub_RegisterExport( exportName, exportedItem);
found = True;
}
}
if (! found) {
await sub_AddWarning( lineIndex, "Invalid export [" + QB.arrayValue(parts, [ 1]).value + "]. Exported items must be a Sub, Function or Const in the current module.");
}
}
async function sub_RegisterExport(exportName/*STRING*/,exportedItem/*STRING*/) {
if (QB.halted()) { return; }
var esize = 0; /* SINGLE */
esize = (QB.func_UBound( exportLines)) + 1;
QB.resizeArray(exportLines, [{l:1,u:esize}], '', true); /* STRING */
QB.arrayValue(exportLines, [ esize]).value = "this." + exportName + " = " + exportedItem + ";";
}
async function func_ConvertSub(m/*METHOD*/,args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertSub = null;
var js = ''; /* STRING */
if ( m.name == "Line" ) {
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var plen = 0; /* INTEGER */
plen = (await func_SLSplit( args, parts , False));
if ( plen > 0) {
if ((QB.func_UCase( QB.arrayValue(parts, [ 1]).value)) == "INPUT" ) {
m.name = "Line Input";
m.jsname = "QB.sub_LineInput";
args = (await func_Join( parts , 2, - 1, " "));
}
}
}
if ( m.name == "Line" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertLine( args, lineNumber)) + ");";
} else if ( m.name == "Cls" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertCls( args, lineNumber)) + ");";
} else if ( m.name == "Input" || m.name == "Line Input" ) {
js = (await func_ConvertInput( m, args, lineNumber));
} else if ( m.name == "PSet" || m.name == "Circle" || m.name == "PReset" || m.name == "Paint" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertPSet( args, lineNumber)) + ");";
} else if ( m.name == "Print" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertPrint( args, lineNumber)) + ");";
} else if ( m.name == "Randomize" ) {
js = (await func_ConvertRandomize( m, args, lineNumber));
} else if ( m.name == "Read" ) {
js = (await func_ConvertRead( m, args, lineNumber));
} else if ( m.name == "Restore" ) {
js = (await func_CallMethod( m)) + "('" + (QB.func_UCase( args)) + "');";
} else if ( m.name == "Swap" ) {
js = (await func_ConvertSwap( m, args, lineNumber));
} else if ( m.name == "Window" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertWindow( args, lineNumber)) + ");";
} else if ( m.name == "_PrintString" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertPrintString( args, lineNumber)) + ");";
} else if ( m.name == "_PutImage" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertPutImage( args, lineNumber)) + ");";
} else if ( m.name == "_FullScreen" ) {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertFullScreen( args)) + ");";
} else {
js = (await func_CallMethod( m)) + "(" + (await func_ConvertMethodParams( args, lineNumber)) + ");";
}
ConvertSub = js;
return ConvertSub;
}
async function func_ConvertFullScreen(args/*STRING*/) {
if (QB.halted()) { return; }
var ConvertFullScreen = null;
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var argc = 0; /* INTEGER */
var mode = ''; /* STRING */
mode = "QB.STRETCH";
var doSmooth = ''; /* STRING */
doSmooth = "false";
argc = (await func_ListSplit( args, parts));
if ( argc > 0) {
var arg = ''; /* STRING */
arg = (QB.func_UCase( QB.arrayValue(parts, [ 1]).value));
if ( arg == "_OFF" ) {
mode = "QB.OFF";
} else if ( arg == "_STRETCH" ) {
mode = "QB.STRETCH";
} else if ( arg == "_SQUAREPIXELS" ) {
mode = "QB.SQUAREPIXELS";
}
}
if ( argc > 1) {
if ((QB.func_UCase( QB.arrayValue(parts, [ 2]).value)) == "_SMOOTH" ) {
doSmooth = "true";
}
}
ConvertFullScreen = mode + ", " + doSmooth;
return ConvertFullScreen;
}
async function func_ConvertLine(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertLine = null;
var argc = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var coord = ''; /* STRING */ var lcolor = ''; /* STRING */ var mode = ''; /* STRING */ var style = ''; /* STRING */
coord = (await func_ConvertCoordParam( "" , True, lineNumber));
lcolor = "undefined";
mode = "undefined";
style = "undefined";
argc = (await func_ListSplit( args, parts));
if ( argc >= 1) {
coord = (await func_ConvertCoordParam( QB.arrayValue(parts, [ 1]).value , True, lineNumber));
}
if ( argc >= 2) {
lcolor = (await func_ConvertExpression( QB.arrayValue(parts, [ 2]).value , lineNumber));
}
if ( argc >= 3) {
mode = "'" + (QB.func_UCase( (QB.func__Trim( QB.arrayValue(parts, [ 3]).value)))) + "'";
}
if ( argc >= 4) {
style = (await func_ConvertExpression( QB.arrayValue(parts, [ 4]).value , lineNumber));
}
ConvertLine = coord + ", " + lcolor + ", " + mode + ", " + style;
return ConvertLine;
}
async function func_ConvertPutImage(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertPutImage = null;
var argc = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var startCoord = ''; /* STRING */ var sourceImage = ''; /* STRING */ var destImage = ''; /* STRING */ var destCoord = ''; /* STRING */ var doSmooth = ''; /* STRING */
startCoord = (await func_ConvertCoordParam( "" , True, lineNumber));
destCoord = (await func_ConvertCoordParam( "" , True, lineNumber));
sourceImage = "undefined";
destImage = "undefined";
doSmooth = "false";
if ((await func_EndsWith( (QB.func__Trim( (QB.func_UCase( args)))) , "_SMOOTH")) ) {
doSmooth = "true";
args = (QB.func_Left( (QB.func__Trim( args)) , (QB.func_Len( (QB.func__Trim( args)))) - 7));
}
argc = (await func_ListSplit( args, parts));
if ( argc >= 1) {
startCoord = (await func_ConvertCoordParam( QB.arrayValue(parts, [ 1]).value , True, lineNumber));
}
if ( argc >= 2) {
sourceImage = (await func_ConvertExpression( QB.arrayValue(parts, [ 2]).value , lineNumber));
}
if ( argc >= 3) {
if ((QB.func__Trim( QB.arrayValue(parts, [ 3]).value)) != "" ) {
destImage = (await func_ConvertExpression( QB.arrayValue(parts, [ 3]).value , lineNumber));
}
}
if ( argc >= 4) {
destCoord = (await func_ConvertCoordParam( QB.arrayValue(parts, [ 4]).value , True, lineNumber));
}
if ( argc >= 5) {
if ((QB.func__Trim( (QB.func_UCase( QB.arrayValue(parts, [ 5]).value)))) == "_SMOOTH" ) {
doSmooth = "true";
}
}
ConvertPutImage = startCoord + ", " + sourceImage + ", " + destImage + ", " + destCoord + ", " + doSmooth;
return ConvertPutImage;
}
async function func_ConvertWindow(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertWindow = null;
var invertFlag = ''; /* STRING */
var firstParam = ''; /* STRING */
var theRest = ''; /* STRING */
var idx = 0; /* INTEGER */
var sstep = ''; /* STRING */
var estep = ''; /* STRING */
invertFlag = "false";
var kwd = ''; /* STRING */
kwd = "SCREEN";
if (((QB.func_UCase( (QB.func_Left( args, (QB.func_Len( kwd)))))) == kwd) ) {
args = (QB.func_Right( args, (QB.func_Len( args)) - (QB.func_Len( kwd))));
invertFlag = "true";
}
args = (QB.func__Trim( args));
sstep = "false";
estep = "false";
idx = (await func_FindParamChar( args, ","));
if ( idx == - 1) {
firstParam = args;
theRest = "";
} else {
firstParam = (QB.func_Left( args, idx - 1));
theRest = (QB.func_Right( args, (QB.func_Len( args)) - idx));
}
idx = (await func_FindParamChar( firstParam, "-"));
var startCord = ''; /* STRING */
var endCord = ''; /* STRING */
if ( idx == - 1) {
endCord = firstParam;
} else {
startCord = (QB.func_Left( firstParam, idx - 1));
endCord = (QB.func_Right( firstParam, (QB.func_Len( firstParam)) - idx));
}
idx = (QB.func_InStr( startCord, "("));
startCord = (QB.func_Right( startCord, (QB.func_Len( startCord)) - idx));
idx = (QB.func__InStrRev( startCord, ")"));
startCord = (QB.func_Left( startCord, idx - 1));
startCord = (await func_ConvertExpression( startCord, lineNumber));
if (((QB.func__Trim( startCord)) == "") ) {
startCord = "undefined, undefined";
}
idx = (QB.func_InStr( endCord, "("));
endCord = (QB.func_Right( endCord, (QB.func_Len( endCord)) - idx));
idx = (QB.func__InStrRev( endCord, ")"));
endCord = (QB.func_Left( endCord, idx - 1));
endCord = (await func_ConvertExpression( endCord, lineNumber));
ConvertWindow = invertFlag + ", " + startCord + ", " + endCord;
return ConvertWindow;
}
async function func_ConvertCls(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertCls = null;
var argc = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
argc = (await func_ListSplit( args, parts));
var method = ''; /* STRING */ var bgcolor = ''; /* STRING */
method = "undefined";
bgcolor = "undefined";
if ( argc >= 1) {
if ((QB.func__Trim( QB.arrayValue(parts, [ 1]).value)) != "" ) {
method = (await func_ConvertExpression( QB.arrayValue(parts, [ 1]).value , lineNumber));
}
}
if ( argc >= 2) {
bgcolor = (await func_ConvertExpression( QB.arrayValue(parts, [ 2]).value , lineNumber));
}
ConvertCls = method + ", " + bgcolor;
return ConvertCls;
}
async function func_ConvertRandomize(m/*METHOD*/,args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertRandomize = null;
var uusing = ''; /* STRING */
var theseed = ''; /* STRING */
uusing = "false";
theseed = args;
if ((QB.func__Trim( args)) == "" ) {
theseed = "undefined";
} else {
if (((QB.func_UCase( (QB.func__Trim( (QB.func_Left( args, 5)))))) == "USING") ) {
uusing = "true";
theseed = (QB.func__Trim( (QB.func_Right( args, (QB.func_Len( args)) - 5))));
}
theseed = (await func_ConvertExpression( theseed, lineNumber));
}
ConvertRandomize = (await func_CallMethod( m)) + "(" + uusing + ", " + theseed + ")";
return ConvertRandomize;
}
async function func_ConvertRead(m/*METHOD*/,args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertRead = null;
var js = ''; /* STRING */
var vname = ''; /* STRING */
var pcount = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var vars = QB.initArray([{l:1,u:0}], ''); /* STRING */
var vcount = 0; /* INTEGER */
var p = ''; /* STRING */
pcount = (await func_ListSplit( args, parts));
var i = 0; /* INTEGER */
var ___v453528 = 0; for ( i= 1; i <= pcount; i= i + 1) { if (QB.halted()) { return; } ___v453528++; if (___v453528 % 100 == 0) { await QB.autoLimit(); }
p = (QB.func__Trim( QB.arrayValue(parts, [ i]).value));
vcount = (QB.func_UBound( vars)) + 1;
QB.resizeArray(vars, [{l:1,u:vcount}], '', true); /* STRING */
QB.arrayValue(vars, [ vcount]).value = p;
}
vname = await func_GenJSVar();
js = "var " + vname + " = new Array(" + (QB.func_Str( (QB.func_UBound( vars)))) + "); ";
js = js + (await func_CallMethod( m)) + "(" + vname + "); ";
var ___v4140327 = 0; for ( i= 1; i <= (QB.func_UBound( vars)); i= i + 1) { if (QB.halted()) { return; } ___v4140327++; if (___v4140327 % 100 == 0) { await QB.autoLimit(); }
js = js + (await func_ConvertExpression( QB.arrayValue(vars, [ i]).value , lineNumber)) + " = " + vname + "[" + (QB.func_Str( i - 1)) + "]; ";
}
ConvertRead = js;
return ConvertRead;
}
async function func_ConvertCoordParam(param/*STRING*/,hasEndCoord/*INTEGER*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertCoordParam = null;
if ((QB.func__Trim( param)) == "" ) {
if ( hasEndCoord) {
ConvertCoordParam = "false, undefined, undefined, false, undefined, undefined";
} else {
ConvertCoordParam = "false, undefined, undefined";
}
} else {
var js = ''; /* STRING */ var startCoord = ''; /* STRING */ var endCoord = ''; /* STRING */ var sstep = ''; /* STRING */ var estep = ''; /* STRING */
var idx = 0; /* INTEGER */
sstep = "false";
estep = "false";
idx = (await func_FindParamChar( param, "-"));
if ( idx == - 1) {
startCoord = param;
endCoord = "";
} else {
startCoord = (QB.func_Left( param, idx - 1));
endCoord = (QB.func_Right( param, (QB.func_Len( param)) - idx));
}
if ((QB.func_UCase( (QB.func_Left( (QB.func__Trim( startCoord)) , 4)))) == "STEP" ) {
sstep = "true";
}
if ((QB.func_UCase( (QB.func_Left( (QB.func__Trim( endCoord)) , 4)))) == "STEP" ) {
estep = "true";
}
idx = (QB.func_InStr( startCoord, "("));
startCoord = (QB.func_Right( startCoord, (QB.func_Len( startCoord)) - idx));
idx = (QB.func__InStrRev( startCoord, ")"));
startCoord = (QB.func_Left( startCoord, idx - 1));
startCoord = (await func_ConvertExpression( startCoord, lineNumber));
if (((QB.func__Trim( startCoord)) == "") ) {
startCoord = "undefined, undefined";
}
if ( hasEndCoord) {
idx = (QB.func_InStr( endCoord, "("));
endCoord = (QB.func_Right( endCoord, (QB.func_Len( endCoord)) - idx));
idx = (QB.func__InStrRev( endCoord, ")"));
endCoord = (QB.func_Left( endCoord, idx - 1));
endCoord = (await func_ConvertExpression( endCoord, lineNumber));
if (((QB.func__Trim( endCoord)) == "") ) {
endCoord = "undefined, undefined";
}
ConvertCoordParam = sstep + ", " + startCoord + ", " + estep + ", " + endCoord;
} else {
ConvertCoordParam = sstep + ", " + startCoord;
}
}
return ConvertCoordParam;
}
async function func_ConvertPSet(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertPSet = null;
var firstParam = ''; /* STRING */
var theRest = ''; /* STRING */
var idx = 0; /* INTEGER */
var sstep = ''; /* STRING */
sstep = "false";
idx = (await func_FindParamChar( args, ","));
if ( idx == - 1) {
firstParam = args;
theRest = "";
} else {
firstParam = (QB.func_Left( args, idx - 1));
theRest = (QB.func_Right( args, (QB.func_Len( args)) - idx));
}
if ((QB.func_UCase( (QB.func__Trim( (QB.func_Left( firstParam, 4)))))) == "STEP" ) {
sstep = "true";
}
idx = (QB.func_InStr( firstParam, "("));
firstParam = (QB.func_Right( firstParam, (QB.func_Len( firstParam)) - idx));
idx = (QB.func__InStrRev( firstParam, ")"));
firstParam = (QB.func_Left( firstParam, idx - 1));
firstParam = (await func_ConvertExpression( firstParam, lineNumber));
if (((QB.func__Trim( firstParam)) == "") ) {
firstParam = "undefined, undefined";
}
theRest = (await func_ConvertExpression( theRest, lineNumber));
ConvertPSet = sstep + ", " + firstParam + ", " + theRest;
return ConvertPSet;
}
async function func_ConvertPrint(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertPrint = null;
var pcount = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
pcount = (await func_PrintSplit( args, parts));
var js = ''; /* STRING */
js = "[";
var i = 0; /* INTEGER */
var ___v8626193 = 0; for ( i= 1; i <= pcount; i= i + 1) { if (QB.halted()) { return; } ___v8626193++; if (___v8626193 % 100 == 0) { await QB.autoLimit(); }
if ( i > 1) {
js = js + ",";
}
if (QB.arrayValue(parts, [ i]).value == "," ) {
js = js + "QB.COLUMN_ADVANCE";
} else if (QB.arrayValue(parts, [ i]).value == ";" ) {
js = js + "QB.PREVENT_NEWLINE";
} else {
js = js + (await func_ConvertExpression( QB.arrayValue(parts, [ i]).value , lineNumber));
}
}
ConvertPrint = js + "]";
return ConvertPrint;
}
async function func_ConvertPrintString(args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertPrintString = null;
var firstParam = ''; /* STRING */
var theRest = ''; /* STRING */
var idx = 0; /* INTEGER */
idx = (await func_FindParamChar( args, ","));
if ( idx == - 1) {
firstParam = args;
theRest = "";
} else {
firstParam = (QB.func_Left( args, idx - 1));
theRest = (QB.func_Right( args, (QB.func_Len( args)) - idx));
}
idx = (QB.func_InStr( firstParam, "("));
firstParam = (QB.func_Right( firstParam, (QB.func_Len( firstParam)) - idx));
idx = (QB.func__InStrRev( firstParam, ")"));
firstParam = (QB.func_Left( firstParam, idx - 1));
ConvertPrintString = (await func_ConvertExpression( firstParam, lineNumber)) + ", " + (await func_ConvertExpression( theRest, lineNumber));
return ConvertPrintString;
}
async function func_ConvertInput(m/*METHOD*/,args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; }
var ConvertInput = null;
var js = ''; /* STRING */
var vname = ''; /* STRING */
var pcount = 0; /* INTEGER */
var parts = QB.initArray([{l:1,u:0}], ''); /* STRING */
var vars = QB.initArray([{l:1,u:0}], ''); /* STRING */
var varIndex = 0; /* INTEGER */
varIndex = 1;
var preventNewline = ''; /* STRING */
preventNewline = "false";
var addQuestionPrompt = ''; /* STRING */
addQuestionPrompt = "false";
var prompt = ''; /* STRING */
prompt = "undefined";
var vcount = 0; /* INTEGER */
var p = ''; /* STRING */
pcount = (await func_PrintSplit( args, parts));
var i = 0; /* INTEGER */
var ___v7904800 = 0; for ( i= 1; i <= pcount; i= i + 1) { if (QB.halted()) { return; } ___v7904800++; if (___v7904800 % 100 == 0) { await QB.autoLimit(); }
p = (QB.func__Trim( QB.arrayValue(parts, [ i]).value));
if ( p == ";" ) {
if ( i == 1) {
preventNewline = "true";
} else {
addQuestionPrompt = "true";
}
} else if ((await func_StartsWith( p, (QB.func_Chr( 34)))) ) {
prompt = p;
} else if ( p != "," ) {
vcount = (QB.func_UBound( vars)) + 1;
QB.resizeArray(vars, [{l:1,u:vcount}], '', true); /* STRING */
QB.arrayValue(vars, [ vcount]).value = p;
}
}
vname = await func_GenJSVar();
js = "var " + vname + " = new Array(" + (QB.func_Str( (QB.func_UBound( vars)))) + "); ";
js = js + (await func_CallMethod( m)) + "(" + vname + ", " + preventNewline + ", " + addQuestionPrompt + ", " + prompt + "); ";
var ___v3735362 = 0; for ( i= 1; i <= (QB.func_UBound( vars)); i= i + 1) { if (QB.halted()) { return; } ___v3735362++; if (___v3735362 % 100 == 0) { await QB.autoLimit(); }
if (!(await func_StartsWith( (QB.func__Trim( QB.arrayValue(vars, [ i]).value)) , "#")) ) {
js = js + (await func_ConvertExpression( QB.arrayValue(vars, [ i]).value , lineNumber)) + " = " + vname + "[" + (QB.func_Str( i - 1)) + "]; ";