-
Notifications
You must be signed in to change notification settings - Fork 0
/
SilkHelp.t
3545 lines (3545 loc) · 136 KB
/
SilkHelp.t
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
[ ] // ***************************************************************************
[ ] // * *
[ ] // * Silk Help Generator *
[ ] // * *
[ ] // * *
[ ] // * Created by: David Genrich Oct, 2001 *
[ ] // * *
[ ] // * Forked by: Alex Mekhovov Dec, 2009 *
[ ] // * *
[ ] // ***************************************************************************
[ ]
[ ] // ---------------------------------------------------------------------------
[+] // ------------------------------- COMMON CODE -------------------------------
[ ]
[ ] // ------- TYPE MAP ------
[+] type PAIR is record // Supplementary type {sKey, aValue} for type MAP
[ ] STRING sKey
[ ] ANYTYPE aValue
[ ]
[+] // Type MAP
[ ] // Description:
[ ] // Associative array, that stores list of pairs {sKey, aValue}.
[ ] // Key is of type STRING, while Value can be of any type.
[ ] // Any key in associative array must be unique:
[ ] // MAP mPatient = {...}
[ ] // {"sLastName", "Smith"}
[ ] // {"sFirstName", "John"}
[ ] // {"sSex", "M - male"}
[ ] // {"sAge", 100}
[ ] //
[ ] // Values of map can be accessed via MapGet/MapSet function:
[ ] // s = MapGet (mPatient, "sLastName");
[ ] // MapSet (mPatient, "sSp", "cat")
[ ] //
[ ] // You can also add values to the map without key. The unique key will be
[ ] // assigned automatically (this is done by MapGetNextHash function):
[ ] // MapAdd (mPatient, "cat") // + {"1", "cat"}
[ ] // MapAdd (mPatient, "tail") // + {"2", "tail"}
[ ] //
[ ] // To delete a value by key, use MapDelete:
[ ] // MapDelete (mPatient, "sAge")
[ ] //
[ ] // The function MapValueKeys returns list of keys, that have given value in a map:
[ ] // Print (MapValueKeys (mPatient, "cat")) -> {"sSp", "1"}
[ ] //
[ ] // To erase a value from map (that can be keyed by one or more keys), use
[ ] // MapErase function.
[ ] // MapErase (mPatient, "cat") // will erase both {"sSp","cat"} and {"1","cat"}
[ ] //
[ ] //***************************************************************************************
[ ] type MAP is LIST OF PAIR
[ ]
[+] //******************************************************************************
//**Function: BOOLEAN MapHasKey (mMap, f_sKey)
[ ] //Description: Returns true or false depending on whether mMap contains key f_sKey
[ ] //Arguments:
[ ] // MAP mMap
[ ] // STRING f_sKey
[ ] //Return codes: none
[ ] //Example:
[ ] // mNumbers = {...}
[ ] // {1, "one"}
[ ] // {2, "two"}
[ ] // {3, "three"}
[ ] // x = MapHasKey (mNumbers, 4) ? MapGet (4) : 0
[ ] //
[ ] //****************************************************************************
[+] BOOLEAN MapHasKey (MAP h, STRING f_sKey null)
[ ] BOOLEAN bRet = false
[ ] INTEGER i
[+] for(i=ListCount(h);i>0;i--)
[+] if(h[i].sKey == f_sKey)
[ ] bRet = true
[ ] break
[ ] return bRet
[ ]
[+] //******************************************************************************
//**Function: ANYTYPE MapGet (mMap, f_sKey)
[ ] //Description: Get value from a map by key
[ ] //Arguments:
[ ] // MAP mMap
[ ] // STRING f_sKey
[ ] //Return codes:
[ ] // ANYTYPE - value of mMap element with key f_sKey
[ ] //Example:
[ ] // sLastName = MapGet (mPatient, "sLastName")
[ ] //****************************************************************************
[+] ANYTYPE MapGet (MAP h, ANYTYPE f_sKey null)
[ ] ANYTYPE a = NULL
[ ] PAIR p
[+] for each p in h
[+] if (p.sKey == f_sKey)
[+] if(IsSet(p.aValue))
[ ] a = p.aValue
[ ] break
[ ] return a
[ ]
[+] //******************************************************************************
//**Function: void MapSet (mMap, f_sKey, f_aValue)
[ ] //Description: Set value in map for the given key
[ ] //Arguments:
[ ] // MAP mMap
[ ] // STRING f_sKey
[ ] // ANYTYPE f_aValue
[ ] //Return codes:
[ ] // none
[ ] //Example:
[ ] // MapSet (mCapitals, "Japan", "Tokyo")
[ ] //****************************************************************************
[+] void MapSet (out MAP h, ANYTYPE f_sKey null, ANYTYPE f_aValue null)
[ ] INTEGER i
[+] for i = 1 to ListCount (h)
[+] if h[i].sKey == f_sKey
[ ] h[i].aValue = f_aValue
[ ] return
[ ]
[ ] h += [MAP]{{f_sKey, f_aValue}}
[ ]
[+] //******************************************************************************
//**Function: LIST OF STRING MapKeys (mMap)
[ ] //Description: Returns list of all keys in a map
[ ] //Arguments:
[ ] // MAP mMap
[ ] //Return codes: list of keys
[ ] //Example:
[ ] // mPatient = {...}
[ ] // {"sLastName", "Ivanov"}
[ ] // {"sFirstName", "Petr"}
[ ] // {"sAge", 100}
[ ] // {"sSex", "M - male"}
[ ] // LIST OF STRING lsRequiredFileds = MapKeys (mPatient)
[ ] //
[ ] //****************************************************************************
[+] LIST OF STRING MapKeys (MAP mMap)
[ ] LIST OF STRING lsKeys
[ ] INTEGER i
[ ]
[+] for i = 1 to ListCount (mMap)
[+] if ListFind (lsKeys, mMap[i].sKey) == 0
[ ] lsKeys += {mMap[i].sKey}
[ ] return lsKeys
[ ]
[ ]
[ ]
[+] //******************************************************************************
//**Function: BOOLEAN ListMatchString(STRING f_sStringFind, LIST OF STRING f_lsList, INTEGER f_iLineStart optional,
//**INTEGER f_iLineStop optional, out INTEGER f_iReturnRow optional)
[ ] //Description: Find text in list (list element in text)
[ ] //Arguments:
[ ] // f_sStringFind - string to find
[ ] // f_lsList - list to search
[ ] // f_iLineStart - start row - optional
[ ] // f_iLineStop - stop row - optional
[ ] // f_iReturnRow - return row - optional
[ ] // f_bReverse - search in reverse order - optional, FALSE by default
[ ] //Return codes:
[ ] // TRUE if string is found in the list
[ ] // FALSE if not
[ ] // f_iReturnRow - return row - optional
[ ] //****************************************************************************
[+] BOOLEAN ListMatchString (STRING f_sStringFind, LIST OF STRING f_lsList, INTEGER f_iLineStart optional,
INTEGER f_iLineStop optional, out INTEGER f_iReturnRow optional, BOOLEAN f_bReverse optional)
[ ] INTEGER i = 0 // counter
[ ] INTEGER iStartLine = 1 // start line
[ ] INTEGER iStopLine = 1 // stop line
[ ] INTEGER iStep = 1 // loop step
[ ] BOOLEAN bReturn = FALSE // return value
[ ]
[+] if IsNull (f_bReverse)
[ ] f_bReverse = FALSE
[+] if IsNull (f_iLineStart)
[ ] f_iLineStart = 1
[+] if IsNull (f_iLineStop)
[ ] f_iLineStop = ListCount(f_lsList)
[ ]
[ ] iStartLine = f_bReverse ? f_iLineStop : f_iLineStart
[ ] iStopLine = f_bReverse ? f_iLineStart : f_iLineStop
[+] if (f_bReverse)
[ ] iStep = -1
[ ]
[+] for i = iStartLine to iStopLine step iStep
[+] if MatchStr ("*{f_lsList[i]}*", f_sStringFind)
[ ] bReturn = TRUE
[ ] f_iReturnRow = i
[ ] break
[ ] return (bReturn)
[ ]
[ ]
[+] //******************************************************************************
//**Function: BOOLEAN ListMatchPhoto(STRING f_sStringFind, LIST OF STRING f_lsList, INTEGER f_iLineStart optional,
//**INTEGER f_iLineStop optional, out INTEGER f_iReturnRow optional)
[ ] //Description: Find text in list (text list element)
[ ] //Arguments:
[ ] // f_sStringFind - string to find
[ ] // f_lsList - list to search
[ ] // f_iLineStart - start row - optional
[ ] // f_iLineStop - stop row - optional
[ ] // f_iReturnRow - return row - optional
[ ] // f_bReverse - search in reverse order - optional, FALSE by default
[ ] //Return codes:
[ ] // TRUE if string is found in the list
[ ] // FALSE if not
[ ] // f_iReturnRow - return row - optional
[ ] //****************************************************************************
[+] BOOLEAN ListMatchPhoto (STRING f_sStringFind, LIST OF STRING f_lsList, INTEGER f_iLineStart optional,
INTEGER f_iLineStop optional, out INTEGER f_iReturnRow optional, BOOLEAN f_bReverse optional)
[ ] INTEGER i = 0 // counter
[ ] INTEGER iStartLine = 1 // start line
[ ] INTEGER iStopLine = 1 // stop line
[ ] INTEGER iStep = 1 // loop step
[ ] BOOLEAN bReturn = FALSE // return value
[ ] INTEGER iFrom, iTo
[ ]
[+] if IsNull (f_bReverse)
[ ] f_bReverse = FALSE
[+] if IsNull (f_iLineStart)
[ ] f_iLineStart = 1
[+] if IsNull (f_iLineStop)
[ ] f_iLineStop = ListCount(f_lsList)
[ ]
[ ] iStartLine = f_bReverse ? f_iLineStop : f_iLineStart
[ ] iStopLine = f_bReverse ? f_iLineStart : f_iLineStop
[+] if (f_bReverse)
[ ] iStep = -1
[ ]
[+] for i = iStartLine to iStopLine step iStep
[ ]
[ ] iFrom = StrPos ("\", f_lsList[i], TRUE)
[+] if iFrom != 0
[ ] iFrom++
[ ]
[ ] iTo = StrPos (" ", f_lsList[i], iFrom)
[+] if iTo == 0
[ ] iTo = Len (f_lsList[i])
[ ]
[+] if MatchStr ("*{f_sStringFind}*", SubStr (f_lsList[i], iFrom, (iTo > iFrom ? (iTo - iFrom) : Len (f_lsList[i]))))
[ ] bReturn = TRUE
[ ] f_iReturnRow = i
[ ] break
[ ]
[+] if !bReturn
[+] for i = iStartLine to iStopLine step iStep
[+] if MatchStr ("*{f_sStringFind}*", f_lsList[i])
[ ] bReturn = TRUE
[ ] f_iReturnRow = i
[ ] break
[ ]
[ ]
[ ] return (bReturn)
[ ]
[ ]
[+] //******************************************************************************
//**Function: STRING ListToString(LIST OF STRING f_lsList, STRING f_sSeparator optional)
[ ] //Description: Converts list of strings to string separated by Separator
[ ] //Arguments:
[ ] // f_lsList - list of strings to convert
[ ] // f_sSeparator - separator string
[ ] //Return codes:
[ ] // STRING - output string
[ ] //****************************************************************************
[+] STRING ListToString(LIST OF STRING f_lsList, STRING f_sSeparator optional)
[ ] STRING sOut = (ListCount(f_lsList)==0) ? "" : f_lsList[1]
[ ] STRING s
[ ] INTEGER i
[+] if(IsNull(f_sSeparator))
[ ] f_sSeparator = Chr(10)
[+] for(i=2;i<=ListCount(f_lsList);i++)
[ ] sOut = "{sOut}{f_sSeparator}{f_lsList[i]}"
[ ] return sOut
[ ]
[+] // description
[ ] // f_lpList - input list
[ ] // f_iIndex - key index of list, 1 by default
[+] // example
[+] // LIST OF LIST OF STRING lls = {...}
[ ] // {"x", "bb", "cc"}
[ ] // {"i", "o", "a"}
[ ] // {"e", "r", "t", "p", "e"}
[ ] // print (ListOfListSortHoriz (lls, 3))
[ ] // >> {i, o, a}
[ ] // >> {x, bb, cc}
[ ] // >> {e, r, t, p, e}}
[+] LIST OF LIST OF ANYTYPE ListOfListSortHoriz (LIST OF LIST OF ANYTYPE f_llpList, int f_iIndex optional)
[ ] int i
[ ]
[+] if !IsNull (f_iIndex) && f_iIndex != 1
[+] for i = 1 to ListCount (f_llpList)
[+] if ListCount (f_llpList[i]) < f_iIndex
[ ] print ("*** Sublist #{i} is shorter then key position!")
[ ] return NULL
[ ] ListInsert (f_llpList[i], 1, f_llpList[i][f_iIndex])
[ ] ListSort (f_llpList)
[+] for i = 1 to ListCount (f_llpList)
[ ] ListDelete (f_llpList[i], 1)
[+] else
[ ] ListSort (f_llpList)
[ ]
[ ] return f_llpList
[ ]
[ ] // reverse horizontal and vertical rows
[+] LIST OF LIST OF ANYTYPE Transpone (LIST OF LIST OF ANYTYPE f_llpList)
[ ] int i, j, iLen = ListCount (f_llpList[1])
[ ] LIST OF LIST OF ANYTYPE llRet = {}
[ ]
[+] for i = 1 to iLen//ListCount (f_llpList)
[ ] ListAppend (llRet, {})
[+] for j = 1 to ListCount (f_llpList)//iLen
[ ] ListAppend (llRet[i], f_llpList[j][1])
[ ] ListDelete (f_llpList[j], 1)
[ ]
[ ] return llRet
[ ]
[+] // description
[ ] // f_lpList - input list
[ ] // f_iIndex - key index of list, 1 by default
[+] // example
[+] // LIST OF LIST OF STRING lls = {...}
[ ] // {"x", "bb", "cc"}
[ ] // {"i", "o", "a"}
[ ] // {"e", "r", "t"}
[ ] // print (ListOfListSortVert (lls, 1))
[ ] // >> {bb, cc, x}
[ ] // >> {o, a, i}
[ ] // >> {r, t, e}
[+] LIST OF LIST OF ANYTYPE ListOfListSortVert (LIST OF LIST OF ANYTYPE f_llpList, int f_iIndex optional)
[ ] return Transpone (ListOfListSortHoriz (Transpone (f_llpList), f_iIndex))
[ ]
[ ] // ---------------------------------------------------------------------------
[ ]
[ ]
[ ] // ----------------------------- CONFIGURATION -------------------------------
[ ]
[ ] STRING sVariant = "" // for variant sandboxes
[ ]
[ ] // List the directories to seach for help text
[+] list of SourceDirectories lsrSource = {...}
[ ] // {sDir, bUseSubDir}
[ ]
[ ] {"{SilkDir}AG_SoftAR", TRUE} // NOTE: SilkDir is a Runtime Compiler constant pointing to the root of automation scripts (C:\SilkTest\)
[ ] {"{SilkDir}GUICommon", TRUE}
[ ] {"{SilkDir}Common", TRUE}
[ ] {"{SilkDir}Common_Tools", TRUE}
[ ] {"{SilkDir}LMG_LabMicGUI", TRUE}
[ ]
[ ]
[ ] // File extensions to use
[+] list of string lsExtensions = {...}
[ ] "inc"
[ ] "t"
[ ]
[ ] // Path to directory with script
[ ] STRING sWorkingDir = "!WORK\silk_help_generator\"
[ ]
[ ] // In this folder group of functions = file name
[+] LIST OF STRING lsGroupFunctions = {...}
[ ] "Common"
[ ] "Common_Tools"
[ ]
[ ] // Rename authors
[+] MAP mAuthorReplace = {...}
[ ] // form to
[ ] {"vass Vasyl Evdokymov", "vass"}
[ ] {"Yaroslav Yakovets", "yyak"}
[ ]
[ ] // location to save the new 4Text file
[ ] string Save_4Text_Location = SilkDir + sWorkingDir
[ ]
[ ] string Orginal_4Text_Location = SYS_GetRegistryValue (HKEY_LOCAL_MACHINE, "SOFTWARE\Segue Software Inc\SilkTest\7.5", "DIRECTORY")
[ ]
[ ] // USE PHOTOS
[ ] boolean bUsePhotos = TRUE
[ ] STRING sPhotoServer = "\\ISD103\Photos\guys" // shared filder with photos
[ ]
[ ] // CREATE HTML HELP
[ ] boolean bCreateHTMLHelp = TRUE
[ ]
[ ] // delimeter for the html help file's
[ ] string sObjectDelimiter = "~"
[ ]
[ ] string sBaseAutomationFolder = SilkDir
[ ] string sHelpTitle = "Autotesting Team 4Test Help"
[ ] string sHTMLSaveLocation = SilkDir + sWorkingDir + "Helps\Help" + "_" + FormatDateTime (GetDateTime (), "mm_dd_hhmm")
[ ] string sHTMLTemplatesLocation = SilkDir + sWorkingDir + "\HTML_Templates"
[ ]
[ ] // DIVIDE TO MULTIPLE PROJECTS
[ ] boolean bMultipleProjects = TRUE
[+] list of MultipleProjects lrcProjects = {...}
[ ] // {sDir, sSaveTo, sName} //NOTE: if "sSaveTo" coincide - "sName" be coincide too (1-st in list)
[ ]
[ ] {"{SilkDir}AG_SoftAR", "AG_SoftAR", "AG_SoftAR"}
[ ] {"{SilkDir}GUICommon", "GUICommon", "GUICommon"}
[ ] {"{SilkDir}Common", "Common", "Common"}
[ ] {"{SilkDir}Common_Tools", "Common", "Common"}
[ ] {"{SilkDir}LMG_LabMicGUI", "LMG_LabMicGUI", "LabMicGUI"}
[ ]
[ ]
[ ] // print trace
[ ] BOOLEAN bTrace = FALSE
[ ]
[ ]
[ ] // --------------------------- DATA RECORDS --------------------
[+] type SourceDirectories is record
[ ] string sDir
[ ] boolean bUseSubDir
[+] type MultipleProjects is record
[ ] string sDir
[ ] string sSaveTo
[ ] string sName
[+] private type Stats is record
[ ] integer iFilesProcessed
[ ] integer iDirProcessed
[ ] integer iMethods
[ ] integer iFunctions
[ ] // integer iPropertyes // TODO: add
[+] private type DataRecord is record
[ ] string sType
[ ] string sURL
[+] private type GenHelp is record
[ ] string sKeyword
[ ] string sText
[ ] list of string lsExample
[+] private type Parameters is record
[ ] string sParam
[ ] string sDesc
[ ] boolean bOptional
[ ] list of string lsExample
[ ]
[ ] private list of DataRecord rcData
[ ] private list of DataRecord rcDataFunctions
[ ]
[ ] private Stats rcStat = {0,0, 0, 0}
[ ]
[ ] // ------------- GLOBAL VARIABLES ------------------------------
[ ] private string sCurrentFile
[ ] private integer tocTab = 0
[ ] private integer tocCount = 0
[ ] private string sCurrentDir
[ ]
[ ] string sFStart = "Function:"
[ ] string sMStart = "Method:"
[ ] string sPStart = "Property:"
[ ]
[ ] MAP mAuthors = {}
[ ]
[ ] // -------------- Directory Management -------------------------
[+] private InitializeDirectory()
[ ]
[ ] string sDir = Save_4Text_Location + "\SilkHelpGen_Temp"
[ ] string sOrgFile = Orginal_4Text_Location + "\4test.txt"
[ ] string sCopyTo = sDir + "\4test.txt"
[+] list of string lsHtmlCopy = {...}
[ ] "blank.htm"
[ ] "displayToc.js"
[ ] "tocParas.js"
[ ] "images\folder.gif"
[ ] "images\folderopen.gif"
[ ] "images\home.png"
[ ] "images\information.png"
[ ] "images\join.gif"
[ ] "images\joinbottom.gif"
[ ] "images\line.gif"
[ ] "images\minus_tree.gif"
[ ] "images\minusbottom.gif"
[ ] "images\page.gif"
[ ] "images\plus_tree.gif"
[ ] "images\plusbottom.gif"
[ ] "images\plus_silk.jpg"
[ ] "images\minus_silk.jpg"
[ ] "images\none.jpg"
[ ] "images\back.gif"
[ ] "images\forward.gif"
[ ] "images\down.gif"
[ ] "images\up.gif"
[ ] "images\user.gif"
[ ] "images\cut.gif"
[ ] "images\clippy.swf"
[ ]
[ ] string sFile
[ ] HFILE FileHandle
[ ] MultipleProjects rcProject
[ ]
[ ] // create the directory, or remove any existing files if it exists
[+] if (!SYS_DirExists (sDir))
[ ] SYS_MakeDir (sDir)
[+] else
[ ] RemoveFiles (GetFileNames(sDir))
[ ]
[ ] // copy the Segue 4test.txt into this new folder
[ ] SYS_CopyFile(sOrgFile, sCopyTo)
[ ]
[ ] // ******* CREATE HTML HELP ******
[+] if bCreateHTMLHelp
[+] if (!SYS_DirExists (sHTMLSaveLocation))
[ ] SYS_MakeDir (sHTMLSaveLocation)
[ ] SYS_MakeDir (sHTMLSaveLocation + "\images")
[ ] SYS_MakeDir (sHTMLSaveLocation + "\HelpAPI{sVariant}")
[ ] SYS_MakeDir (sHTMLSaveLocation + "\HelpAPI{sVariant}\API")
[ ] SYS_MakeDir (sHTMLSaveLocation + "\HelpAPI{sVariant}\Code")
[ ] SYS_MakeDir (sHTMLSaveLocation + "\js")
[ ]
[+] if bMultipleProjects
[+] for each rcProject in lrcProjects
[+] if !SYS_DirExists (sHTMLSaveLocation + "\HelpAPI{sVariant}\" + rcProject.sSaveTo)
[ ] SYS_MakeDir (sHTMLSaveLocation + "\HelpAPI{sVariant}\" + rcProject.sSaveTo)
[+] if !SYS_DirExists (sHTMLSaveLocation + "\HelpAPI{sVariant}\Code\" + rcProject.sSaveTo)
[ ] SYS_MakeDir (sHTMLSaveLocation + "\HelpAPI{sVariant}\Code\" + rcProject.sSaveTo)
[ ]
[+] else
[ ] // remove API files
[ ] RemoveFiles (GetFileNames(sHTMLSaveLocation + "\HelpAPI{sVariant}"))
[ ]
[+] if bMultipleProjects
[+] for each rcProject in lrcProjects
[ ] RemoveFiles (GetFileNames(sHTMLSaveLocation + "\HelpAPI{sVariant}\" + rcProject.sSaveTo))
[ ]
[ ]
[ ] // delete existing base files
[+] for each sFile in lsHtmlCopy
[+] if (SYS_FileExists(sHTMLSaveLocation + "\" + sFile))
[ ] SYS_RemoveFile(sHTMLSaveLocation + "\" + sFile)
[ ]
[ ] // copy base files
[+] for each sFile in lsHtmlCopy
[ ] sOrgFile = sHTMLTemplatesLocation + "\" + sFile
[ ] sCopyTo = sHTMLSaveLocation + "\" + sFile
[ ] SYS_CopyFile(sOrgFile, sCopyTo)
[ ]
[ ] // copy all js folder
[ ] SYS_Execute ("xcopy {sHTMLTemplatesLocation}\js {sHTMLSaveLocation}\js /S")
[ ]
[ ] // intialize the Table of Contents
[ ] FileHandle = FileOpen (sHTMLSaveLocation + "\tocTab{sVariant}.js", FM_WRITE)
[ ] FileWriteLine (FileHandle, "var tocTab = new Array();")
[ ] FileWriteLine (FileHandle, "")
[ ] FileWriteLine (FileHandle, "tocTab[0] = new Array (""0"", ""{sHelpTitle}"", ""HelpAPI{sVariant}/API/API_Home.htm"");")
[ ] FileWriteLine (FileHandle, "")
[ ] FileClose (FileHandle)
[ ]
[ ] // intialize the index file
[ ] FileHandle = FileOpen (sHTMLSaveLocation + "\index.html", FM_WRITE)
[ ] FileWriteLine (FileHandle, "<html>")
[ ] FileWriteLine (FileHandle, "<head>")
[ ] FileWriteLine (FileHandle, "<title>{sHelpTitle}</title>")
[ ] FileWriteLine (FileHandle, "<script language=""JavaScript"" src=""tocTab{sVariant}.js""></script>")
[ ] FileWriteLine (FileHandle, "<script language=""JavaScript"" src=""tocParas.js""></script>")
[ ] FileWriteLine (FileHandle, "<script language=""JavaScript"" src=""displayToc.js""></script>")
[ ] FileWriteLine (FileHandle, "</head>")
[ ] FileWriteLine (FileHandle, "<frameset cols=""280,*"" border=1 onload=""reDisplay('0',true);"">")
[ ] FileWriteLine (FileHandle, " <frame src=""blank.htm"" name=""toc"">")
[ ] FileWriteLine (FileHandle, " <frame src=""blank.htm"" name=""content"">")
[ ] FileWriteLine (FileHandle, "</frameset>")
[ ] FileWriteLine (FileHandle, "")
[ ]
[ ] FileClose (FileHandle)
[ ]
[ ]
[+] private RemoveTempDir()
[ ]
[ ] string sDir = Save_4Text_Location + "\SilkHelpGen_Temp"
[ ]
[ ] // create the directory, or remove any existing files if it exists
[ ] RemoveFiles (GetFileNames(sDir))
[ ]
[ ] // remove the directory
[ ] SYS_RemoveDir (sDir)
[ ]
[ ]
[+] private list of string GetFileNames(string sDir, boolean bUseExt optional)
[ ] list of string lsFileNames
[ ] LIST OF FILEINFO lfFiles
[ ] INTEGER iCount
[ ] string sFullFile, sExt
[ ]
[+] if IsNull(bUseExt)
[ ] bUseExt = false
[ ]
[ ] lfFiles = SYS_GetDirContents (sDir)
[ ]
[+] for iCount = 1 to ListCount (lfFiles)
[+] if (!lfFiles[iCount].bIsDir)
[ ] sFullFile = "{sDir}\{lfFiles[iCount].sName}"
[ ]
[+] if (bUseExt)
[ ] sExt = GetFileExtension(lfFiles[iCount].sName)
[+] if sExt != ""
[+] if (ListFind(lsExtensions, sExt) > 0)
[ ] ListAppend(lsFileNames, sFullFile)
[+] else
[ ] ListAppend(lsFileNames, sFullFile)
[ ]
[ ] return lsFileNames
[ ]
[+] private list of string GetAPIFiles(string sDir)
[ ] list of string lsFileNames
[ ] LIST OF FILEINFO lfFiles
[ ] INTEGER iCount
[ ] string sFullFile
[ ]
[ ] lfFiles = SYS_GetDirContents (sDir)
[ ]
[+] for iCount = 1 to ListCount (lfFiles)
[+] if (!lfFiles[iCount].bIsDir)
[ ] sFullFile = "{lfFiles[iCount].sName}"
[ ]
[ ] ListAppend(lsFileNames, sFullFile)
[ ]
[ ] return lsFileNames
[ ]
[+] private string GetFileExtension (string sFileName)
[ ]
[ ] STRING sExtension = ""
[ ]
[ ] INTEGER iDotPos = StrPos (".", sFileName)
[+] if (iDotPos == 0)
[ ] sExtension = ""
[+] else
[ ] sExtension = SubStr (sFileName, iDotPos+1)
[ ]
[ ] return (sExtension)
[ ]
[+] private string GetSaveToFolder()
[ ] integer iPos = 0
[ ] MultipleProjects rcProject
[ ] list of string lsProjectsDir = {}
[ ] string sFullDir
[ ] string sFind = ""
[ ]
[+] if (bMultipleProjects)
[+] for each rcProject in lrcProjects
[ ] ListAppend(lsProjectsDir, rcProject.sDir)
[ ]
[+] if (Left(sCurrentDir, Len(rcProject.sDir)) == rcProject.sDir)
[ ] sFind = rcProject.sDir
[ ]
[+] if sFind != ""
[ ] iPos = ListFind(lsProjectsDir, sFind)
[+] if iPos > 0
[ ] sFullDir = sHTMLSaveLocation + "\HelpAPI{sVariant}\" + lrcProjects[iPos].sSaveTo + "\"
[+] else
[ ] sFullDir = sHTMLSaveLocation + "\HelpAPI{sVariant}\"
[+] else
[ ] sFullDir = sHTMLSaveLocation + "\HelpAPI{sVariant}\"
[ ]
[ ] return sFullDir
[ ]
[ ]
[+] private list of string GetSubDirectories(string sDir)
[ ] list of string lsDirs
[ ] LIST OF FILEINFO lfFiles
[ ] INTEGER iCount
[ ] string sFullDir
[ ]
[ ] lfFiles = SYS_GetDirContents (sDir)
[ ]
[+] for iCount = 1 to ListCount (lfFiles)
[+] if (lfFiles[iCount].bIsDir)
[ ] sFullDir = sDir + "\" + lfFiles[iCount].sName
[ ] ListAppend(lsDirs, sFullDir)
[ ]
[ ] return lsDirs
[ ]
[+] private RemoveFiles(list of string lsFileNames)
[ ] string sFile
[ ]
[+] for each sFile in lsFileNames
[+] if (SYS_FileExists(sFile))
[ ] SYS_RemoveFile(sFile)
[ ]
[ ]
[ ] // ------------- Help Processing --------------------------------
[+] private ProcessDirectory(SourceDirectories rcDir)
[ ]
[ ] list of string lsFileNames
[ ] list of string lsSubDir
[ ] string sFile, sDir
[ ]
[ ] print("")
[ ] print("** Processing Directory: {rcDir.sDir} ....")
[ ] rcStat.iDirProcessed++
[ ] sCurrentDir = rcDir.sDir
[ ]
[ ] lsFileNames = GetFileNames(rcDir.sDir, true)
[ ]
[+] for each sFile in lsFileNames
[ ]
[+] if bTrace
[ ] print(" -- Processing File: {sFile} ....")
[ ]
[ ] rcStat.iFilesProcessed++
[ ]
[ ] sCurrentFile = StrTran(sFile, sBaseAutomationFolder + "\", ".\")
[ ]
[ ] // call code to process
[ ] GenerateHelp(sFile, rcDir.sDir)
[ ]
[ ]
[ ] // process sub-directories
[+] if rcDir.bUseSubDir
[ ] lsSubDir = GetSubDirectories(rcDir.sDir)
[ ]
[+] for each sDir in lsSubDir
[ ] ProcessDirectory({sDir, rcDir.bUseSubDir})
[ ]
[ ]
[ ]
[ ] // ------------- Help Generation --------------------------------
[+] private GenerateHelp(string sFile, string sDir)
[ ] list of string lsCodeLines
[ ] list of string lsHelpCode
[ ] string sLine, sGroup = "none"
[ ] boolean bFoundStart = false
[ ] boolean bFoundEnd = false
[ ] list of GenHelp lsGenHelp
[ ] integer i, j, k, iStr = 0
[ ]
[ ] LIST OF STRING lsFuncNew
[ ] STRING sPrefix
[ ] INTEGER iFrom, iTo
[ ] BOOLEAN bFuncStart
[ ]
[ ] STRING sTCName = ""
[ ] STRING sTCAuthor = ""
[ ] LIST OF STRING lsCode = {}
[ ] INTEGER iPos, n = 0
[ ] STRING sCodeLine, sFolder
[ ]
[ ] lsCodeLines = SYS_GetFileContents(sFile)
[+] for each sLine in lsCodeLines
[ ] iStr++
[ ] i=StrPos("//", sLine)
[ ]
[+] if (i == 0) && (Len (Trim (sLine)) == Len ("[ ]"))
[ ] i=StrPos("[ ]", sLine)
[ ]
[+] if((i > 0)) //**Function:
[+] if (!bFoundStart)
[+] if (StrPos(sFStart, sLine) > 0 || StrPos(sMStart, sLine) > 0 || StrPos(sPStart, sLine) > 0)
[ ] ListAppend(lsHelpCode, sLine) // line is part of help
[ ] bFoundStart = TRUE
[+] else
[ ] ListAppend(lsHelpCode, sLine) // line is part of help
[+] else
[+] if (bFoundStart)
[ ] ListDelete(lsHelpCode, ListCount(lsHelpCode))
[ ]
[ ] lsFuncNew = {}
[ ] iFrom = 0
[ ] iTo = 0
[ ] bFuncStart = FALSE
[ ] sPrefix = ""
[ ]
[+] for j = 1 to ListCount (lsHelpCode)
[+] if (StrPos ("(", lsHelpCode[j]))
[ ] iFrom = j
[ ] iTo = j
[ ] sPrefix = SubStr (lsHelpCode[j], 1, StrPos (":", lsHelpCode[j]))
[ ]
[+] if (StrPos (")", lsHelpCode[j]))
[ ] iTo = j
[ ] break
[ ]
[ ]
[+] if ListCount (lsHelpCode) > 0
[+] for j = iFrom to iTo
[ ] ListDelete (lsHelpCode, 1)
[ ]
[+] for j = iStr to ListCount (lsCodeLines)
[ ]
[+] if !bFuncStart
[+] if ListCount (lsFuncNew) >= 1
[ ] lsFuncNew += {lsCodeLines[j]}
[ ]
[+] if ((StrPos("[+]", lsCodeLines[j]) > 0) || (StrPos("[-]", lsCodeLines[j]) > 0)) && (StrPos("(", lsCodeLines[j]) > 0)
[ ] lsFuncNew += {lsCodeLines[j]}
[ ]
[+] if (StrPos(")", lsCodeLines[j]) > 0)
[ ] lsCode = {}
[ ]
[ ] lsFuncNew = {ListToString (lsFuncNew, "<br>[ ] // ")}
[ ]
[ ] bFuncStart = TRUE
[ ] n = 0
[+] else
[+] if (bFuncStart) && (ListCount (lsFuncNew) > 0)
[ ]
[ ] sCodeLine = lsCodeLines[j]
[ ]
[+] if (StrPos ("[", sCodeLine) == 0) || (Trim (SubStr (sCodeLine, 1, StrPos ("[", sCodeLine) - 1)) != "") // add ...[] for line with shift+enter
[ ]
[+] if StrPos ("[", lsCode[ListCount (lsCode)]) != 0
[ ] iPos = StrPos ("[", lsCode[ListCount (lsCode)])
[ ]
[ ] sCodeLine = StrTran (SubStr (lsCode[ListCount (lsCode)], 1, iPos), "[", " ") + sCodeLine
[ ]
[ ] // found end of code
[+] if (StrPos ("[", sCodeLine) > 0) && (StrPos ("[", lsFuncNew[1]) >= StrPos ("[", sCodeLine))
[ ]
[ ] n += StrPos ("[", lsFuncNew[1]) - StrPos ("[", sCodeLine)
[ ] n++
[ ]
[ ] lsCode = lsFuncNew + lsCode
[ ]
[ ] lsCode[1] = StrTran(lsCode[1], "[+]", "[+]<!-->[+]</-->") // link with [+]
[ ] lsCode[1] = StrTran(lsCode[1], "[-]", "[+]<!-->[+]</-->") // link with [-]
[ ] lsCode[1] = StrTran(lsCode[1], "[ ] //", "[shiftenter]") // mark delete [ ] (shift+enter)
[ ]
[ ] lsCode[1] = lsCode[1] + "<br><!-->Begin</-->" // begin of collapse block
[ ]
[+] for j = 1 to n
[ ] lsCode += {"{Replicate (" ", n - j)}<!-->End</--><br>"} // end of collapse block
[ ]
[ ] break
[ ]
[+] if (StrPos ("[+]", sCodeLine) > 0) || (StrPos ("[-]", sCodeLine) > 0)
[ ]
[ ] n++
[ ] sCodeLine = StrTran(sCodeLine, "[+]", "[+]<!-->[+]</-->") // link with [+]
[ ] sCodeLine = StrTran(sCodeLine, "[-]", "[+]<!-->[+]</-->") // link with [-]
[ ] sCodeLine = sCodeLine + "<br><!-->Begin</-->" // begin of collapse block
[+] else
[ ] sCodeLine = sCodeLine + "<br>"
[ ]
[+] if j < ListCount (lsCodeLines) && (StrPos ("[", lsCodeLines[j+1]) > 0)
[+] if StrPos ("[", sCodeLine) > StrPos ("[", lsCodeLines[j+1])
[+] for k = 1 to (StrPos ("[", sCodeLine) - StrPos ("[", lsCodeLines[j+1]))
[ ] n--
[ ] sCodeLine = sCodeLine + "<!-->End</-->" // end of collapse block
[ ]
[ ] lsCode += {sCodeLine}
[ ]
[ ]
[ ]
[+] if ListCount (lsFuncNew) > 0
[ ] lsFuncNew[1] = StrTran (lsFuncNew[1], "[+]", "[-]")
[ ] lsFuncNew[1] = StrTran (lsFuncNew[1], "[-]", sPrefix)
[ ] lsHelpCode = lsFuncNew + lsHelpCode
[ ]
[ ] bFoundEnd = TRUE
[ ]
[+] if (bFoundEnd)
[ ]
[ ] // find class for method (if needed)
[ ]
[+] for each sLine in lsHelpCode
[ ]
[+] if (StrPos (sFStart, sLine) > 0) && (StrPos ("_Frame.inc", SubStr (sFile, StrPos ("\", sFile, TRUE) + 1)) == 0) // if function - generate group
[ ]
[+] if SubStr (sFile, StrPos (".", sFile, TRUE)) == ".t" // if TestCase - generate group: User functions - filename
[ ] sGroup = SubStr (sFile, StrPos ("\", sFile, TRUE) + 1)
[ ] sGroup = "User functions - " + SubStr (sGroup, 1, StrPos (".", sGroup, TRUE) - 1)
[ ]
[ ] // find TC name and get TC author
[+] for j = iStr to ListCount (lsCodeLines)
[ ]
[ ] // TC name
[ ] iPos = StrPos("] testcase", lsCodeLines[j])
[+] if iPos > 0
[ ] sTCName = Trim (SubStr (lsCodeLines[j], iPos + 10))
[ ] sTCName = StrTran (sTCName, chr (9), " ")
[ ] sTCName = Trim (SubStr (sTCName, 1, StrPos (" ", sTCName) ))
[ ]
[ ]
[ ] // Author TC
[ ] iPos = StrPos("Author:", lsCodeLines[j])
[+] if iPos > 0
[ ] sTCAuthor = Trim (SubStr (lsCodeLines[j], iPos + 7))
[ ] break
[ ]
[ ]
[ ] break
[ ]
[+] for each sFolder in lsGroupFunctions // if Common - generate group: filename
[ ]
[+] if StrPos (sFolder, sDir) > 0
[ ] sGroup = SubStr (sFile, StrPos ("\", sFile, TRUE) + 1)
[ ] sGroup = SubStr (sGroup, 1, StrPos (".", sGroup, TRUE) - 1)
[ ] break
[ ]
[+] else
[ ] sGroup = SubStr (sDir, StrPos ("\", sDir, TRUE) + 1)
[ ] break
[ ]
[ ]
[+] else if (StrPos (sMStart, sLine) > 0) || (StrPos ("_Frame.inc", SubStr (sFile, StrPos ("\", sFile, TRUE) + 1)) > 0) // if method - generate class
[ ]
[ ] lsHelpCode[1] = StrTran (lsHelpCode[1], sFStart, sMStart)
[ ]
[+] for j = iStr to 1 step -1
[ ]
[+] if ( StrPos ("[+] window ", lsCodeLines[j]) > 0 ) || ( StrPos ("[-] window ", lsCodeLines[j]) > 0 ) // || ( StrPos ("] WINDOW ", lsCodeLines[j]) > 0 )
[ ] sGroup = StrTran (lsCodeLines[j], chr (9), " ")
[ ] sGroup = RTrim (sGroup)
[ ] sGroup = LTrim (SubStr (sGroup, StrPos (" ", sGroup, TRUE ) + 1))
[ ] break
[ ]
[+] else if StrPos ("] winclass ", lsCodeLines[j]) > 0
[ ] sGroup = SubStr (lsCodeLines[j], StrPos ("] winclass ", lsCodeLines[j]) + 11)
[ ] sGroup = RTrim (SubStr (sGroup, 1, StrPos (":", sGroup) == 0 ? Len (sGroup) : StrPos (":", sGroup) - 1))
[ ] break
[ ]
[ ]
[ ]
[ ]
[ ] lsHelpCode = FormatHelp(lsHelpCode, sGroup, sTCName, sTCAuthor, lsCode) // add group or class if it not set
[+] if(ListCount(lsHelpCode)>0)
[ ] lsGenHelp = ExtractHelp(lsHelpCode)
[ ] SaveHelp(lsGenHelp)
[ ] lsGenHelp = {}
[ ] lsHelpCode = {}
[ ] bFoundEnd = FALSE
[ ] bFoundStart = FALSE
[ ]
[ ] // repeat until end of file (list in this case)
[ ]
[ ]
[ ] // ******* CREATE HTML HELP ******
[+] if bCreateHTMLHelp
[ ] GenerateDataHelp(sFile)
[ ]
[+] private GenerateDataHelp(string sFile)
[ ] list of string lsCodeLines
[ ] list of string lsHelpCode
[ ] string sLine, sOrginLine
[ ] string sStart = "[ ] type "
[ ] string sEnd1 = "[+]"
[ ] string sEnd2 = "[-]"
[ ] boolean bFoundStart = false
[ ] boolean bFoundEnd = false
[ ] list of string lsGenHelp
[ ]
[ ] lsCodeLines = SYS_GetFileContents(sFile)
[ ]
[+] for each sOrginLine in lsCodeLines
[ ]
[ ] sLine = Ltrim (sOrginLine) // becouse before may be tabs and witespases
[+] if (!bFoundStart)
[ ] sLine = StrTran(sLine, "[+", "[ ")
[ ] sLine = StrTran(sLine, "[-", "[ ")
[+] if (Left(sLine, 9) == sStart)
[ ] bFoundStart = TRUE
[ ] ListAppend(lsHelpCode, sLine)
[+] else
[+] if (Left(sLine, 3) == sEnd1) || (Left(sLine, 3) == sEnd2)
[ ] bFoundEnd = TRUE
[+] else
[ ] // line is part of help
[ ] ListAppend(lsHelpCode, sLine)
[ ]
[+] if (bFoundEnd)
[ ] lsGenHelp = ExtractDataHelp(lsHelpCode)
[ ] CreateDataHTMLHelp(lsGenHelp)
[ ] lsGenHelp = {}
[ ] lsHelpCode = {}
[ ] bFoundEnd = FALSE
[ ]
[ ] sLine = StrTran(sLine, "[+", "[ ")
[ ] sLine = StrTran(sLine, "[-", "[ ")
[+] if (Left(sLine, 9) == sStart)
[ ] bFoundStart = TRUE
[ ] ListAppend(lsHelpCode, sLine)
[+] else
[ ] bFoundStart = FALSE
[ ]
[ ] // repeat until end of file (list in this case)
[ ]
[ ]
[ ]
[+] type Attributes is record
[ ] string sAttribute
[ ] string sReplaceStr
[ ]
[+] private list of string FormatHelp(list of string lsHelp, string sGroup, string sTCName, string sTCAuthor, list of string lsCode)
[ ] list of string lsResult = {}
[ ] list of string lsTmp = {}
[ ] string sTmp
[+] list of Attributes lsFAttr = {...}
[ ] {" Group:", " @group:"}
[ ] {sFStart, " @function:"}
[ ] {"Return codes:", " @returns:"}
[ ] {"Arguments:", " @parameter:"}
[ ] {"Description:", " @notes:"}
[ ] {"Example:", " @example:"}
[ ] {"Author:", " @author:"}
[+] list of Attributes lsMAttr = {...}
[ ] {" Class:", " @class:"}
[ ] {sMStart, " @method:"}
[ ] {"Return codes:", " @returns:"}
[ ] {"Arguments:", " @parameter:"}
[ ] {"Description:", " @notes:"}
[ ] {"Example:", " @example:"}
[ ] {"Author:", " @author:"}
[+] list of Attributes lsPAttr = {...}
[ ] {"Class:", " @class:"}
[ ] {sPStart, " @property:"}
[ ] {"Description:", " @notes:"}
[ ]
[+] MAP mFAttr = {...}
[ ] {" @group:", {" Group:", "*Group:", "//Group:"} }
[ ] {" @function:", {sFStart} }
[ ] {" @returns:", {"Return codes:", "Return:", "Returns:", "Result:", "Return values:", "Return value"} }