Guest User

Untitled

a guest
Jun 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /*
  2. Pipe Operations from within ArmA. Copy of ArmALib Kegetys functions atm.
  3. slInit:
  4. "myPipe" call slInit
  5. Initializes scriptlink named pipe, name will be '\\.\pipe\scriptlink_myPipe'. Client
  6. can connect after this. Returns name of pipe if succeeded, or throws exception on error
  7.  
  8. slIsConnected:
  9. "myPipe" call slIsConnected
  10. returns boolean true if pipe 'myPipe' has a client connected to it, false otherwise
  11.  
  12. slReadData:
  13. "myPipe" call slReadData
  14. returns array of strings containing messages from the pipe that the client has written,
  15. or an emptry array if no data is waiting
  16.  
  17. slWriteData:
  18. ["myPipe", _data] call slWriteData
  19. Writes _data to pipe, data is converted to string if other than string trype
  20. Throws exception on error
  21.  
  22. slClose:
  23. "myPipe" call slClose
  24. Closes scriptlink pipe. Pipe is also closed automatically when client disconnects.
  25. */
  26.  
  27. #define __str "ION." + str ION_RTE_EXPORT_NUMBER + '.COMMAND|' + PIPE + '|' + DATA + ".ION";
  28. // ERROR, OPEN, CLOSE, ISOPEN, ISCONNECTED, READ, WRITE
  29.  
  30. #define __f \
  31. private ["_str", "_result"]; \
  32. _str = __str; \
  33. ION_RTE_EXPORT_NUMBER = ION_RTE_EXPORT_NUMBER + 1; \
  34. _result = call compile loadFile _str; \
  35. if (isNil "_result") exitWith { \
  36. throw "Self.Suicide(StupidUser)"; \
  37. false \
  38. }; \
  39. _result
  40.  
  41. // Allow using ION next to ArmALib if wished
  42. ION_slInit =
  43. {
  44. #define COMMAND OPEN
  45. #define PIPE _this
  46. #define DATA
  47. __f
  48. };
  49.  
  50. ION_slIsOpen =
  51. {
  52. #define COMMAND ISOPEN
  53. #define PIPE _this
  54. #define DATA
  55. __f
  56. };
  57.  
  58. ION_slClose =
  59. {
  60. #define COMMAND CLOSE
  61. #define PIPE _this
  62. #define DATA
  63. __f
  64. };
  65.  
  66. ION_slIsConnected =
  67. {
  68. #define COMMAND ISCONNECTED
  69. #define PIPE _this
  70. #define DATA
  71. __f
  72. };
  73.  
  74. ION_slReadData =
  75. {
  76. #define COMMAND READ
  77. #define PIPE _this
  78. #define DATA
  79. __f
  80. };
  81.  
  82. ION_slWriteData =
  83. {
  84. #define COMMAND WRITE
  85. #define PIPE (_this select 0)
  86. #define DATA (_this select 1)
  87. __f
  88. };
  89.  
  90. ION_slError =
  91. {
  92. #define COMMAND CLOSE
  93. #define PIPE _this
  94. #define DATA
  95. __f
  96. };
  97.  
  98. // If no ArmaLib found, emulate ArmALib
  99. if !(ArmALib) then
  100. {
  101. slInit = ION_slInit;
  102. slClose = ION_slClose;
  103. slIsConnectioned = ION_slIsConnectioned;
  104. slWriteData = ION_slWriteData;
  105. slReadData = ION_slReadData;
  106. };
Add Comment
Please, Sign In to add comment