source: trunk/NewView/CmdLineParameterUnit.pas@ 350

Last change on this file since 350 was 350, checked in by RBRi, 16 years ago

copyright change

  • Property svn:eol-style set to native
File size: 21.3 KB
RevLine 
[23]1Unit CmdLineParameterUnit;
2
3// NewView - a new OS/2 Help Viewer
[350]4// Copyright 2006-2009 Ronald Brill (rbri at rbri dot de)
[42]5// This software is released under the GNU Public License - see readme.txt
[23]6
7// Helper functions to address the command line parameters newview
8// is started with
9
10Interface
11
12uses
[32]13 Os2Def,
14 BseTib,
15 BseDos,
[23]16 SysUtils,
17 Classes,
18 PMWIN,
[42]19 StringUtilsUnit,
20 DebugUnit;
[23]21
[78]22CONST
23 ENV_DEBUG = 'NEWVIEW_DEBUG';
[23]24
[76]25
[42]26 TYPE EParsingFailed=CLASS(Exception);
27
[23]28 TYPE
29 TWindowPosition = record
30 left: longint;
31 bottom: longint;
32 width: longint;
33 height: longint;
34 end;
35 TYPE
36 TCmdLineParameters = class
37 private
[109]38 commandLine : AnsiString;
[23]39 showUsageFlag : boolean;
[42]40 searchFlag : boolean;
41 globalSearchFlag : boolean;
[23]42 language : string;
[259]43 showIndexFlag : boolean;
[23]44 helpManagerFlag : boolean;
[69]45 helpManagerWindow : HWND;
[23]46 windowPositionFlag: boolean;
47 windowPosition: TWindowPosition;
48 ownerWindow : integer;
[109]49 windowTitle : AnsiString;
50 parsedFileNames : AnsiString;
51 parsedRawFileNames : AnsiString;
52 fileNames : AnsiString;
53 parsedSearchText : AnsiString;
54 searchText : AnsiString;
[78]55 debugEnabled : boolean;
[147]56 nhmDebugMessages : TStringList; // for better debugging strange situations
[23]57
[67]58 FUNCTION handleSwitchWithValue(const aSwitchString : String; const aSwitch : String; var aValue : String) : Boolean;
[119]59 PROCEDURE parseSwitch(const aSwitchString : String);
[109]60 PROPERTY getParsedFileNames : AnsiString read parsedFileNames;
61 PROPERTY getParsedSearchText : AnsiString read parsedSearchText;
[42]62
[23]63 public
[78]64 PROPERTY isDebugEnabled : boolean read debugEnabled;
[32]65 PROPERTY getShowUsageFlag : boolean read showUsageFlag;
[42]66 PROPERTY getSearchFlag : boolean read searchFlag;
67 PROPERTY getGlobalSearchFlag : boolean read globalSearchFlag;
[32]68 PROPERTY getLanguage : string read language;
[259]69 PROPERTY getShowIndexFlag : boolean read showIndexFlag;
[32]70 PROPERTY getHelpManagerFlag : boolean read helpManagerFlag;
[122]71 FUNCTION setHelpManagerFlag(const aNewValue : boolean) : boolean;
[69]72 PROPERTY getHelpManagerWindow : HWND read helpManagerWindow;
[32]73 PROPERTY getWindowPositionFlag : boolean read windowPositionFlag;
74 PROPERTY getWindowPosition : TWindowPosition read windowPosition;
75 PROPERTY getOwnerWindow : integer read ownerWindow;
[109]76 PROPERTY getWindowTitle : AnsiString read windowTitle;
77 PROPERTY getSearchText : AnsiString read searchText;
[42]78
[128]79 FUNCTION getFileNames(const aShowNewViewHelpIfNoFileSpecifiedFlag : Boolean) : AnsiString;
80
[65]81 PROCEDURE writeDetailsTo(aStrings : TStrings);
[80]82 PROCEDURE logDetails;
[122]83 PROCEDURE parseCmdLine(const aCmdLineString : AnsiString);
[82]84 FUNCTION getOwnHelpFileName: String;
[147]85 PROCEDURE addNhmDebugMessage(const aString : String);
[23]86 end;
87
[342]88
89 // add all file name parts of aFileNameString to the result
90 // check for containing environment vars
91 // and include all help files if the environment var points
92 // to a directory
93 PROCEDURE ParseAndExpandFileNames(const aFileNameString: String; aResult: TStrings );
94
95
[42]96 // returns a string containing the whole
97 // command line parametes
[119]98 FUNCTION nativeOS2GetCmdLineParameter : AnsiString;
[23]99
100
101Implementation
[54]102uses
[76]103 DOS,
[147]104 FileUtilsUnit,
105 VersionUnit;
[23]106
[65]107 PROCEDURE TCmdLineParameters.writeDetailsTo(aStrings : TStrings);
108 var
109 tmpWindowPosition : TWindowPosition;
[147]110 i : integer;
[65]111 begin
[147]112 aStrings.Add('---- Version ----');
113 aStrings.Add(' ' + GetAppVersion);
114 aStrings.Add('');
115
116 aStrings.Add('---- Command Line ----');
[78]117 aStrings.Add('''' + commandLine + '''');
118 aStrings.Add('isDebugEnabled: ' + boolToStr(isDebugEnabled));
[128]119
[65]120 aStrings.Add('parsed infos:');
[78]121 aStrings.Add(' showUsageFlag: ' + boolToStr(getShowUsageFlag));
122 aStrings.Add(' searchFlag: ' + boolToStr(getSearchFlag));
[128]123 aStrings.Add(' fileNames(true): ' + getFileNames(true));
124 aStrings.Add(' fileNames(false): ' + getFileNames(false));
[78]125 aStrings.Add(' parsedFileNames: ' + getParsedFileNames);
126 aStrings.Add(' searchText: ' + getSearchText);
127 aStrings.Add(' parsedSearchText: ' + getParsedSearchText);
128 aStrings.Add(' globalSearchFlag: ' + boolToStr(getGlobalSearchFlag));
129 aStrings.Add(' language: ' + getLanguage);
[259]130 aStrings.Add(' showIndexFlag: ' + boolToStr(getShowIndexFlag));
[78]131 aStrings.Add(' helpManagerFlag: ' + boolToStr(getHelpManagerFlag));
132 aStrings.Add(' helpManagerWindow: ' + LongWordToStr(getHelpManagerWindow));
133 aStrings.Add(' windowPositionFlag: ' + boolToStr(getWindowPositionFlag));
[65]134
135 tmpWindowPosition := getWindowPosition;
[78]136 aStrings.Add(' windowPosition: '
[65]137 + intToStr(tmpWindowPosition.left) + ', '
138 + intToStr(tmpWindowPosition.bottom) + ', '
139 + intToStr(tmpWindowPosition.width) + ', '
140 + intToStr(tmpWindowPosition.height)
141 );
[78]142 aStrings.Add(' ownerWindow: ' + intToStr(getOwnerWindow));
143 aStrings.Add(' windowTitle: ' + getWindowTitle);
[147]144
145 if nil <> nhmDebugMessages then
146 begin
147 aStrings.Add('');
148 aStrings.Add('---- NHM DebugMessages ----');
149 for i := 0 to nhmDebugMessages.count-1 do
150 begin
151 aStrings.Add(' ' + nhmDebugMessages[i]);
152 end;
153 end;
154
[65]155 end;
156
157
[80]158 PROCEDURE TCmdLineParameters.LogDetails;
159 var
160 tmpWindowPosition : TWindowPosition;
161 begin
162 LogEvent(LogStartup, '''' + commandLine + '''');
163 LogEvent(LogStartup, 'isDebugEnabled: ' + boolToStr(isDebugEnabled));
164 LogEvent(LogStartup, 'parsed infos:');
165
166 LogEvent(LogStartup, ' showUsageFlag: ' + boolToStr(getShowUsageFlag));
167 LogEvent(LogStartup, ' searchFlag: ' + boolToStr(getSearchFlag));
[128]168 LogEvent(LogStartup, ' fileNames(true): ' + getFileNames(true));
169 LogEvent(LogStartup, ' fileNames(false): ' + getFileNames(false));
[80]170 LogEvent(LogStartup, ' parsedFileNames: ' + getParsedFileNames);
171 LogEvent(LogStartup, ' searchText: ' + getSearchText);
172 LogEvent(LogStartup, ' parsedSearchText: ' + getParsedSearchText);
173 LogEvent(LogStartup, ' globalSearchFlag: ' + boolToStr(getGlobalSearchFlag));
174 LogEvent(LogStartup, ' language: ' + getLanguage);
[259]175 LogEvent(LogStartup, ' showIndexFlag: ' + boolToStr(getShowIndexFlag));
[80]176 LogEvent(LogStartup, ' helpManagerFlag: ' + boolToStr(getHelpManagerFlag));
177 LogEvent(LogStartup, ' helpManagerWindow: ' + LongWordToStr(getHelpManagerWindow));
178 LogEvent(LogStartup, ' windowPositionFlag: ' + boolToStr(getWindowPositionFlag));
179
180 tmpWindowPosition := getWindowPosition;
181 LogEvent(LogStartup, ' windowPosition: '
182 + intToStr(tmpWindowPosition.left) + ', '
183 + intToStr(tmpWindowPosition.bottom) + ', '
184 + intToStr(tmpWindowPosition.width) + ', '
185 + intToStr(tmpWindowPosition.height)
186 );
187 LogEvent(LogStartup, ' ownerWindow: ' + intToStr(getOwnerWindow));
188 LogEvent(LogStartup, ' windowTitle: ' + getWindowTitle);
189 end;
190
191
[122]192 Function TCmdLineParameters.setHelpManagerFlag(const aNewValue : boolean) : boolean;
[25]193 begin
194 helpManagerFlag := aNewValue;
195 result := helpManagerFlag;
196 end;
197
198
[122]199 Procedure TCmdLineParameters.parseCmdLine(const aCmdLineString : AnsiString);
[23]200 var
[67]201 tmpState : (WHITESPACE, QUOTE, SWITCH, FILENAME, TEXT);
202 tmpCurrentParsePosition : integer;
203 tmpQuoted : boolean;
[42]204 tmpCurrentChar : char;
[109]205 tmpWhitespace : AnsiString;
206 tmpQuote : AnsiString;
207 tmpSwitch : AnsiString;
[93]208 tmpEnvDebug : String;
[23]209 begin
[76]210 // first adjust logging
[78]211 debugEnabled := false;
[93]212 tmpEnvDebug := GetEnv(ENV_DEBUG);
213
214 if tmpEnvDebug <> '' then
[76]215 begin
[78]216 debugEnabled := true;
[93]217 SetLogAspects(tmpEnvDebug);
[76]218 end;
[25]219
[76]220 LogEvent(LogStartup, 'ParseCommandLine: "' + aCmdLineString + '"');
[23]221
[76]222 // store the original string for debugging
223 commandLine := aCmdLineString;
[23]224
[76]225 // reset the whole object
226 showUsageFlag := false;
227 searchFlag := false;
228 globalSearchFlag := false;
229 language := '';
[259]230 showIndexFlag := false;
[76]231 helpManagerFlag := false;
232 helpManagerWindow := 0;
233 windowPositionFlag := false;
234 ownerWindow := 0;
235 windowTitle := '';
[78]236 parsedSearchText := '';
237 parsedFileNames := '';
238 parsedRawFileNames := '';
[23]239
[76]240 try
241 // start parsing
242 tmpState := WHITESPACE;
243 tmpWhitespace := '';
244 tmpSwitch := '';
245 tmpQuote := '';
246 tmpQuoted := false;
247 tmpCurrentParsePosition := 1;
248 while tmpCurrentParsePosition <= length(aCmdLineString) do
249 begin
250 tmpCurrentChar := aCmdLineString[tmpCurrentParsePosition];
[67]251
[76]252 Case tmpCurrentChar of
253 ' ' :
254 begin
255 Case tmpState of
[67]256
[76]257 WHITESPACE :
258 begin
259 tmpWhitespace := tmpWhitespace + tmpCurrentChar;
260 end;
[67]261
[76]262 QUOTE :
263 begin
264 tmpQuote := tmpQuote + tmpCurrentChar;
265 end;
[67]266
[76]267 SWITCH :
268 begin
269 if tmpQuoted then
270 begin
271 tmpSwitch := tmpSwitch + tmpCurrentChar;
272 end
273 else
274 begin
275 parseSwitch(tmpSwitch);
276 tmpState := WHITESPACE;
277 tmpWhitespace := tmpCurrentChar;
278 end
279 end;
[67]280
[76]281 FILENAME :
282 begin
283 if tmpQuoted then
284 begin
[78]285 parsedFileNames := parsedFileNames + tmpCurrentChar;
286 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]287 end
288 else
289 begin
290 tmpState := WHITESPACE;
291 tmpWhitespace := tmpCurrentChar;
292 end
293 end;
[25]294
[76]295 TEXT :
296 begin
297 if tmpQuoted then
298 begin
[78]299 parsedSearchText := parsedSearchText + tmpCurrentChar;
[76]300 end
301 else
302 begin
303 tmpState := WHITESPACE;
304 tmpWhitespace := tmpCurrentChar;
305 end
306 end;
307 end;
308 end;
[67]309
[76]310 '/', '-' :
311 begin
312 Case tmpState of
313 WHITESPACE :
314 begin
315 tmpState := SWITCH;
316 tmpSwitch := '';
317 end;
[67]318
[76]319 QUOTE :
320 begin
321 tmpState := SWITCH;
322 tmpSwitch := '';
323 end;
[67]324
[76]325 SWITCH :
326 begin
327 parseSwitch(tmpSwitch);
328 tmpSwitch := '';
329 end;
[67]330
[76]331 FILENAME :
332 begin
[78]333 parsedFileNames := parsedFileNames + tmpCurrentChar;
334 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]335 end;
[67]336
[76]337 TEXT :
338 begin
[78]339 parsedSearchText := parsedSearchText + tmpCurrentChar;
[76]340 end;
341 end;
342 end;
[42]343
[76]344 '"' :
345 begin
346 if tmpQuoted then
347 begin
348 tmpQuoted := false;
349 Case tmpState of
350 FILENAME :
351 begin
[78]352 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]353 end;
[78]354 TEXT :
355 begin
356 parsedSearchText := parsedSearchText + tmpCurrentChar;
357 end;
[76]358 end;
359 end
360 else
361 begin
[78]362 tmpQuoted := true;
[76]363 Case tmpState of
364 WHITESPACE :
365 begin
366 tmpState := QUOTE;
367 tmpQuote := tmpCurrentChar;
368 end;
369 FILENAME :
370 begin
[78]371 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]372 end;
373 end;
374 end;
375 end;
[67]376
[76]377 // any other char
378 else
379 begin
380 Case tmpState of
[67]381
[76]382 WHITESPACE :
383 begin
[78]384 if length(parsedFileNames) > 0 then
[76]385 begin
386 tmpState := TEXT;
[78]387 parsedSearchText := parsedSearchText + tmpWhitespace + tmpCurrentChar;
[76]388 end
389 else
390 begin
391 tmpState := FILENAME;
[78]392 parsedFileNames := parsedFileNames + tmpCurrentChar;
393 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]394 end;
395 end;
[67]396
[76]397 QUOTE :
398 begin
[78]399 if length(parsedFileNames) > 0 then
[76]400 begin
401 tmpState := TEXT;
[78]402 parsedSearchText := parsedSearchText + tmpQuote + tmpCurrentChar;
[76]403 end
404 else
405 begin
406 tmpState := FILENAME;
[78]407 parsedFileNames := parsedFileNames + tmpCurrentChar;
408 parsedRawFileNames := parsedRawFileNames + tmpQuote + tmpCurrentChar;
[76]409 end;
410 end;
[67]411
[76]412 SWITCH :
413 begin
414 tmpSwitch := tmpSwitch + tmpCurrentChar;
415 end;
[67]416
[76]417 FILENAME :
418 begin
[78]419 parsedFileNames := parsedFileNames + tmpCurrentChar;
420 parsedRawFileNames := parsedRawFileNames + tmpCurrentChar;
[76]421 end;
422
423 TEXT :
424 begin
[78]425 parsedSearchText := parsedSearchText + tmpCurrentChar;
[76]426 end;
427 end;
428 end;
[42]429 end;
[67]430 inc(tmpCurrentParsePosition);
[42]431 end;
[23]432
[67]433 // ok all chars are processed, but maybe we have something to do
434 Case tmpState of
435 SWITCH :
436 begin
437 parseSwitch(tmpSwitch);
438 end;
[76]439 end;
[42]440 except
441 on e:EParsingFailed do
442 begin
443 showUsageFlag := true;
444 end;
445 end;
446
[78]447 // remove blanks
[109]448 fileNames := AnsiStrTrim(getParsedFileNames);
449 searchText := AnsiStrTrim(getParsedSearchText);
[42]450
[78]451 if getGlobalSearchFlag
452 AND (getParsedSearchText = '')
453 then
454 begin
455 fileNames := '';
456 searchText := parsedRawFileNames;
457 end;
458
459 // to be compatible with the old one we have to ignore
460 // the quotes
461 if not getGlobalSearchFlag
462 AND (not getSearchFlag)
463 then
464 begin
[109]465 searchText := AnsiStrTrimChars(searchText, ['"']);
[78]466 end;
467
[42]468 LogEvent(LogStartup, 'Parameters parsed');
[80]469 LogDetails;
[42]470 end;
471
472
[67]473 Function TCmdLineParameters.handleSwitchWithValue(const aSwitchString : String; const aSwitch : String; var aValue : String) : Boolean;
[42]474 var
475 tmpText : String;
[67]476 tmpValueStartPos : integer;
[42]477 tmpSwitchLength : integer;
478 begin
479 tmpSwitchLength := Length(aSwitch);
[67]480 tmpText := copy(aSwitchString, 1, tmpSwitchLength);
[42]481 tmpText := lowercase(tmpText);
[23]482
[42]483 if (lowercase(aSwitch) = tmpText) then
484 begin
[67]485 tmpValueStartPos := tmpSwitchLength;
486 inc(tmpValueStartPos);
487 if aSwitchString[tmpValueStartPos] = ':' then
[42]488 begin
[67]489 inc(tmpValueStartPos);
[42]490 end;
[23]491
[67]492 aValue := copy(aSwitchString, tmpValueStartPos, Length(aSwitchString) - tmpValueStartPos+ 1);
[42]493 result := true;
494 exit;
495 end;
496 result := false;
497 end;
[23]498
499
[42]500 Function ParseWindowPositionPart(const aPart: String; const aScreenDimension: longint): longint;
501 Var
502 tmpPart : String;
503 Begin
504 if aPart = '' then
505 raise EParsingFailed.Create('Missing position element');
[23]506
[42]507 if StrEndsWithIgnoringCase(aPart, 'P') then
508 begin
509 tmpPart := copy(aPart, 1, length(aPart)-1);
510 if tmpPart = '' then
511 raise EParsingFailed.Create('Missing position element');
[23]512
[42]513 Result := StrToInt(tmpPart);
514 if Result < 0 then
515 Result := 0;
516 if Result > 100 then
517 Result := 100;
518 Result := Round(Result / 100 * aScreenDimension);
519 end
520 else
521 begin
522 Result := StrToInt(aPart);
523 end;
524 end;
[23]525
[42]526 Function ParseWindowPosition(const aParamValue: String): TWindowPosition;
527 Var
528 tmpParts : TStringList;
[147]529 tmpScreenWidth : longint;
530 tmpScreenHeight : longint;
[42]531 Begin
532 tmpParts := TStringList.Create;
533 StrExtractStrings(tmpParts, aParamValue, [','], '\');
[23]534
[147]535 tmpScreenWidth := WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
536 tmpScreenHeight := WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
[23]537
[147]538 result.Left := ParseWindowPositionPart(tmpParts[0], tmpScreenWidth);
539 result.Bottom := ParseWindowPositionPart(tmpParts[1], tmpScreenHeight);
540
541 result.Width := ParseWindowPositionPart(tmpParts[2], tmpScreenWidth);
[42]542 if result.Width < 50 then
543 result.Width := 50;
[23]544
[147]545 result.Height := ParseWindowPositionPart(tmpParts[3], tmpScreenHeight);
[42]546 if result.Height < 50 then
547 result.Height := 50;
548
549 tmpParts.Destroy;
[23]550 end;
551
552
[119]553 Procedure TCmdLineParameters.parseSwitch(const aSwitchString : String);
[42]554 var
555 tmpCurrentChar : char;
556 tmpValue : String;
557 begin
558 // lang
[67]559 if handleSwitchWithValue(aSwitchString, 'lang', tmpValue) then
[42]560 begin
561 language := tmpValue;
562 exit;
563 end;
564
565 // title
[67]566 if handleSwitchWithValue(aSwitchString, 'title', tmpValue) then
[42]567 begin
568 windowTitle := tmpValue;
569 exit;
570 end;
571
572 // HM
[67]573 if handleSwitchWithValue(aSwitchString, 'hm', tmpValue) then
[42]574 begin
575 try
576 helpManagerWindow := StrToInt(tmpValue);
577 helpManagerFlag := true;
578 except
579 on e:Exception do
580 begin
581 showUsageFlag := true;
582 end;
583 end;
584 exit;
585 end;
586
587 // owner
[67]588 if handleSwitchWithValue(aSwitchString, 'owner', tmpValue) then
[42]589 begin
590 try
591 ownerWindow := StrToInt(tmpValue);
592 except
593 on e:Exception do
594 begin
595 showUsageFlag := true;
596 end;
597 end;
598 exit;
599 end;
600
601 // pos
[67]602 if handleSwitchWithValue(aSwitchString, 'pos', tmpValue) then
[42]603 begin
604 windowPosition := ParseWindowPosition(tmpValue);
605 windowPositionFlag := true;
606 exit;
607 end;
608
609 // check the next char
[67]610 // TODO check for other invalid chars
611 tmpCurrentChar := aSwitchString[1];
[42]612 Case tmpCurrentChar of
613 'h', 'H', '?' :
614 begin
615 showUsageFlag := true;
616 end;
617
618 's', 'S' :
619 begin
620 searchFlag := true;
621 end;
622
[259]623 'i', 'I' :
624 begin
625 showIndexFlag := true;
626 end;
627
[42]628 'g', 'G' :
629 begin
630 globalSearchFlag := true;
631 end;
632
633 else
634 begin
635 raise EParsingFailed.Create('Unsupported switch');
636 end;
637 end;
[23]638 end;
639
[25]640
[128]641 FUNCTION TCmdLineParameters.getFileNames(const aShowNewViewHelpIfNoFileSpecifiedFlag : Boolean) : AnsiString;
642 var
643 tmpOwnHelpFileName : String;
644 begin
645 // user hasn't requested any particular file
646 // at startup, so if the option is set,
647 // load the NewView help file
648 if aShowNewViewHelpIfNoFileSpecifiedFlag
649 AND (fileNames = '')
650 AND not getGlobalSearchFlag then
651 begin
652 tmpOwnHelpFileName := getOwnHelpFileName;
653 if FileExists(tmpOwnHelpFileName) then
654 begin
655 result := tmpOwnHelpFileName;
656 end;
657 end
658 else
659 begin
660 result := fileNames;
661 end;
662 end;
663
664
[82]665 FUNCTION TCmdLineParameters.getOwnHelpFileName: String;
666 var
667 tmpLanguage : String;
[54]668 begin
[82]669 tmpLanguage := getLanguage;
670 if tmpLanguage = '' then
671 begin
672 tmpLanguage := GetEnv(LanguageEnvironmentVar)
673 end;
674
675 result := FindDefaultLanguageHelpFile('NewView', tmpLanguage);
[54]676 end;
677
678
[147]679 PROCEDURE TCmdLineParameters.addNhmDebugMessage(const aString : String);
680 begin
681 if nil = nhmDebugMessages then
682 begin
683 nhmDebugMessages := TStringList.Create;
684 end;
685
686 nhmDebugMessages.add(aString);
687 end;
688
689
[342]690 PROCEDURE ParseAndExpandFileNames(const aFileNameString : String; aResult: TStrings);
691 var
692 i : longint;
693 tmpFileNamesList: TStringList;
694 tmpItem: String;
695 tmpEnvironmentVarValue: string;
696 begin
697 LogEvent(LogDebug, 'ParseAndExpandFileNames "' + aFileNameString + '"');
698
699 tmpFileNamesList := TStringList.Create;
700
701 StrExtractStrings(tmpFileNamesList, aFileNameString, [HELP_FILE_DELIMITER, PATH_SEPARATOR], #0);
702 for i := 0 to tmpFileNamesList.Count - 1 do
703 begin
704 tmpItem := tmpFileNamesList[i];
705
706 // is this a environment var
707 tmpEnvironmentVarValue := GetEnv(tmpItem);
708 if DosError = 0 then
709 begin
710 // environment var exists
711 LogEvent(LogStartup, ' Environment var found; translated to: "' + tmpEnvironmentVarValue + '"');
712 ParseAndExpandFileNames(tmpEnvironmentVarValue, aResult);
713 end
714 else if DirectoryExists(tmpItem) then
715 begin
716 ListFilesInDirectory(tmpItem, '*' + HELP_FILE_EXTENSION, true, aResult);
717 end
718 else
719 begin
720 aResult.Add(tmpItem);
721 end;
722 end;
723
724 tmpFileNamesList.Destroy;
725 end;
726
727
[119]728 FUNCTION nativeOS2GetCmdLineParameter : AnsiString;
[42]729 VAR
730 tmpPtib : PTIB; // thread information block
731 tmpPpib : PPIB; // process information block
732 tmpCmd : PCHAR;
[109]733 tmpParams : PCHAR;
[42]734
735 BEGIN
736 // ask the system
737 DosGetInfoBlocks(tmpPtib, tmpPpib);
738 tmpCmd := tmpPpib^.pib_pchcmd;
739 // the fist element (null terminated) is the
740 // called command itself
741 // skip to the next null terminated string
742 // these are the parameters
[109]743 tmpParams := tmpCmd + StrLen(tmpCmd) + 1;
744
[119]745 result := '';
746 AnsiSetString(result, tmpParams, StrLen(tmpParams));
[42]747 END;
[147]748
749
[23]750END.
Note: See TracBrowser for help on using the repository browser.