-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit1.pas
3857 lines (3422 loc) · 107 KB
/
unit1.pas
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
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
LCLType, Grids, StdCtrls, EditBtn, IniFiles, process, Math, Clipbrd, Menus,
Buttons, Spin, ButtonPanel, fileinfo, Types, TypInfo, DateUtils, FileUtil,
lclintf, LCLTranslator,
RichMemo, UBigFloatV3, MD5, sha1,
uPSComponent, uPSComponent_Default, uPSComponent_COM, uPSComponent_Forms,
uPSComponent_Controls, uPSComponent_StdCtrls,
SynEdit, SynHighlighterPython, SynHighlighterCpp, SynHighlighterPas;
const
GITHUB_URL = 'https://github.com/shaoziyang/CalcToolbox2';
GITEE_URL = 'https://gitee.com/shaoziyang/CalcToolbox2';
VERSION = '2.0.0.0';
{$ifdef Windows}
MICROPYTHON_BIN_NAME = 'interpreter\micropython\micropython.exe';
PATHSEP = '\';
{$else}
{$ifdef Linux}
MICROPYTHON_BIN_NAME = 'interpreter/micropython/micropython';
PATHSEP = '/';
{$endif}
{$endif}
TimeBetweenLineOffset = 13;
{$I NewFileTemplate.pas}
ScriptName: array of string = ('LittleC', 'graph', 'micropython', 'pascal');
ScriptSym: array of string = ('LittleC', 'Graph', 'MPY', 'Pascal');
type
{ TfrmMain }
TfrmMain = class(TForm)
ApplicationProperties: TApplicationProperties;
btnScriptCaret_LittleC: TToolButton;
btnScriptCaret_Graph: TToolButton;
btnScriptCaret_MPY: TToolButton;
btnScriptCaret_Pascal: TToolButton;
btnScriptClear_LittleC: TToolButton;
btnScriptClear_Graph: TToolButton;
btnScriptClear_MPY: TToolButton;
btnScriptClear_Pascal: TToolButton;
btnScriptCmd_MPY: TToolButton;
btnCrcCalc: TBitBtn;
btnCrcXOR: TBitBtn;
btnCrcSUM16: TBitBtn;
btnCrcSUM8: TBitBtn;
btnCrc_CRC16_CCITT: TToolButton;
btnCrc_CRC16_CCITT_FALSE: TToolButton;
btnCrc_CRC16_DNP: TToolButton;
btnCrc_CRC16_IBM: TToolButton;
btnCrc_CRC16_MAXIM: TToolButton;
btnCrc_CRC16_MODBUS: TToolButton;
btnCrc_CRC16_USB: TToolButton;
btnCrc_CRC16_X25: TToolButton;
btnCrc_CRC16_XMODEM: TToolButton;
btnCrc_CRC32: TToolButton;
btnCrc_CRC32_MPEG2: TToolButton;
btnCrc_CRC32_JAMCRC: TToolButton;
btnCrc_CRC4_ITU: TToolButton;
btnCrc_CRC5_EPC: TToolButton;
btnCrc_CRC5_ITU: TToolButton;
btnCrc_CRC5_USB: TToolButton;
btnCrc_CRC6_ITU: TToolButton;
btnCrc_CRC7_MMC: TToolButton;
btnCrc_CRC8: TToolButton;
btnCrc_CRC8_ITU: TToolButton;
btnCrc_CRC8_MAXIM: TToolButton;
btnCrc_CRC8_ROHC: TToolButton;
btnScriptNew_LittleC: TToolButton;
btnScriptNew_Graph: TToolButton;
btnScriptNew_MPY: TToolButton;
btnScriptNew_Pascal: TToolButton;
ilBookmark1: TImageList;
ilBookmark3: TImageList;
ilBookmark4: TImageList;
ilBookmark2: TImageList;
lbOptionEditor: TLabel;
btnScriptOpen_LittleC: TToolButton;
btnScriptOpen_Graph: TToolButton;
btnScriptOpen_MPY: TToolButton;
btnScriptOpen_Pascal: TToolButton;
btnScriptPanelMode_LittleC: TToolButton;
btnScriptPanelMode_Graph: TToolButton;
btnScriptPanelMode_MPY: TToolButton;
btnScriptPanelMode_Pascal: TToolButton;
btnScriptRun_LittleC: TToolButton;
btnScriptRun_Graph: TToolButton;
btnScriptRun_MPY: TToolButton;
btnScriptRun_Pascal: TToolButton;
btnScriptSaveAs_LittleC: TToolButton;
btnScriptSaveAs_Graph: TToolButton;
btnScriptSaveas_MPY: TToolButton;
btnScriptSaveAs_Pascal: TToolButton;
btnScriptSavePic_Graph: TToolButton;
btnScriptSave_LittleC: TToolButton;
btnScriptSave_Graph: TToolButton;
btnScriptSave_MPY: TToolButton;
btnScriptSave_Pascal: TToolButton;
OpenGITEE: TSpeedButton;
OpenGITHUB: TSpeedButton;
Panel4: TPanel;
PSImport_ComObj: TPSImport_ComObj;
PSImport_Controls: TPSImport_Controls;
PSImport_DateUtils: TPSImport_DateUtils;
PSImport_Forms: TPSImport_Forms;
PSImport_StdCtrls: TPSImport_StdCtrls;
rmoAboutChangeLog: TRichMemo;
rmoAboutReadme: TRichMemo;
rmoAboutAddNew: TRichMemo;
scbOption3: TScrollBox;
ShowGear: TSpeedButton;
btnScriptShowGraphForm: TToolButton;
btnScriptStop_LittleC: TToolButton;
btnScriptStop_Graph: TToolButton;
btnScriptStop_MPY: TToolButton;
btnScriptStop_Pascal: TToolButton;
ButtonPanelOption: TButtonPanel;
chkOptionButtonFlatsytle: TCheckBox;
chkOptionTrayIcon: TCheckBox;
chkOptionErrlogEn: TCheckBox;
chkOptionRMCCopy: TCheckBox;
chkOptionTabAlternateColor: TCheckBox;
chkOptionTableFlatsytle: TCheckBox;
chkOptionCloseToTray: TCheckBox;
chkOptionMinimizeToTray: TCheckBox;
chkChecksumFileCRC32: TCheckBox;
chkChecksumFileMD5: TCheckBox;
chkChecksumFileSHA1: TCheckBox;
chkCrcHexMode: TCheckBox;
chkCrcInvIn: TCheckBox;
chkCrcInvOut: TCheckBox;
chkChecksumFileAutoVerify: TCheckBox;
chkChecksumFileAutosavetofile: TCheckBox;
cbbOptionLanguage: TComboBox;
btnOptionTabAlternateColor: TColorButton;
dlgOpen_Graph: TOpenDialog;
dlgOpen_LittleC: TOpenDialog;
dlgOpen_MPY: TOpenDialog;
dlgOpen_Pascal: TOpenDialog;
dlgSave_Graph: TSaveDialog;
dlgSave_LittleC: TSaveDialog;
dlgSave_MPY: TSaveDialog;
dlgSave_Pascal: TSaveDialog;
edtBaseCustom: TSpinEdit;
edtCalcExpr: TEditButton;
edtCrcHexResult: TEdit;
edtCrcInitV: TEdit;
edtCrcPolygon: TEdit;
edtCrcResult: TEdit;
edtCrcXOROUT: TEdit;
edtDecimalDigitsConvertTemperature: TSpinEdit;
dlgFont: TFontDialog;
edtOptionPythonPath: TFileNameEdit;
edtOptionLittleCPath: TFileNameEdit;
edtOptionMPYPath: TFileNameEdit;
gbOptionCalcInterpreter: TGroupBox;
gbOptionLittleC: TGroupBox;
ilICO: TImageList;
ilOption: TImageList;
ilTray: TImageList;
ilMain: TImageList;
ilConvert: TImageList;
imgLogo: TImage;
ilAbout: TImageList;
lbOptionLittleCBinFilePath: TLabel;
lbOptionMaxLineNumberOfScriptOutput: TLabel;
lbDecimalDigits: TLabel;
lbCalcExpression: TLabel;
lbCalcResult: TLabel;
lbConvertTimeDay: TLabel;
lbConvertTimeDaysBetween: TLabel;
lbConvertTimeHour: TLabel;
lbConvertTimeHoursBetween: TLabel;
lbConvertTimeMilliSecondsBetween: TLabel;
lbConvertTimeMinute: TLabel;
lbConvertTimeMinutesBetween: TLabel;
lbConvertTimeMonth: TLabel;
lbConvertTimeMonthsBetween: TLabel;
lbConvertTimeSecond: TLabel;
lbConvertTimeSecondsBetween: TLabel;
lbConvertTimeTimeBetween: TLabel;
lbConvertTimeValue: TLabel;
lbConvertTimeWeeksBetween: TLabel;
lbConvertTimeYear: TLabel;
lbConvertTimeHoursOfTheYear: TLabel;
lbConvertTimeMinutesOfTheDay: TLabel;
lbConvertTimeSecondsOfTheDay: TLabel;
lbConvertTimeSecondsOfTheMonth: TLabel;
lbConvertTimeMinutesOfTheMonth: TLabel;
lbConvertTimeHoursOfTheMonth: TLabel;
lbConvertTimeSecondsOfTheYear: TLabel;
lbConvertTimeMinutesOfTheYear: TLabel;
lbConvertTimeWeeksOfTheYear: TLabel;
lbConvertTimeDaysOfTheYear: TLabel;
lbConvertTimeYearsBetween: TLabel;
lbCalcVarAndFunc: TLabel;
dlgLoadCalcWorkspace: TOpenDialog;
lbAboutFreeware: TLabel;
lbDigitBaseBase: TLabel;
lbDigitBaseCustom: TLabel;
lbDigitBaseNumber: TLabel;
lbChecksumFiles: TLabel;
lbCrcHexResult: TLabel;
lbCrcDecimalResult: TLabel;
lbOptionInterpreter: TLabel;
lbOptionInterface: TLabel;
lbOptionGeneral: TLabel;
lbOptionLanguage: TLabel;
lbOptionFont: TLabel;
lbChecksumFileHint: TLabel;
lbChecksumFileDescription: TLabel;
lbName: TLabel;
lbTinyCWebSite1: TLabel;
lbTinyCWebSite2: TLabel;
lbVer: TLabel;
mmoScriptOut_LittleC: TMemo;
mmoScriptOut_Graph: TMemo;
mmoScriptOut_MPY: TMemo;
mmoScriptOut_Pascal: TMemo;
mmoOut_Temp: TMemo;
mmoTmp: TMemo;
miTrayExit: TMenuItem;
miTrayN1: TMenuItem;
miTrayOption: TMenuItem;
mmoCRC: TMemo;
mmoLicense: TMemo;
PageControl1: TPageControl;
pcConstant: TPageControl;
Panel2: TPanel;
pmScriptHis_LittleC: TPopupMenu;
pmScriptHis_Graph: TPopupMenu;
pmScriptHis_Pascal: TPopupMenu;
pmScriptNew_LittleC: TPopupMenu;
pmScriptNew_Graph: TPopupMenu;
pmScriptNew_Pascal: TPopupMenu;
pnlOptionTv: TPanel;
pnlBase: TPanel;
pnlCalcExpr: TPanel;
pnlConvertTime: TPanel;
pnlConvertTimeValue: TPanel;
pcConvert: TPageControl;
pnlAbout: TPanel;
Panel3: TPanel;
pnlOptionFontPreview: TPanel;
pcDigit: TPageControl;
pcScript: TPageControl;
pcMain: TPageControl;
pcChecksum: TPageControl;
Panel1: TPanel;
pmTray: TPopupMenu;
pmTrayShow: TMenuItem;
pnlCalcVar: TPanel;
pmHisCalc: TPopupMenu;
pmScriptHis_MPY: TPopupMenu;
pmScriptNew_MPY: TPopupMenu;
ProcessLittleC: TProcess;
ProcessMPY: TProcess;
ProcessPY: TProcess;
PSImport_Classes: TPSImport_Classes;
PSScript: TPSScript;
dlgSaveCalcWorkspace: TSaveDialog;
rbOptionCalcUseMPY: TRadioButton;
rbOptionCalcUsePython: TRadioButton;
rbCrc12bits: TRadioButton;
rbCrc16bits: TRadioButton;
rbCrc32bits: TRadioButton;
rbCrc4bits: TRadioButton;
rbCrc5bits: TRadioButton;
rbCrc6bits: TRadioButton;
rbCrc7bits: TRadioButton;
rbCrc8bits: TRadioButton;
scbOption0: TScrollBox;
scbOption1: TScrollBox;
scbOption2: TScrollBox;
sgBase: TStringGrid;
sgChecksumFile: TStringGrid;
btnOptionSelectFont: TSpeedButton;
btnCrcBufLen: TSpeedButton;
sgConvertTemperature: TStringGrid;
sgConvertTimeValue: TStringGrid;
edtOptionMaxLineNumberOfScriptOutput: TSpinEdit;
splScript_LittleC: TSplitter;
splScript_Graph: TSplitter;
Splitter1: TSplitter;
SplitterCalc: TSplitter;
sgCalcExpr: TStringGrid;
mmoCalcFunc: TSynEdit;
sgConvertTime: TStringGrid;
splScript_MPY: TSplitter;
splScript_Pascal: TSplitter;
sgOptionTableDemo: TStringGrid;
SynCppSyn: TSynCppSyn;
synEditScript_LittleC: TSynEdit;
synEditScript_Graph: TSynEdit;
synEditScript_MPY: TSynEdit;
synEditScript_Pascal: TSynEdit;
SynPasSyn: TSynPasSyn;
SynPythonSyn: TSynPythonSyn;
btnCalcWorkspaceName: TToolButton;
btnCalcClearHis: TToolButton;
tlbScript_LittleC: TToolBar;
ToolBar16: TToolBar;
ToolBar8: TToolBar;
tlbScript_MPY: TToolBar;
ToolButton17: TToolButton;
ToolButton28: TToolButton;
ToolButton30: TToolButton;
ToolButton32: TToolButton;
ToolButton33: TToolButton;
ToolButton34: TToolButton;
ToolButton35: TToolButton;
ToolButton38: TToolButton;
ToolButton40: TToolButton;
ToolButton42: TToolButton;
ToolButton43: TToolButton;
ToolButton44: TToolButton;
tsAboutChangelog: TTabSheet;
tsAboutLicense: TTabSheet;
tsAboutNote: TTabSheet;
TabSheet: TTabSheet;
tsAboutHelp: TTabSheet;
tsSolve: TTabSheet;
ToolBar7: TToolBar;
btnConvertTemperatureDecimalPlaces: TToolButton;
ToolButton1: TToolButton;
tsConvertTemperature: TTabSheet;
tsConvertTime: TTabSheet;
tvOption: TTreeView;
tsOption: TTabSheet;
TmrRun: TTimer;
ToolBar1: TToolBar;
ToolBar2: TToolBar;
ToolBar3: TToolBar;
tbChecksumCRCPoly: TToolBar;
ToolBar6: TToolBar;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
btnCrc_CRC8_CDMA2000: TToolButton;
btnCrc_CRC8_WCDMA: TToolButton;
btnCrc_CRC32_BZIP2: TToolButton;
btnCrc_CRC32_POSIX: TToolButton;
ToolButton15: TToolButton;
ToolButton16: TToolButton;
btnDigitBaseCustom: TToolButton;
ToolButton2: TToolButton;
ToolButton21: TToolButton;
btnCrcPolygon: TToolButton;
btnCrcInitV: TToolButton;
ToolButton5: TToolButton;
btnCrcXOROUT: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
tsDigitBigint: TTabSheet;
tsDigitBigfloat: TTabSheet;
tsScriptPascal: TTabSheet;
tsScriptMpy: TTabSheet;
tsScriptLittleC: TTabSheet;
tsScriptGraph: TTabSheet;
tsDigitBase: TTabSheet;
tmrICO: TTimer;
tbCalc: TToolBar;
btnCalcSave: TToolButton;
btnCalcSaveAs: TToolButton;
btnCalcOpen: TToolButton;
btnCalcNew: TToolButton;
TrayIcon: TTrayIcon;
tsAbout: TTabSheet;
tsChecksum: TTabSheet;
tsDigit: TTabSheet;
tsConvert: TTabSheet;
tsChecksumCrc: TTabSheet;
tsChecksumFile: TTabSheet;
tsCalc: TTabSheet;
tsScript: TTabSheet;
tsContant: TTabSheet;
procedure ApplicationPropertiesException(Sender: TObject; E: Exception);
procedure btnCalcClearHisClick(Sender: TObject);
procedure btnCalcNewClick(Sender: TObject);
procedure btnCalcOpenClick(Sender: TObject);
procedure btnCalcSaveAsClick(Sender: TObject);
procedure btnCalcSaveClick(Sender: TObject);
procedure btnCrcCalcClick(Sender: TObject);
procedure btnCrcSUM8Click(Sender: TObject);
procedure btnCrcXORClick(Sender: TObject);
procedure btnCrc_CRC16_CCITTClick(Sender: TObject);
procedure btnCrc_CRC16_CCITT_FALSEClick(Sender: TObject);
procedure btnCrc_CRC16_DNPClick(Sender: TObject);
procedure btnCrc_CRC16_IBMClick(Sender: TObject);
procedure btnCrc_CRC16_MAXIMClick(Sender: TObject);
procedure btnCrc_CRC16_MODBUSClick(Sender: TObject);
procedure btnCrc_CRC16_USBClick(Sender: TObject);
procedure btnCrc_CRC16_X25Click(Sender: TObject);
procedure btnCrc_CRC16_XMODEMClick(Sender: TObject);
procedure btnCrc_CRC32Click(Sender: TObject);
procedure btnCrc_CRC32_BZIP2Click(Sender: TObject);
procedure btnCrc_CRC32_JAMCRCClick(Sender: TObject);
procedure btnCrc_CRC32_MPEG2Click(Sender: TObject);
procedure btnCrc_CRC32_POSIXClick(Sender: TObject);
procedure btnCrc_CRC4_ITUClick(Sender: TObject);
procedure btnCrc_CRC5_EPCClick(Sender: TObject);
procedure btnCrc_CRC5_ITUClick(Sender: TObject);
procedure btnCrc_CRC5_USBClick(Sender: TObject);
procedure btnCrc_CRC6_ITUClick(Sender: TObject);
procedure btnCrc_CRC7_MMCClick(Sender: TObject);
procedure btnCrc_CRC8Click(Sender: TObject);
procedure btnCrc_CRC8_CDMA2000Click(Sender: TObject);
procedure btnCrc_CRC8_ITUClick(Sender: TObject);
procedure btnCrc_CRC8_MAXIMClick(Sender: TObject);
procedure btnCrc_CRC8_ROHCClick(Sender: TObject);
procedure btnCrc_CRC8_WCDMAClick(Sender: TObject);
procedure btnScriptRun_GraphClick(Sender: TObject);
procedure btnScriptRun_PascalClick(Sender: TObject);
procedure btnScriptStop_PascalClick(Sender: TObject);
procedure OpenGITEEClick(Sender: TObject);
procedure OpenGITHUBClick(Sender: TObject);
procedure btnOptionSelectFontClick(Sender: TObject);
procedure btnOptionTabAlternateColorColorChanged(Sender: TObject);
procedure btnScriptClear_GraphClick(Sender: TObject);
procedure btnScriptClear_LittleCClick(Sender: TObject);
procedure btnScriptClear_PascalClick(Sender: TObject);
procedure btnScriptNew_GraphClick(Sender: TObject);
procedure btnScriptNew_LittleCClick(Sender: TObject);
procedure btnScriptNew_PascalClick(Sender: TObject);
procedure btnScriptOpen_GraphClick(Sender: TObject);
procedure btnScriptOpen_LittleCClick(Sender: TObject);
procedure btnScriptOpen_PascalClick(Sender: TObject);
procedure btnScriptPanelMode_MPYClick(Sender: TObject);
procedure btnScriptClear_MPYClick(Sender: TObject);
procedure btnScriptCmd_MPYClick(Sender: TObject);
procedure btnScriptNew_MPYClick(Sender: TObject);
procedure btnScriptOpen_MPYClick(Sender: TObject);
procedure btnScriptRun_LittleCClick(Sender: TObject);
procedure btnScriptRun_MPYClick(Sender: TObject);
procedure btnScriptSaveAs_GraphClick(Sender: TObject);
procedure btnScriptSaveAs_LittleCClick(Sender: TObject);
procedure btnScriptSaveas_MPYClick(Sender: TObject);
procedure btnScriptSaveAs_PascalClick(Sender: TObject);
procedure btnScriptSave_GraphClick(Sender: TObject);
procedure btnScriptSave_LittleCClick(Sender: TObject);
procedure btnScriptSave_MPYClick(Sender: TObject);
procedure btnScriptSave_PascalClick(Sender: TObject);
procedure btnScriptStop_LittleCClick(Sender: TObject);
procedure btnScriptStop_MPYClick(Sender: TObject);
procedure chkChecksumFileCRC32Change(Sender: TObject);
procedure chkOptionButtonFlatsytleChange(Sender: TObject);
procedure chkOptionTableFlatsytleChange(Sender: TObject);
procedure edtBaseCustomChange(Sender: TObject);
procedure edtCalcExprButtonClick(Sender: TObject);
procedure edtCalcExprKeyDown(Sender: TObject; var Key: word;
Shift: TShiftState);
procedure edtCalcExprKeyPress(Sender: TObject; var Key: char);
procedure edtCrcHexResultClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of string);
procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: char);
procedure FormShow(Sender: TObject);
procedure FormWindowStateChange(Sender: TObject);
procedure gbOptionCalcInterpreterResize(Sender: TObject);
procedure lbTinyCWebSite2Click(Sender: TObject);
procedure miTrayExitClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure pcMainChange(Sender: TObject);
procedure pmScriptHis_LittleCPopup(Sender: TObject);
procedure pmScriptHis_MPYPopup(Sender: TObject);
procedure PSScriptCompile(Sender: TPSScript);
procedure sgBaseEditingDone(Sender: TObject);
procedure sgCalcExprKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
procedure sgCalcExprMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
procedure sgChecksumFileClick(Sender: TObject);
procedure sgChecksumFileHeaderSized(Sender: TObject; IsColumn: boolean;
Index: integer);
procedure sgConvertTimeButtonClick(Sender: TObject; aCol, aRow: integer);
procedure sgConvertTimeEditingDone(Sender: TObject);
procedure sgConvertTimeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
procedure sgOptionTableDemoClick(Sender: TObject);
procedure synEditScript_LittleCStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
procedure synEditScript_MPYStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
procedure synEditScript_PascalStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
procedure tmrICOTimer(Sender: TObject);
procedure TrayIconClick(Sender: TObject);
procedure tvOptionSelectionChanged(Sender: TObject);
private
CalcWorkspaceFileName: string;
procedure sgAddLine(var sg: TStringGrid; maxcount: integer = 200);
procedure sgScrollToLastLine(var sg: TStringGrid);
procedure SaveCalcWorkspace(filename: string);
procedure LoadCalcWorkspace(filename: string);
procedure pmAdd(var pm: TPopupMenu; filename: string; maxcount: integer = 12);
procedure miHisCalcClick(Sender: TObject);
function getCrcBit: integer;
procedure setCrcBit(bit: integer);
procedure setCrcMode(bit: integer; poly: longword; v0: longword;
XOROUT: longword; InvIn: boolean; InvOut: boolean);
procedure updateLanguageList;
procedure saveOption;
procedure loadOption;
procedure applyOption;
private
procedure clearConvert;
procedure findConvert(lang: string);
procedure loadConvert(filename: string);
procedure sgConvertEditingDone(Sender: TObject);
private
procedure clearConstant;
procedure findConstant(lang: string);
procedure loadConstant(filename: string);
private
// Script
Compiled_PascalScript: boolean;
procedure mmoOutAdd(var mmo: TMemo; msg: string);
procedure mmoOutAdd_MPY(msg: string);
procedure mmoOutAdd_LittleC(msg: string);
procedure mmoOutAdd_Graph(msg: string);
procedure mmoOutAdd_Pascal(msg: string);
procedure StrToPmScriptNew(pmstr: array of string; pm: TPopupMenu);
procedure pmNewOnClick(Sender: TObject);
procedure pmScriptHisAdd(var pm: TPopupMenu; FileName: string);
procedure pmScriptHisClick(Sender: TObject);
procedure LoadScriptFile(syn: TSynEdit; FileName: string);
procedure SaveScriptFile(syn: TSynEdit; FileName: string);
public
// Option
MinimizeToTray, CloseToTray: boolean;
TableFlatStyle, ButtonFlatStyle: boolean;
TabAlternateColorEn: boolean;
TabAlternateColor: TColor;
RMCCopy: boolean;
MaxLineNumberOfScriptOutput: integer;
winstat: TWindowState;
DateTimefmt: TFormatSettings;
path_MPY, path_Python, path_LittleC: string;
CalcUseMpy: boolean;
errlog_en: boolean;
errlogfile: string;
procedure errlog(msg: string);
procedure setLang(lang: string);
public
UpTime, RunTimeM: integer;
function RunTimeToDHMStr(T: integer): string;
public
function ChrToByte(ch: char): byte;
function Chr2ToByte(c1: char; c2: char): byte;
function BigBytes(s: string): string;
function IntToByteStr(d: dword): string;
procedure StrToBytes(s: string; n: integer; var buf: SysUtils.TByteArray);
procedure StrToByteBuf(s: string; out bs: string);
function StrToXY(dat: string; out x, y: integer): boolean;
public
procedure MPYRunTmpScript(sc: string; out res, err: string);
procedure PYRunTmpScript(sc: string; out res, err: string);
public
procedure ConvertTime(d: TDateTime);
procedure ConvertTime2(d: TDateTime);
procedure TimeBetween;
end;
var
frmMain: TfrmMain;
ini: TIniFile;
lang: string;
ReadonlyMode: boolean;
r: float;
AppPath: string;
implementation
uses
uCRC, uBase;
{$R *.lfm}
{ pascal script addon functions }
procedure PSWrite(const v: array of variant);
var
i: integer;
s, ss: string;
begin
s := '';
for i := low(v) to high(v) do
begin
ss := v[i];
s := s + ss;
end;
frmMain.mmoOutAdd_Pascal(s);
Application.ProcessMessages;
end;
procedure PSWriteln(const v: array of variant);
begin
PSWrite(v);
PSWrite([#13#10]);
end;
function PSFormat(const Fmt: string; const Args: array of const): string;
begin
Result := Format(Fmt, Args);
Application.ProcessMessages;
end;
function PSlog(x: double): double;
begin
Result := ln(x);
Application.ProcessMessages;
end;
function PSlog2(x: double): double;
begin
Result := log2(x);
Application.ProcessMessages;
end;
function PSlog10(x: double): double;
begin
Result := log10(x);
Application.ProcessMessages;
end;
function PSlogN(n, x: double): double;
begin
Result := logN(n, x);
Application.ProcessMessages;
end;
function PSPower(x, y: double): double;
begin
Result := power(x, y);
Application.ProcessMessages;
end;
function PSExp(x: double): double;
begin
Result := exp(x);
Application.ProcessMessages;
end;
function PStan(x: double): double;
begin
Result := tan(x);
Application.ProcessMessages;
end;
function PSarcsin(x: double): double;
begin
Result := arcsin(x);
Application.ProcessMessages;
end;
function PSarccos(x: double): double;
begin
Result := arccos(x);
Application.ProcessMessages;
end;
function PSarctan(x: double): double;
begin
Result := arctan2(x, 1);
Application.ProcessMessages;
end;
function PSsinh(x: double): double;
begin
Result := sinh(x);
Application.ProcessMessages;
end;
function PScosh(x: double): double;
begin
Result := cosh(x);
Application.ProcessMessages;
end;
function PStanh(x: double): double;
begin
Result := tanh(x);
Application.ProcessMessages;
end;
function PSfloor(x: double): double;
begin
Result := floor(x);
Application.ProcessMessages;
end;
function PSceil(x: double): double;
begin
Result := ceil(x);
Application.ProcessMessages;
end;
function PSRandom: double;
begin
Result := Random;
Application.ProcessMessages;
end;
function PSRandomRange(x, y: integer): integer;
begin
Result := Randomrange(x, y);
Application.ProcessMessages;
end;
function PSReadln(const question: string): string;
begin
Result := InputBox(question, '', '');
Application.ProcessMessages;
end;
procedure PSclear;
begin
frmMain.mmoScriptOut_Pascal.Lines.Clear;
Application.ProcessMessages;
end;
procedure PSsleep(x: integer = 1000);
begin
Sleep(x);
Application.ProcessMessages;
end;
procedure PSbeep;
begin
beep;
Application.ProcessMessages;
end;
{ pascal script end }
{ TfrmMain }
procedure TfrmMain.tmrICOTimer(Sender: TObject);
begin
tmrICO.Tag := tmrICO.Tag + 1;
if tmrICO.Tag > 1023 then
begin
tmrICO.Tag := 0;
tmrICO.Interval := Random(4) * 40 + 100;
end;
if (tmrICO.Tag mod 4) = 0 then
begin
ilTray.Tag := (ilTray.Tag + 1) mod ilTray.Count;
ilTray.GetIcon(ilTray.Tag, TrayIcon.Icon);
end;
ShowGear.ImageIndex :=
(ShowGear.ImageIndex + ilOption.Count + ShowGear.Tag) mod ilOption.Count;
if (tmrICO.Tag mod 32) = 0 then
begin
ilICO.Tag := (ilICO.Tag + 1) mod ilICO.Count;
ilICO.GetIcon(ilICO.Tag, frmMain.Icon);
if Random(2) = 0 then
ShowGear.Tag := 1
else
ShowGear.Tag := -1;
end;
end;
procedure TfrmMain.TrayIconClick(Sender: TObject);
begin
// resotre main form
if WindowState = wsMinimized then
WindowState := winstat;
Show;
Application.BringToFront;
end;
procedure TfrmMain.tvOptionSelectionChanged(Sender: TObject);
var
scb: TScrollBox;
begin
scb := TScrollBox(FindComponent('scbOption' + IntToStr(tvOption.Selected.Index)));
if scb = nil then
Exit;
scb.Align := alClient;
scb.BringToFront;
end;
procedure TfrmMain.sgAddLine(var sg: TStringGrid; maxcount: integer);
begin
if sg.RowCount > maxcount then
sg.DeleteRow(1);
sg.RowCount := sg.RowCount + 1;
end;
procedure TfrmMain.sgScrollToLastLine(var sg: TStringGrid);
begin
sg.TopRow := sg.RowCount - 1;
end;
procedure TfrmMain.SaveCalcWorkspace(filename: string);
var
fini: TIniFile;
i: integer;
s: string;
begin
fini := TIniFile.Create(filename);
try
fini.EraseSection('workspace');
fini.WriteString('workspace', 'expr', edtCalcExpr.Text);
s := mmoCalcFunc.Lines.CommaText;
s := '"' + s + '"';
fini.WriteString('workspace', 'func', s);
fini.WriteInteger('workspace', 'hisnum', sgCalcExpr.RowCount - 1);
for i := 1 to sgCalcExpr.RowCount - 1 do
begin
fini.WriteString('workspace', 'expr' + IntToStr(i), sgCalcExpr.Cells[1, i]);
fini.WriteString('workspace', 'res' + IntToStr(i), sgCalcExpr.Cells[2, i]);
end;
fini.UpdateFile;
mmoCalcFunc.Modified := False;
btnCalcSave.Enabled := False;
finally
btnCalcWorkspaceName.Caption :=
'<' + ChangeFileExt(ExtractFileName(filename), '') + '>';
fini.Free;
end;
end;
procedure TfrmMain.LoadCalcWorkspace(filename: string);
var
fini: TIniFile;
s1, s2: string;
i: integer;
begin
sgCalcExpr.RowCount := 1;
fini := TIniFile.Create(filename);
try
edtCalcExpr.Text := fini.ReadString('workspace', 'expr', '');
s1 := fini.ReadString('workspace', 'func', '');
mmoCalcFunc.Lines.CommaText := s1;
for i := 1 to fini.ReadInteger('workspace', 'hisnum', 0) do
begin
sgAddLine(sgCalcExpr);
s1 := fini.ReadString('workspace', 'expr' + IntToStr(i), '');
s2 := fini.ReadString('workspace', 'res' + IntToStr(i), '');
if s1 <> '' then
begin
sgCalcExpr.Cells[1, i] := s1;
sgCalcExpr.Cells[2, i] := s2;
end;
end;
sgScrollToLastLine(sgCalcExpr);
sgCalcExpr.Tag := sgCalcExpr.RowCount - 1;
mmoCalcFunc.Modified := False;
btnCalcSave.Enabled := False;
finally
CalcWorkspaceFileName := filename;
btnCalcWorkspaceName.Caption :=
'<' + ChangeFileExt(ExtractFileName(filename), '') + '>';
fini.Free;
end;
end;
procedure TfrmMain.pmAdd(var pm: TPopupMenu; filename: string; maxcount: integer);
var
mi: TMenuItem;
begin
if FileName = '' then
Exit;
mi := pm.Items.Find(filename);
// Add new history file
if mi = nil then
begin
// max history files
if pm.Items.Count > maxcount then
pm.Items.Delete(maxcount - 1);
mi := TMenuItem.Create(pm);
mi.Caption := filename;
if pm = pmHisCalc then
begin
mi.OnClick := @miHisCalcClick;
end;
mi.GroupIndex := 1;
mi.RadioItem := True;
mi.AutoCheck := True;
pm.Items.Insert(0, mi);
pm.Items[0].Checked := True;
end
else
begin
// move filename to first
if mi.MenuIndex = 0 then
Exit;
pm.Items.Remove(mi);
pmAdd(pm, filename, maxcount);
end;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
var
i: integer;
BuildNum: string;
FileVerInfo: TFileVersionInfo;
begin
FileVerInfo := TFileVersionInfo.Create(nil);
try
FileVerInfo.ReadFileInfo;
BuildNum := 'V' + FileVerInfo.VersionStrings.Values['FileVersion'];
finally
FileVerInfo.Free;
end;
lbVer.Caption := BuildNum;
tsSolve.TabVisible := False;
tsScriptGraph.TabVisible := False;
tsDigitBigint.TabVisible := False;
tsDigitBigfloat.TabVisible := False;
AppPath := ExtractFilePath(Application.ExeName);
ini := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
errlogfile := ChangeFileExt(Application.ExeName, '.err');
updateLanguageList;
try
UpTime := ini.ReadInteger('run', 'UpTime', 0);
RunTimeM := MinuteOf(now);
imgLogo.Tag := ini.ReadInteger('run', 'count', 0) + 1;
ini.WriteInteger('run', 'count', imgLogo.Tag);
ReadonlyMode := False;
except
ReadonlyMode := True;
end;
// option
loadOption;
applyOption;
tvOption.Select(tvOption.Items[0]);
tvOptionSelectionChanged(nil);
// last
Left := ini.ReadInteger('last', 'Left', Left);
Top := ini.ReadInteger('last', 'Top', Top);
Width := ini.ReadInteger('last', 'Width', Width);
Height := ini.ReadInteger('last', 'Height', Height);
pcMain.ActivePageIndex := ini.ReadInteger('last', 'page', 0);
{// check micropython exist
if not FileExists(AppPath + MICROPYTHON_BIN_NAME) then
begin
ShowMessage('MicroPython is not found, path:' + #13#10#13#10 +
AppPath + #13#10 + MICROPYTHON_BIN_NAME + #13#10#13#10 +
'Please reinstall CalcToolbox!');
tsCalc.Enabled := False;
end