/
165_best_of_runtime4.txt
1739 lines (1488 loc) · 59.2 KB
/
165_best_of_runtime4.txt
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
{********************************************************"""""""""*******
*
* Project : BEST OF RUNTIME LIBRARY by Object Pascal
* App Name : 165_best_of_runtime.txt, #locs:1291
* Purpose : Demonstrates functions of runtime lib
* Date : 17/09/2011 - 14:56
* History : getHostbyName, HINSTANCE, TPrinter, TMediaPlayer
* : TClipboard, TStatusBar, Ressources, Registry Read
* : System demo for mX3.5.1 and EKON 15 and Delphi Tage 2011
***********************************************************************}
Program RuntimeLibraryOperatingSystem_Tutorial_Delphi_Experimental_Frame_3;
{BOOL WINAPI MessageBeep(
__in UINT uType
);}
// for DLL Load Demo
function MessageBeep(para: integer): byte;
external 'MessageBeep@user32.dll stdcall';
const REGPATH= '\SYSTEM\CurrentControlSet\services\SCCSService';
REGROOT= HKEY_LOCAL_MACHINE;
REGPATH3= '\Software\Microsoft\Internet Explorer\TypedURLs';
REGROOT3= HKEY_CURRENT_USER;
MAINFORM = 'TMaxForm1';
BITMAPPATH = '..\maxbox3\examples\citymax.bmp';
EBNFFILE = '..\maxbox3\examples\ebnftest.txt';
literal = '*xml-char';
title = 'wikitext-L3';
part_name = 'wikitext-L3';
part_value = 'wikitext-L3';
part = '( part_name "=" part_value ) / ( part_value )';
parts = '[ title *( "|" part ) ]';
tplarg = '"{{{" parts "}}}"';
template = '"{{" parts "}}"';
link = '"[[" wikitext-L3 "]]"';
var
rStr: String;
StringGrid1: TStringGrid;
mytimestamp, dt: TDateTime;
osType: TIdWin32Type;
myProcList, pathstr: TStrings;
//UpDown3: TUpDown;
procedure Signal_Sounds;
var sound: integer;
begin
for sound:= 1 to 100 do
if sound mod 10 = 0 then begin
MessageBeep(sound)
Sleep(1500)
end
end;
//Recursion
Function Fakultaet(Zahl: integer): Integer;
begin
If Zahl = 0 then
result:= 1
else
result:= Zahl * Fakultaet(Zahl - 1);
end;
Function getFileCount: integer;
var
DOSerr: integer;
//fsrch: TsearchRec;
begin
result:= 0;
doserr:= FindFirst('*.*',faAnyFile);
if (DOSerr = 0) then begin
while (DOSerr = 0) do begin
if (searchRecAttr and faDirectory) = 0 then inc(result);
//writeln(searchRecName)
DOSerr:= findNext;
end;
findClose;
end;
end;
function GetFolderDate(Folder: String): TDateTime;
var
Found: integer;
Date: TDateTime;
begin
if Folder[length(folder)]= '\' then
Delete(Folder, length(folder), 1);
Result:= 0;
Found:= FindFirst(Folder, faDirectory);
try
if Found = 0 then begin
Date:= FileDateToDateTime(searchRecTime);
result:= Date;
end;
finally
FindClose;
end;
end;
function GetTextFromFile(AFile: String; var ReturnString: string): boolean;
var
FileStream: TFileStream;
begin
result:= false;
if not fileExists(AFile) then Exit;
FileStream:= TFileStream.Create(AFile, fmOpenRead);
try
if FileStream.Size > 0 then begin
SetLength(ReturnString, FileStream.Size);
FileStream.Read(ReturnString, FileStream.Size);
result:= true;
end;
finally
FileStream.Free;
end; //try
end;
function ExeFileIsRunning(ExeFile: string): boolean;
begin
result:= ExeFileIsRunning(ExeFile);
end;
procedure getDriveTypesF;
var
Drive: byte;
DriveLetter: String;
begin
for Drive:= ord('A') to ord('Z') do begin
DriveLetter:= chr(Drive) + ':\';
case GetDriveType(PChar(chr(Drive) + ':\')) of
0: //DRIVE_UNKNOWN
Memo2.Lines.Add(DriveLetter + ' Unknown Drive');
{1: //DRIVE_NO_ROOT_DIR
Memo2.Lines.Add(DriveLetter + ' No Root Dir or mount Point');}
2: //DRIVE_REMOVABLE:
Memo2.Lines.Add(DriveLetter + ' Removable or Floppy Drive');
3: //DRIVE_FIXED:
Memo2.Lines.Add(DriveLetter + ' Fixed Drive');
4: //DRIVE_REMOTE:
Memo2.Lines.Add(DriveLetter + ' Network Drive');
5: //DRIVE_CDROM:
Memo2.Lines.Add(DriveLetter + ' CD-ROM Drive');
6: //DRIVE_RAMDISK:
Memo2.Lines.Add(DriveLetter + ' RAM Disk');
end;
end;
end;
Procedure TimeCounter;
var
time, time2: longint;
begin
time:= GetTickCount;
time2:= GetClockValue;
//Put the commands to measure...
Sleep(500)
//maxform1.StatusBar1.SimpleText:= ('Time Diff: '+IntToStr(GetTickCount-time));
Writeln('Get Clock Value Time Diff: '+IntToStr(GetTickCount-time));
end;
function getBitMap: TBitmap;
begin
result:= TBitmap.Create;
//result.LoadFromFile(BITMAPPATH);
//result.Free;
end;
Procedure RTL_Containers; //see ex. 160_object_list.txt
var
objstack: TObjectStack;
mystrl: TStringlist;
begin
objstack:= TObjectStack.create;
mystrl:= TStringlist.create;
mystrl.add('first box');
mystrl.add('second box');
with objstack do begin
push(mystrl)
push(mystrl)
push(mystrl)
Pop
Writeln('from containers objstack in list has '+intToStr(count)+' objects');
Free;
end;
mystrl.Free;
end;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ARow = 1 then
StringGrid1.Canvas.Draw(Rect.Left,Rect.Top, getBitmap);
end;
procedure BuildFormMenu;
var frmMon: TForm;
myButton: TSpeedButton;
mylistbox: TListbox;
i: integer;
begin
frmMon:= TForm.Create(self);
with frmMon do begin
//FormStyle := fsStayOnTop;
Position := poScreenCenter;
caption:='Best of Runtime Functions';
color:= clred;
width:= 650;
height:= 600;
Show
end;
stringGrid1:= TStringGrid.Create(frmMon);
with stringGrid1 do begin
Parent:= frmMon;
defaultcolwidth:= 154;
defaultrowheight:= 154;
height:= 360;
width:= 360;
colcount:= 2; //buggg solved!!!
rowcount:= 2;
top:= 20;
GridLineWidth:= 8;
Scrollbars:= false;
//onDrawCell:= @StringGrid1DrawCell; //to decompile
end;
myListbox:= TListbox.create(frmMon);
with myListbox do begin
parent:= frmMon;
top:= 20;
left:= 450;
height:= 380;
font.size:= 18;
//font.Style:= [fsbold];
for i:= 1 to 15 do
items.add(intToStr(i*i));
show
end;
myButton:= TSpeedButton.Create(frmMon)
with myButton do begin
Parent:= frmMon;
setbounds(10,440,380,80);
caption:= 'Big Bit Button';
font.size:= 12;
//font.Style:= [fsbold];
//glyph.loadfromfile(BITMAPPATH);
//glyph.loadfromresourcename(getHINSTANCE,'HARD');
glyph.loadfromresourcename(getHINSTANCE,'OPENFOLDER');
//event handler
//onclick:= @btnClick;
end;
end;
procedure Apploop_Tester;
var i,j: integer;
c: TComponent;
begin
for i:= 0 to Application.ComponentCount - 1 do begin
// all components of a Form
for j:= 0 to Application.Components[i].ComponentCount - 1 do begin
c:= Application.Components[i].Components[j];
if c is TComponent then
writeln(inttostr(j)+ ' '+c.name +' '+ c.classname)
end;
end;
end;
FUNCTION GetIpAddressByName(const AHostName: String): String;
begin
result:= GetHostByName(AHostName)
end;
function GetURLByIndy(const AURL: String): String;
var
IdHTTP: TIdHTTP;
begin
IdHTTP:= TIdHTTP.Create(NIL);
try
Result:= IdHTTP.Get(AURL);
finally
IdHTTP.Free;
end;
end;
FUNCTION HINSTANCE: longword;
begin
result:= GetHINSTANCE;
end;
Function RegRead(keyRoot: Longint; keyPath, myField: String): string;
begin
result:= RegistryRead(keyroot, keyPath, myField)
end;
procedure IsAppAlive;
var Handle: THandle;
begin
Handle:= FindWindow(MAINFORM,''); //FindReplDialog does not
if Handle <> 0 then
Showmessage('maXbox is alive')
else
Showmessage('maXbox still sleeps');
end;
procedure PrintMap(aGraphic: TGraphic; title: string);
begin
Printer.Title:= Title;
Printer.BeginDoc;
// in to the center
Printer.Canvas.Draw((Printer.PageWidth - aGraphic.Width ) div 2,
(Printer.PageHeight - aGraphic.Height) div 2,aGraphic);
//Printer.Canvas.Draw(40,40,aGraphic);
Printer.Canvas.TextOut(480,480,'Place any text here');
Printer.EndDoc;
end;
function d3Array: array of array of string;
var
A: array of array of string;
I,J : Integer;
begin
SetLength(A, 10);
for I:= Low(A) to High(A) do begin
SetLength(A[I], I);
for J:= Low(A[I]) to High(A[I]) do begin
A[I][J]:= IntToStr(I) + ',' + IntToStr(J) + ' ';
Write(A[I][J]+ ' ');
end;
end;
result:= A;
end;
function StrToHexStr(const S:string):string;
//??????16?????
var
I:Integer;
begin
for I:=1 to Length(S) do begin
if I=1 then
Result:= IntToHex(Ord(S[1]),2)
else Result:= Result+IntToHex(Ord(S[I]),2);
end;
end;
procedure ABNFToText_01; //Indy
var amfile: string;
begin
Writeln('ABNFToText_01: '+ABNFToText(template))
amfile:= LoadFileAsString(Exepath+'examples\ebnftest.txt')
Writeln('ABNFToText_01: '+ABNFToText(amfile))
end;
procedure BytesToString_02; //Indy
var mbytes: TBytes;
i, byteback: integer;
begin
SetLength(mbytes, 32)
Writeln('');
for i:= 1 to 31 do begin
mbytes[i]:= Random(2)
write(inttostr(mbytes[i])+' ') //debug
end;
//bytestocardinal
Writeln('BytesToInteger_02: '+IntToStr((BytesToInteger(mbytes,0))))
byteback:= BytesToInteger(mbytes,0)
//Writeln('testback ' +InttoBin(byteback))
end;
Procedure TimeCompare_05;
var
thismoment, futuremoment: TDateTime;
begin
ThisMoment:= Now;
FutureMoment:= IncDay(ThisMoment, 6); //adds 6 days
//sleep(10)
//FutureMoment:= Now;
Writeln('CompareDateTime '+IntToStr(CompareDateTime(ThisMoment, FutureMoment)))
//returns LessThanValue (-1)
//maxform1.StatusBar1.SimpleText:= ('Time Diff: '+IntToStr(GetTickCount-time));
end;
Procedure DecodeDateTimeFully_09;
var
myDate : TDateTime;
myYear, myMonth, myDay : Word;
myHour, myMin, mySec, myMilli : Word;
begin
// Set up the myDate variable to have a December 2000 value
myDate:= StrToDateTime('29.12.2000 12:45:12.34');
// Now add a month to this value
myDate:= IncMonth(myDate,1);
// And let us see what we get
DecodeDateTime(myDate, myYear, myMonth, myDay,
myHour, myMin, mySec, myMilli);
Writeln('myDate now = '+DateToStr(myDate));
Writeln('myHour = '+IntToStr(myHour));
Writeln('myMin = '+IntToStr(myMin));
Writeln('mySec = '+IntToStr(mySec));
Writeln('myMilli = '+IntToStr(myMilli));
Writeln('myDay = '+IntToStr(myDay));
Writeln('myMonth = '+IntToStr(myMonth));
Writeln('myYear = '+IntToStr(myYear));
end;
procedure Fetch_13_from_Telnet;
var Buffer: String;
Tmp: String;
begin
Tmp := Buffer;
// repeat
tmp:= 'this is my telnet session before' +#13#10+'Memo1.SelStart:= Memo1.GetTextLen';
Writeln(tmp)
buffer:= Fetch(Tmp, #10,true,false);
writeln(buffer)
//if (Tmp <>'') and (Tmp[1] = #10) then Delete(Tmp, 1, 1);
//until Tmp = '';
end;
Procedure CommandlLineSwitch_14; //SysUtils unit
var
switchPrefixes : TSysCharSet;
begin
// Before running this code, use the Run/parameters menu option
// to set the following command line parameters : /def /file
//chars:= ' ';
// How many parameters were passed?
ExecuteFile(ExePath+'maxbox4.exe','"'
+ExePath+'examples\218_biorythmus_studio.txt"','',1);
//Set these Commands in the Remote App
ShowMessage('There are '+IntToStr(ParamCount)+' parameters inside');
ShowMessage(CmdLine); // Show the execution command + parameters
// Scan for parm1, parm2 and parm3 parameters
if FindCmdLineSwitch('165_best_of_runtime.txt',switchprefixes, True)
then ShowMessage('abc found')
else ShowMessage('abc NOT found');
{if FindCmdLineSwitch('def')
then ShowMessage('def found')
else ShowMessage('def NOT found');}
end;
function GetASCII_16: string;
var i: integer;
begin
for i:= 1 to 255 do
result:= result +#13#10+ Format('This Number: %4d is this ASCII %2s',[i, Chr(i)])
end;
Procedure TimeCounterDiff_18;
var
time, time2: longint;
begin
time:= GetTickCount;
time2:= GetClockValue;
//Put the commands to measure...
Sleep(500)
//maxform1.StatusBar1.SimpleText:= ('Time Diff: '+IntToStr(GetTickCount-time));
Writeln('Get TickCountTime Diff: '+IntToStr(GetTickCount-time));
Writeln('Get Get Tick Diff: '+IntToStr(GetTickDiff(time, GetTickCount)));
Writeln('Get Clock Value Time: '+IntToStr64(GetClockValue));
end;
procedure PerformanceTimer_18;
var
Start, Stop: longint;
Start1, Stop1: TDateTime;
begin
Start:= GetTickCount;
//Start1:= GetTickCount;
Sleep(3000);
Stop:= GetTickCount;
//Stop1:= TDateTime(GetTickCount);
//Writeln(TimeToStr((time)));
Writeln(TimeToStr(GetTickDiff(Start, Stop)));
Writeln(IntToStr(Stop - Start)+ ' ms'); // * (1/24/60/60/1000)));
end;
function GrabLine2(const s: string; ALine: Integer): string;
var
sl: TStringList;
begin
sl:= TStringList.Create;
try
sl.LoadFromFile(s);
Result:= sl[ALine - 1]; // index off by one
finally
sl.Free;
end;
end;
Procedure PrompForFileName_28;
var
selectedFile, path, fileName, tmp: string;
drive: char;
begin
if PromptForFileName(selectedFile,
'Text files (*.txt)|*.txt',
'',
'Select your mX3 test file',
'C:\', False) // Means not a Save dialog !
then begin
// Display this full file/path value
ShowMessage('Selected file = '+selectedFile);
// Split this full file/path value into its constituent parts
//ProcessPath(selectedfile, drive, path, tmp);
writeln('PromptForFileName_28: Res of processpath '+tmp)
ShowMessage('drive = '+drive);
ShowMessage('path = '+path);
ShowMessage('fileName = '+tmp);
end;
end;
procedure testchessboard;
begin
//register;
//SetAndrew40Str','String').SetString( 'SETANDREW40');
//versionStr','String').SetString( '3.02');
//NoPiece','LongInt').SetInt( - 1);
//change Black','LongInt').SetInt( 0);
// change White','LongInt').SetInt( 1);
//MOVE_STACK','LongInt').SetInt( 4096);
//HIST_STACK','LongInt').SetInt( 64);
//LIGHT','LongInt').SetInt( 0);
//DARK','LongInt').SetInt( 1);
//PAWN','LongInt').SetInt( 0);
//KNIGHT','LongInt').SetInt( 1);
//BISHOP','LongInt').SetInt( 2);
//ROOK','LongInt').SetInt( 3);
//QUEEN','LongInt').SetInt( 4);
//KING','LongInt').SetInt( 5);
//EMPTY','LongInt').SetInt( 6);
//CL.AddClassN(CL.FindClass('TOBJECT'),'EChessException');
//Square', '( None, A8, B8, C8, D8, E8, F8, G8, H8, A7, B7, C7, D7'
{+', E7, F7, G7, H7, A6, B6, C6, D6, E6, F6, G6, H6, A5, B5, C5, D5, E5, F5, '
+'G5, H5, A4, B4, C4, D4, E4, F4, G4, H4, A3, B3, C3, D3, E3, F3, G3, H3, A2'
+', B2, C2, D2, E2, F2, G2, H2, A1, B1, C1, D1, E1, F1, G1, H1 )');
}
//DisplayCoords', '( West, North, East, South )');
//CanStillCastle', '( WhiteKingSide, WhiteQueenSide, BlackKingSide'
//+', BlackQueenSide )');
//CastleSet', 'set of CanStillCastle');
//CoordSet', 'set of DisplayCoords');
//MoveInfo', 'record position : String; Castling : CastleSet; OldS'
//+'quare : square; NewSquare : square; EnPassant : Square; end');
//pieces', '( BP, BN, BB, BR, BK, BQ, WP, WN, WB, WR, WQ, WK )');
//pGenRec', '^gen_rec // will not work');
//pSquare', '^Square // will not work');
//pCastleSet', '^CastleSet // will not work');
//pBoolean', '^Boolean // will not work');
//pThreadPriority', '^TThreadPriority // will not work');
//change TMoveEvent', 'Procedure ( Sender : TObject; oldSq, newSq : Square)');
//TCaptureEvent', 'Procedure ( Sender : TObject; oldSq, newSq : Square; CapturedPiece : Char)');
//TOneSquareEvent', 'Procedure ( Sender : TObject; square : Square)');
//TPromotionEvent', 'Procedure ( Sender : TObject; oldSq, newSq : '
// +'Square; var NewPiece : Char)');
//TMoveFunc', 'Function ( oldsq, newsq : Square) : Boolean');
//TThinkEvent', 'Procedure ( Sender : TObject; var oldsq, newsq : Square)');
//move_bytes', 'record src : byte; dst : byte; promote : byte; bits : Byte; end');
//moverec', 'record b : move_bytes; end');
//gen_rec', 'record m : moverec; score : Integer; end');
//hist_rec', 'record m : moverec; capture : integer; castle : inte'
//+'ger; ep : integer; fifty : Integer; end');
//SIRegister_TChessThread(CL);
//TChessBrd
//SIRegister_TChessBrd(CL);
//CL.AddClassN(CL.FindClass('TOBJECT'),'ChessBrdError');
//CL.AddDelphiFunction('Procedure Register');
//TGraph3D
//MaxNoOfIsodoses','LongInt').SetInt( 10);
//T3DPoint', 'record X : single; Y : single; Z : Single; end');
//P3DPoint', '^T3DPoint // will not work');
//PSingleArray', '^TSingleArray // will not work');
//TMouseControl', '( mcNone, mcMove, mcRotate, mcZoom )');
//TIsodoseData', 'record Percentage : Single; Color : TColor; Acti'
//+'ve : Boolean; end');
//PIsodoseData', '^TIsodoseData // will not work');
//TWaterlevel', '( wlNone, wlAbove, wlBelow )');
//TGraphLine(CL);
//SIRegister_TGraph3D(CL);
//L.AddDelphiFunction('Function Point3D( x, y, z : Single) : T3DPoint');
// change Point3D3( x, y, z : Single) : T3DPoint');
//TGraphLine
//CL.AddDelphiFunction('Procedure Register');
writeln('length: '+itoa(length('C:\maXbox\TestApp2\maxbox2\maxbox2\source_2007\maxbox29\mx4\mx4_v38\mx4\source\REST\unit-importing')))
// Soundex
//isprime
//ConvertFromBase(sNum: String; iBase: Integer; cDigits: String): Integer;
//ConvertToBase(iNum, iBase: Integer; cDigits: String): String;
//EnsureSentenceTerminates(Sentence: String; Terminator: Char): String;
//FindTokenStartingAt(st: String; var i: Integer; TokenChars: TCharSet; TokenCharsInToken: Boolean): String;
//GetDirectoryOfFile(FileName: String): String;
//GetTempFileFIB(FilePrefix: String): String;
//Icon2Bitmap(Icon: HICON): HBITMAP;
//Maxfib(n1, n2: Integer): Integer;
//MaxD(n1, n2: Double): Double;
//Minfib(n1, n2: Integer): Integer;
//MinD(n1, n2: Double): Double;
//RandomStringfib(iLength: Integer): String;
//RandomIntegerfib(iLow, iHigh: Integer): Integer;
//Soundexfib(st: String): String;
//StripStringfib(st: String; CharsToStrip: String): String;
//ClosestWeekday(const d: TDateTime): TDateTime;
//Yearfib(d: TDateTime): Integer;
//Monthfib(d: TDateTime): Integer;
//DayOfYearfib(d: TDateTime): Integer;
//DayOfMonthfob(d: TDateTime): Integer;
//dayofmonth
//VarCoalesce(V1, V2: Variant): Variant;
//VarEqual(V1, V2: Variant): Boolean;
//WeekOfYearfib(d: TDateTime; var Year, Week: Integer);
//Degree10(Degree:integer):double;
// Comp type stuff
//CompToStr(Value: comp): string;
//StrToComp(const Value: string): comp;
//CompDiv(A, B: comp): comp;
//CompModfib(A, B: comp): comp;
//GetDirOfFile( FileName : String) : String');
//integerarray
//Essentially Free calls Destroy if Self is not nil.
{ procedure DefWriteToRegistry( const OtherKeys , ParamNames: array of string;
const Values: array of Variant
);
procedure WriteToRegistry(aRootKey:HKEY; const OtherKeys,ParamNames: array of string;
const Values: array of Variant
);
function ReadFromRegistry(aRootKey:HKEY;
const OtherKeys, ParamNames: array of string
):Variant;
WriteToRegistry
function DefReadFromRegistry(const OtherKeys, ParamNames: array of string):Variant;
function AllSubKey(aRootKey:HKEY; const ForPath: array of string):Variant;
function DefAllSubKey(const ForPath: array of string):Variant;
function SaveRegKey(const FileName: String; const ForKey: array of string): Boolean;
function LoadRegKey(const FileName: String; const ForKey: array of string): Boolean;
function AltSaveRegKey(const FileName: String; const ForKey: array of string): Boolean;
function AltLoadRegKey(const FileName: String; const ForKey: array of string): Boolean;
function GetKeyForParValue(const aRootKey,ParName,ParValue:string):string; }
//DefWriteToRegistry( const OtherKeys , ParamNames: array of string;
//const Values: array of Variant
//);
//WriteToRegistry(aRootKey:HKEY; const OtherKeys,ParamNames: array of string;
//const Values: array of Variant
//);
//ReadFromRegistry(aRootKey:HKEY;
//const OtherKeys, ParamNames: array of string
//):Variant;
//DefReadFromRegistry(const OtherKeys, ParamNames: array of string):Variant;
//AllSubKey(aRootKey:HKEY; const ForPath: array of string):Variant;
//DefAllSubKey(const ForPath: array of string):Variant;
//SaveRegKey(const FileName: String; const ForKey: array of string): Boolean;
//LoadRegKey(const FileName: String; const ForKey: array of string): Boolean;
//AltSaveRegKey(const FileName: String; const ForKey: array of string): Boolean;
//AltLoadRegKey(const FileName: String; const ForKey: array of string): Boolean;
//GetKeyForParValue(const aRootKey,ParName,ParValue:string):string;
//SafeVarArrayCreate
//change VarArrayGet
//cgange VarArrayPut
{function CycleReadArray(vArray:Variant;CallBackProc:TProcReadElementValue):boolean;
function CycleWriteArray(var vArray:Variant;CallBackProc:TProcWriteElementValue):boolean;
function CompareVarArray1(vArray1,vArray2:Variant):boolean;
function EasyCompareVarArray1(vArray1,vArray2:Variant;HighBound:integer):boolean;
}
//CycleReadArray(vArray:Variant;CallBackProc:TProcReadElementValue):boolean;
//CycleWriteArray(var vArray:Variant;CallBackProc:TProcWriteElementValue):boolean;
//CompareVarArray1(vArray1,vArray2:Variant):boolean;
//EasyCompareVarArray1(vArray1,vArray2:Variant;HighBound:integer):boolean;
//WriteToRegistry
//VarArrayGet2
//DispositionFrom(const SQLText:string):TPoint;
//AllTables(const SQLText:string;FTables:Tstrings);
//TableByAlias(const SQLText,Alias:string):string;
//FullFieldName(const SQLText,FieldName:string):string;
//AddToWhereClause(const SQLText,NewClause:string):string;
//GetWhereClause(SQLText:string;N:integer;var StartPos,EndPos:integer ):string;
//77WhereCount(SQLText:string):integer;
//GetOrderInfo(SQLText:string):variant;
//OrderStringTxt(SQLText:string; var StartPos,EndPos:integer ):String;
//
//PrepareConstraint(Src:Tstrings):string;
//DeleteEmptyStr(Src:Tstrings);
//NormalizeSQLText(const SQL: string;MacroChar:Char): string;
//CountSelect(const SrcSQL:string):string;
//GetModifyTable(const SQLText:string;AlreadyNormal:boolean):string;
//space2
//QuotMarks
//dayofyear2
//Nanometers', 'Double');
//WavelengthMinimum','LongInt').SetInt( 380);
//WavelengthMaximum','LongInt').SetInt( 780);
//CL.AddDelphiFunction('Procedure WavelengthToRGB( const Wavelength : Nanometers; var R, G, B : BYTE)');
//WavelengthToRGB
//TRangeErrorEvent
//GetCharFromVKey
//Xls_To_StringGrid
//IsObjectActive
with TChessForm1.create(self) do begin
caption:= 'myChess Guess';
//ChessBrd1LegalMove(self,square([E_2,E_4]),[E_2,E_4]);
ChessBrd1;
showmodal
free
end;
end;
function IsObjectActive(ClassName: string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
//UnRegisterOCX
try
ClassID := ProgIDToClassID(ClassName);
//Result := XRTLGetActiveObject(ClassID, nil, Unknown) = S_OK;
//RegisterServer2
except
// raise;
Result := False;
end;
end;
procedure TForm1_AppOnMessage(var Msg: TMsg; var Handled: Boolean);
var
ccode: Word;
begin
case Msg.Message of
WM_KEYDOWN, WM_KEYUP:
begin
//RegisterOCX
// if (GetKeyState(VK_NUMLOCK) >= 0) {NumLock not active} and
// ((Msg.lParam and $1000000) = 0) {not a gray key} then
begin
ccode := 0;
case Msg.wParam of
VK_HOME: ccode := VK_NUMPAD7;
VK_UP: ccode := VK_NUMPAD8;
VK_PRIOR: ccode := VK_NUMPAD9;
VK_LEFT: ccode := VK_NUMPAD4;
VK_CLEAR: ccode := VK_NUMPAD5;
VK_RIGHT: ccode := VK_NUMPAD6;
VK_END: ccode := VK_NUMPAD1;
VK_DOWN: ccode := VK_NUMPAD2;
VK_NEXT: ccode := VK_NUMPAD3;
VK_INSERT: ccode := VK_NUMPAD0;
VK_DELETE: ccode := VK_DECIMAL;
end; {Case}
if ccode <> 0 then
Msg.wParam := ccode;
end; {If}
end; {Case Msg.Message}
end; {Case}
end;
procedure DelayAPI(msecs: Longint);
var
targettime: Longint;
Msg: TMsg;
begin
targettime := GetTickCount + msecs;
while targettime > GetTickCount do
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
if Msg.message = WM_QUIT then
begin
PostQuitMessage(Msg.wParam);
Break;
end;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
procedure TForm1_Button1Click(Sender: TObject);
var
data: TIdMultiPartFormDataStream;
IdHTTP1: TIdHTTP;
begin
data := TIdMultiPartFormDataStream.Create;
try
{ add the used parameters for the script }
data.AddFormField('param1', 'value1');
data.AddFormField('param2', 'value2');
data.AddFormField('param3', 'value3');
//DownloadJPGToBitmap
{ Call the Post method of TIdHTTP and read the result into TMemo }
Memo2.Lines.Text := IdHTTP1.Post2('http://localhost/script.php', data);
finally
data.Free;
end;
end;
function PosInSubstr(const SearchStr:string;Str:string;
BeginPos,EndPos:integer
):integer;
begin
if BeginPos<1 then BeginPos:=1;
Result:=Pos(SearchStr,
Copy(Str,BeginPos,EndPos)
);
if Result>0 then Inc1(Result,BeginPos-1)
end;
function PosInSubstrExt(const SearchStr:string;Str:string;
BeginPos,EndPos:integer;
BegSub,EndSub:TCharSet
):integer;
var p,l,l1:integer;
begin
Result:=0;
p:=PosInSubstr(SearchStr,Str,BeginPos,EndPos);
l:=Length(Str);l1:=Length(SearchStr);
while p>0 do begin
if ((p=1) or (Str[p-1] in BegSub) )
and ((Str[p+l1] in EndSub) or (p+l1=l))
then
begin
Result:=p; Exit;
end;
p:=PosInSubstr(SearchStr,Str,p+l1,EndPos)
end;
end;
var Res : boolean;
function Identical (FLine,SLine : string) : boolean;
begin
if (FLine = '*') or (SLine = '*') or (FLine=SLine) then result:= true
else result:= false;
end;
function Different (FLine,SLine : string ) : boolean;
begin
result:=false;
if (Length(FLine)>0) and (Length(SLine)>0) then begin
if (FLine[1]<>'*') and (SLine[1]<>'*')
and (FLine[1]<>'?') and (SLine[1]<>'?')
and (FLine[1]<>SLine[1]) then result := true;
end
else begin
if (Length(FLine)=0) and (SLine<>'*') then result := true;
if (Length(SLine)=0) and (FLine<>'*') then result := true;
end;
end;
function DoResultLine (TLine : string ) : string;
var i : integer;
begin
i := 1;
{for i := 1 to Length(TLine) do}
while i<=length(TLine) do
if (Copy(TLine,i,2)='**') or
(Copy(TLine,i,2)='*?') or
(Copy(TLine,i,2)='?*') then begin
TLine := Copy(TLine,1,i-1)+'*'+Copy(TLine,i+2,Length(TLine)-i-1);
{i := 0;}
i := 0;
end
else inc(i);
result := TLine;
end;
function WildCompare (FLine,SLine : string) : boolean;
var k : integer;
begin
//EParserError
if Identical(FLine,SLine) then begin
result := true;
exit;
end;
if Different(FLine,SLine) then begin
result := false;
exit;
end;
if (FLine[1]='*') then
for k := 1 to Length(SLine) do
if (SLine[k]='*') or (SLine[k]=FLine[2]) or (SLine[k]='?') then
Res := Res or
wildcompare(Copy(FLine,2,Length(FLine)-1), Copy(SLine,k,Length(SLine)-k+1));
if (SLine[1]='*') then
for k := 1 to Length(FLine) do
if (FLine[k]='*')or(FLine[k]=SLine[2])or(FLine[k]='?') then
Res := Res
or wildcompare(Copy(FLine,k,Length(FLine)-k+1), Copy(SLine,2,Length(SLine)-1));
if (FLine[1]<>'*') and (SLine[1]<>'*') and ((FLine[1] = SLine[1])
or((FLine[1]='?') or (SLine[1]='?'))) then
Res := Res or WildCompare(Copy(FLine,2,Length(Fline)-1), Copy(SLine,2,Length(SLine)-1));
result := Res;
end;
function WordCount(const S: string; const WordDelims: TCharSet): Integer;
var
SLen, I: Cardinal;
begin
Result := 0;
I := 1;
SLen := Length(S);
while I <= SLen do begin
while (I <= SLen) and (S[I] in WordDelims) do Inc(I);
if I <= SLen then Inc(Result);
while (I <= SLen) and not(S[I] in WordDelims) do Inc(I);
end;
end;
var
mylong, i, j: longword;
myhandle: THandle;
//b: boolean;
mystr: string;
mycurr: currency;
my3darray: array of array of string;
mname, mdes, afile, afile2, filename: string;
AFamily: TConvFamily;
ATypes: TConvTypeArray;
begin //main app
//Signal_Sounds;
Writeln('All files in Exe Path: ' +intToStr(GetFileCount));
Writeln('folder date of: '+datetimetostr(getFolderDate('examples')))
dt:= getFolderDate('examples')
//if GetTextFromFile(ExePath+'firstdemo3.txt',rStr) then ShowMessage(rStr);
//0 = Current drive
getDriveTypesF;
TimeCounter;
//BuildFormMenu; //calls StringGrid1DrawCell and getBitMap
//Apploop_Tester;
Writeln('IP Address of: '+GetIpAddressByName('www.softwareschule.ch'));
Writeln('IP Address of own Host: '+GetIpAddressByName(getHostName));
//Memo2.Lines.Text:= GetURLByIndy('http://www.delphi-treff.de');
Writeln('instance of module is: '+intToStr(HINSTANCE))
Writeln('Registry read of url2: '+RegRead(REGROOT3, REGPATH3, 'url2'))
//IsAppAlive;
//PrintMap(getBitMap,'print of mX3.1')
//SearchAndOpenDoc(ExePath+'examples\boxprint2.xps');
Writeln('machine name is: '+getHostName)
Writeln('user name is: '+getUserName)
Writeln('proc id is: '+inttostr(currentProcessId))