ProgArgs.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // Body of ProgArgs interface.
  3. // This file implements the code of the ProgArgs.cp file.
  4. // kjg December 1999.
  5. //
  6. // The reason that this module is implemented as a Java class is
  7. // that the name CPmain has special meaning to the compiler, so
  8. // it must be imported secretly in the implementation.
  9. //
  10. package CP.ProgArgs;
  11. import CP.CPmain.CPmain;
  12. public class ProgArgs
  13. {
  14. public static int ArgNumber()
  15. {
  16. if (CP.CPmain.CPmain.args == null)
  17. return 0;
  18. else
  19. return CP.CPmain.CPmain.args.length;
  20. }
  21. public static void GetArg(int num, char[] str)
  22. {
  23. int i;
  24. if (CP.CPmain.CPmain.args == null) {
  25. str[0] = '\0';
  26. } else {
  27. for (i = 0;
  28. i < str.length && i < CP.CPmain.CPmain.args[num].length();
  29. i++) {
  30. str[i] = CP.CPmain.CPmain.args[num].charAt(i);
  31. }
  32. if (i == str.length)
  33. i--;
  34. str[i] = '\0';
  35. }
  36. }
  37. public static void GetEnvVar(char[] ss, char[] ds)
  38. {
  39. String path = CP.CPJ.CPJ.MkStr(ss);
  40. String valu = System.getProperty(path);
  41. int i;
  42. for (i = 0;
  43. i < valu.length() && i < ds.length;
  44. i++) {
  45. ds[i] = valu.charAt(i);
  46. }
  47. if (i == ds.length)
  48. i--;
  49. ds[i] = '\0';
  50. }
  51. } // end of public class ProgArgs