Autostart.Mod 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (* Aos, Copyright 2001, Pieter Muller, ETH Zurich *)
  2. MODULE Autostart; (** AUTHOR "be"; PURPOSE "Execute the commands in the Autostart section of Configuration.XML"; *)
  3. IMPORT XML, XMLObjects, Commands, Configuration, KernelLog;
  4. CONST
  5. Trace = TRUE;
  6. PROCEDURE Run*;
  7. VAR enum: XMLObjects.Enumerator; p: ANY; e: XML.Element; value: XML.String;
  8. autostart : XML.Element;
  9. msg: ARRAY 128 OF CHAR; res: WORD;
  10. BEGIN
  11. autostart := Configuration.GetSection("Autostart");
  12. IF autostart # NIL THEN
  13. enum := autostart.GetContents();
  14. WHILE enum.HasMoreElements() DO
  15. p := enum.GetNext();
  16. IF p IS XML.Element THEN
  17. e := p(XML.Element); value := e.GetAttributeValue("value");
  18. IF (value^ # "") THEN
  19. IF Trace THEN KernelLog.String("Autostart: executing "); KernelLog.String(value^); KernelLog.Ln END;
  20. Commands.Call(value^, {Commands.Wait}, res, msg);
  21. IF (res # 0) THEN
  22. KernelLog.String("Autostart: error executing "); KernelLog.String(value^); KernelLog.String(": ");
  23. IF (msg # "") THEN KernelLog.String(msg)
  24. ELSE KernelLog.String("res = "); KernelLog.Int(res, 0)
  25. END;
  26. KernelLog.Ln
  27. END
  28. END
  29. END
  30. END
  31. END;
  32. END Run;
  33. END Autostart.
  34. System.Free Autostart ~
  35. EditTools.OpenAscii Configuration.XML~
  36. Configuration.Init
  37. Aos.Call Autostart.Run ~