Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. (*
  2.     Copyright 2022 Anton Krotov
  3.  
  4.     This file is part of CEdit.
  5.  
  6.     CEdit is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     CEdit is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with CEdit. If not, see <http://www.gnu.org/licenses/>.
  18. *)
  19.  
  20. MODULE Args;
  21.  
  22. IMPORT SYSTEM, KOSAPI;
  23.  
  24.  
  25. VAR
  26.  
  27.         argc*: INTEGER;
  28.  
  29.  
  30. PROCEDURE ptr2str (ptr: INTEGER; VAR s: ARRAY OF CHAR);
  31. VAR
  32.         i, n: INTEGER;
  33. BEGIN
  34.         i := -1;
  35.         n := LEN(s) - 1;
  36.         REPEAT
  37.                 INC(i);
  38.                 SYSTEM.GET(ptr, s[i]);
  39.                 INC(ptr)
  40.         UNTIL (i = n) OR (s[i] = 0X);
  41.         s[i] := 0X
  42. END ptr2str;
  43.  
  44.  
  45. PROCEDURE GetArg* (n: INTEGER; VAR s: ARRAY OF CHAR);
  46. BEGIN
  47.         IF n = 0 THEN
  48.                 ptr2str(KOSAPI.GetName(), s)
  49.         ELSIF (n = 1) & (argc = 2) THEN
  50.                 ptr2str(KOSAPI.GetCommandLine(), s)
  51.         ELSE
  52.                 s[0] := 0X
  53.         END
  54. END GetArg;
  55.  
  56.  
  57. PROCEDURE main;
  58. VAR
  59.         c: CHAR;
  60. BEGIN
  61.         SYSTEM.GET(KOSAPI.GetCommandLine(), c);
  62.         argc := ORD(c # 0X) + 1
  63. END main;
  64.  
  65.  
  66. BEGIN
  67.         main
  68. END Args.