User Tools

Site Tools


cdc:nos2.source:nam5871:lfggfn

LFGGFN

Table Of Contents

  • [00002] PROC LFGGFN(TABLE,FILECNT)
  • [00006] GET FILE NAMES.
  • [00081] PROC ABORT
  • [00083] PROC LFGGNT
  • [00084] PROC LFGLHDR
  • [00085] PROC LFGWL
  • [00086] PROC MESSAGE
  • [00088] PROC READH
  • [00089] PROC WRITER
  • [00158] FUNC ZFILL(NAME) C(10)

Source Code

LFGGFN.txt
  1. *DECK LFGGFN
  2. PROC LFGGFN(TABLE,FILECNT);
  3. BEGIN # GET FILE NAMES #
  4. *IF,DEF,IMS
  5. #
  6. ** LFGGFN - GET FILE NAMES.
  7. *
  8. * D.K. ENDO 81/12/15
  9. *
  10. * LFGGFN ATTEMPTS TO BUILD THE FILE NAME TABLE FROM THE INPUT
  11. * DIRECTIVES GIVEN.
  12. *
  13. * PROC LFNGFN(TABLE,FILECNT)
  14. *
  15. * ENTRY NONE.
  16. *
  17. * EXIT TABLE = TABLE CONTAINING FILE NAMES.
  18. * FILECNT = NUMBER OF ENTRIES IN TABLE.
  19. *
  20. * MESSAGES DIRECTIVE FILE EMPTY.
  21. * DIRECTIVE ERRORS DETECTED.
  22. *
  23. * METHOD
  24. *
  25. * WRITE HEADER FOR LISTING.
  26. * READ FIRST CARD.
  27. * IF FILE IS NOT EMPTY
  28. * THEN
  29. * FOR EACH CARD WHILE NOT END OF RECORD,
  30. * GET FIRST TOKEN.
  31. * IF TOKEN IS AN ASTERISK,
  32. * GET NEXT TOKEN.
  33. * IF TOKEN IS NOT THE KEYWORD -FILE-,
  34. * FLAG ERROR -- NO DIRECTIVE.
  35. * GET NEXT TOKEN.
  36. * FOR EACH TOKEN UNTIL END OF CARD,
  37. * SELECT CASE THAT APPLIES,
  38. * CASE 1(NAME):
  39. * IF LENGTH OF NAME IS NOT GREATER THAN MAXIMUM,
  40. * THEN,
  41. * PUT NAME IN TABLE
  42. * INCREMENT FILE NAME COUNT.
  43. * OTHERWISE,
  44. * FLAG ERROR -- FILE NAME TOO LONG.
  45. * CASE 2(DELIMITER):
  46. * IF TOKEN IS A COMMA
  47. * THEN,
  48. * IF COMMA WAS ALREADY SPECIFIED,
  49. * FLAG ERROR -- CONSECUTIVE COMMAS.
  50. * OTHERWISE,
  51. * FLAG ERROR -- ASTERISK IS INVALID DELIMITER.
  52. * CASE 3(UNKNOWN CHARACTER):
  53. * FLAG ERROR -- INVALID DELIMITER.
  54. * CASE 4(EOC):
  55. * SET END OF CARD FLAG.
  56. * IF NO FILE NAMES WERE SPECIFIED
  57. * FLAG ERROR -- NO FILE NAMES
  58. * IF LISTING FLAG SET OR ERROR DETECTED ON LINE,
  59. * WRITE DIRECTIVE CARD TO OUTPUT FILE.
  60. * READ NEXT CARD.
  61. * OTHERWISE,
  62. * SEND DAYFILE MESSAGE -- EMPTY DIRECTIVE FILE.
  63. * ABORT.
  64. * IF ERRORS DETECTED IN DIRECTIVE FILE
  65. * SEND DAYFILE MESSAGE -- DIRECTIVE ERRORS DETECTED.
  66. * ABORT.
  67. *
  68. #
  69. *ENDIF
  70. ARRAY TABLE [0:0] S(1); # TABLE TO PUT FILE NAMES #
  71. BEGIN
  72. ITEM TBL$ENT C(00,00,10); # FILE NAME ENTRY #
  73. ITEM TBL$NUM I(00,00,60); # NUMBER ENTRY #
  74. END
  75. ITEM FILECNT; # FILE COUNT #
  76. #
  77. **** PROC LFGGFN - XREF LIST BEGINS.
  78. #
  79. XREF
  80. BEGIN
  81. PROC ABORT; # ABORTS JOB ON REQUEST #
  82. ITEM INPUT; # DIRECTIVE FILE FET #
  83. PROC LFGGNT; # GET NEXT TOKEN #
  84. PROC LFGLHDR; # WRITES LISTING HEADER #
  85. PROC LFGWL; # WRITES LINE TO OUTPUT FILE #
  86. PROC MESSAGE; # SENDS MESSAGE TO DAYFILE #
  87. ITEM OUTPUT; # OUTPUT FET #
  88. PROC READH; # READ INPUT DIRECTIVE IN -H- FORMAT #
  89. PROC WRITER; # FLUSH CIO BUFFER AND WRITE EOR #
  90. END
  91. #
  92. ****
  93. #
  94. DEF ECODE1 # 1 #; # INDEX FOR MESSAGE ONE. #
  95. DEF ECODE2 # 2 #; # INDEX FOR MESSAGE TWO. #
  96. DEF ECODE3 # 3 #; # INDEX FOR MESSAGE THREE #
  97. DEF ECODE4 # 4 #; # INDEX FOR MESSAGE FOUR #
  98. DEF ECODE5 # 5 #; # INDEX FOR MESSAGE FIVE #
  99. DEF LFN$MXL # 7 #; # MAXIMUM LENGTH FOR FILE NAME #
  100. DEF TRNS$OK # 0 #; # STATUS RETURN AFTER SUCCESSFUL READ #
  101. CONTROL NOLIST; # LFGSTAN COMMON DECK #
  102. *CALL LFGSTAN
  103. CONTROL LIST;
  104. ITEM ABRTFLG B; # ABORT FLAG #
  105. ITEM CARDCNT I; # DIRECTIVE CARD COUNT #
  106. ITEM COL I; # POINTER TO CURRENT CHARACTER #
  107. ITEM COMMA$FLG B; # COMMA FLAG #
  108. ITEM DIR$FLG B; # DIRECTIVE FLAG #
  109. ITEM EOC B; # END OF CARD FLAG #
  110. ITEM ERRLINE B; # DIRECTIVE ERROR INDICATOR #
  111. ITEM I I; # SCRATCH ITEM #
  112. ITEM J I; # SCRATCH ITEM #
  113. ITEM LENGTH; # LENGTH OF TOKEN #
  114. ITEM LFN$FLG B; # LOCAL FILE NAME FLAG #
  115. ITEM LSTNG$ID; # LISTING I.D. #
  116. ITEM STATIS I; # STATUS RETURNED ON READ #
  117. ITEM TOKEN C(10); # TOKEN RETURNED FOR DIRECTIVE LINE #
  118. ITEM TYPE I; # TOKEN TYPE #
  119. ARRAY DIR$BUFF [0:9] S(1);
  120. BEGIN # DIRECTIVE LINE BUFFER #
  121. ITEM DB$LINE C(00,00,90) = [" "];
  122. ITEM DB$ZBYT I(09,00,60) = [0];
  123. END
  124. ARRAY DIR$ERROR [0:0] S(3);
  125. BEGIN # DIRECTIVE ERROR MESSAGE #
  126. ITEM DE$MSG C(00,00,27) = [" DIRECTIVE ERRORS DETECTED."];
  127. ITEM DE$ZBYT I(02,42,18) = [0];
  128. END
  129. ARRAY EMPTY$FILE [0:0] S(3);
  130. BEGIN
  131. ITEM EF$MSG C(00,00,22) = [" EMPTY DIRECTIVE FILE."];
  132. ITEM EF$ZBYT I(02,12,48) = [0];
  133. END
  134. DEF MXET # 5 #;
  135. ARRAY ERRMSG$TABLE [00:MXET] S(6);
  136. BEGIN
  137. ITEM ERRMSG C(00,00,50) =
  138. [" ",
  139. " **** DIRECTIVE INDICATOR -FILE- NOT FOUND. ",
  140. " **** FILE NAME MUST BE 1 TO 7 CHARACTERS. ",
  141. " **** FILE NAME MUST BE DELIMITED BY ONE COMMA.",
  142. " **** COMMA AND/OR BLANKS ARE ONLY LEGAL DELIM.",
  143. " **** AT LEAST ONE FILE NAME MUST BE SPECIFIED.",
  144. ];
  145. ITEM ERMS$ZBYT I(05,00,60) = [,
  146. 0,
  147. 0,
  148. 0,
  149. 0,
  150. 0,
  151. ];
  152. END
  153. SWITCH GFNSWTCH UNKNOWN,
  154. NAME,
  155. DELIM,
  156. EO$CARD;
  157. CONTROL EJECT;
  158. FUNC ZFILL(NAME) C(10);
  159. BEGIN
  160. ITEM NAME C(10);
  161. ITEM CTEMP1 C(1);
  162. ITEM CTEMP2 C(10);
  163. ITEM I I;
  164. # #
  165. # ZFILL CODE BEGINS HERE #
  166. # #
  167. FOR I=0 STEP 1 UNTIL 9 # FOR EACH CHARACTER IN NAME #
  168. DO
  169. BEGIN
  170. CTEMP1 = C<I,1>NAME;
  171. IF CTEMP1 EQ " " # CHARACTER IS BLANK #
  172. THEN
  173. BEGIN
  174. C<I,1>CTEMP2 = 0; # REPLACE BLANK WITH ZERO #
  175. END
  176. ELSE # CHARACTER IS NON-BLANK #
  177. BEGIN
  178. C<I,1>CTEMP2 = CTEMP1; # SAVE CHARACTER #
  179. END
  180. END
  181. ZFILL = CTEMP2; # RETURN ZERO FILLED NAME #
  182. RETURN; # **** RETURN **** #
  183. END
  184. CONTROL EJECT;
  185. # #
  186. # LFGGFN CODE BEGINS HERE #
  187. # #
  188. ABRTFLG = FALSE; # CLEAR ABORT FLAG #
  189. FILECNT = 0; # INITIALIZE FILE NAME COUNT #
  190. PAGEN = 1; # INITIALIZE PAGE COUNT #
  191. LSTNG$ID = DIR$LST; # SET LISTING ID #
  192. LFGLHDR(LSTNG$ID); # WRITE LISTING HEADER #
  193. READH(INPUT,DIR$BUFF[1],8,STATIS); # READ FIRST INPUT CARD #
  194. IF STATIS EQ TRNS$OK # IF READ WAS O.K. #
  195. THEN
  196. BEGIN # KEEP READING CARDS TILL NO MORE #
  197. FOR CARDCNT=0 STEP 1 WHILE STATIS EQ TRNS$OK
  198. DO
  199. BEGIN
  200. COL = 0; # SET COLUMN POINTER #
  201. EOC = FALSE; # CLEAR END OF CARD INDICATOR #
  202. ERRLINE = FALSE; # CLEAR ERROR LINE FLAG #
  203. COMMA$FLG = FALSE; # CLEAR COMMA FLAG #
  204. LFGGNT(TOKEN,COL,LENGTH,TYPE,DIR$BUFF[1]); # GET NEXT TOKEN #
  205. IF TOKEN EQ "*" # IF TOKEN IS -*-, THIS MUST #
  206. THEN # BE A DIRECTIVE INDICATOR #
  207. BEGIN
  208. LFGGNT(TOKEN,COL,LENGTH,TYPE,DIR$BUFF[1]); #GET NEXT TOKEN #
  209. IF TOKEN NQ "FILE" # IF TOKEN IS NOT -FILE- #
  210. THEN
  211. BEGIN # FLAG ERROR -- INVALID DIRECTIVE IND. #
  212. LFGWL(ERRMSG$TABLE[ECODE1],LSTNG$ID);
  213. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  214. ABRTFLG = TRUE; # SET ABORT FLAG #
  215. END
  216. LFGGNT(TOKEN,COL,LENGTH,TYPE,DIR$BUFF[1]); # GET NEXT TOKEN#
  217. DIR$FLG = TRUE; # SET DIRECTIVE FOUND FLAG #
  218. END
  219. LFN$FLG = FALSE; # CLEAR FILE NAME FLAG #
  220. FOR J=0 WHILE NOT EOC
  221. DO # FOR EACH TOKEN TILL END OF CARD #
  222. BEGIN
  223. GOTO GFNSWTCH[TYPE]; # GOTO APPROPRIATE PARAGRAPH #
  224. NAME:
  225. IF LENGTH LQ LFN$MXL # IF FILE NAME IS NOT TOO LONG #
  226. THEN
  227. BEGIN
  228. LFN$FLG = TRUE; # SET FILE NAME FLAG #
  229. FILECNT = FILECNT + 1; # INCREMENT FILE COUNT #
  230. TBL$ENT[FILECNT] = ZFILL(TOKEN); # PUT NAME INTO TABLE #
  231. COMMA$FLG = FALSE; # CLEAR COMMA FLAG #
  232. END
  233. ELSE # FILE NAME TOO LONG #
  234. BEGIN # FLAG ERROR -- FILE NAME TOO LONG #
  235. LFGWL(ERRMSG$TABLE[ECODE2],LSTNG$ID);
  236. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  237. ABRTFLG = TRUE; # SET ABORT FLAG #
  238. END
  239. GOTO NEXT;
  240. DELIM:
  241. IF TOKEN EQ "," # IF TOKEN IS COMMA #
  242. THEN
  243. BEGIN
  244. IF NOT COMMA$FLG # IF A COMMA WAS NOT PREVIOUSLY #
  245. THEN # SPECIFIED #
  246. BEGIN
  247. COMMA$FLG = TRUE; # SET COMMA FOUND FLAG #
  248. END
  249. ELSE # NO FILE NAME BETWEEN COMMAS #
  250. BEGIN # FLAG ERROR -- CONSECUTIVE COMMAS #
  251. LFGWL(ERRMSG$TABLE[ECODE3],LSTNG$ID);
  252. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  253. ABRTFLG = TRUE; # SET ABORT FLAG #
  254. END
  255. END
  256. ELSE # TOKEN MUST BE AN ASTERISK #
  257. BEGIN # FLAG ERROR -- INVALID DELIMITER #
  258. LFGWL(ERRMSG$TABLE[ECODE4],LSTNG$ID);
  259. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  260. ABRTFLG = TRUE; # SET ABORT FLAG #
  261. END
  262. GOTO NEXT;
  263. UNKNOWN: # FLAG ERROR -- INVALID DELIMITER #
  264. LFGWL(ERRMSG$TABLE[ECODE4],LSTNG$ID);
  265. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  266. ABRTFLG = TRUE; # SET ABORT FLAG #
  267. GOTO NEXT;
  268. EO$CARD:
  269. EOC = TRUE; # SET END OF CARD FLAG #
  270. NEXT:
  271. LFGGNT(TOKEN,COL,LENGTH,TYPE,DIR$BUFF[1]); # GET NEXT TOKEN#
  272. END
  273. IF NOT LFN$FLG AND # IF NO FILE NAME SPECIFIED #
  274. DIR$FLG
  275. THEN
  276. BEGIN # FLAG ERROR -- NO FILE NAME SPECIFIED #
  277. LFGWL(ERRMSG$TABLE[ECODE5],LSTNG$ID);
  278. ERRLINE = TRUE; # SET ERROR LINE FLAG #
  279. ABRTFLG = TRUE; # SET ABORT FLAG #
  280. END
  281. IF LISTFLG OR # IF LISTING WAS REQUESTED OR #
  282. ERRLINE # ERROR WAS DETECTED #
  283. THEN
  284. BEGIN # WRITE INPUT DIRECTIVE #
  285. LFGWL(DIR$BUFF,LSTNG$ID);
  286. END # READ NEXT CARD #
  287. READH(INPUT,DIR$BUFF[1],8,STATIS);
  288. END
  289. END
  290. ELSE # EMPTY DIRECTIVE FILE #
  291. BEGIN
  292. MESSAGE(EMPTY$FILE,0); # SEND MESSAGE TO DAYFILE #
  293. ABORT; # **** ABORT **** #
  294. END
  295. IF ABRTFLG # IF ERROR WAS DETECTED #
  296. THEN
  297. BEGIN
  298. MESSAGE(DIR$ERROR,0); # SEND MESSAGE TO DAYFILE #
  299. WRITER(OUTPUT); # FLUSH CIO BUFFER #
  300. ABORT; # **** ABORT **** #
  301. END
  302. RETURN; # **** RETURN **** #
  303. END # LFGGFN #
  304. TERM
cdc/nos2.source/nam5871/lfggfn.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator