0 BEGIN PGM 90401_EN MM 1 ;NC program for extracting the file name from 2 ;a complete path. The control saves the path 3 ;in the calling program in QS1 and transfers 4 ;it to this program. 5 ;The program separates the file name from 6 ;this string. The string is searched for the 7 ;"\" and the part of the string before it is 8 ;removed. This step is repeated until no more 9 ;"\" characters are found. Then the control 10 ;removes the file name extension ".h" so that 11 ;only the file name remains. 12 ;The control returns it in QS1 to the calling 13 ;program. 14 ; 15 ;Select file from path, whereby the character 16 ;to find is "\" 17 QS2 = "\" 18 ; 19 LBL 1 ;Begin of loop 20 ; 21 ;Search string QS1 for "\" 22 Q50 = INSTR( SRC_QS1 SEA_QS2 BEG0 ) 23 ;The result in Q50 is the place at which the 24 ;"\" was found 25 ; 26 ;Increase the result of Q50 by 1 27 Q52 = Q50 + 1 28 ; 29 ;Read out the entire length of the string, 30 ;save it in Q53 31 Q53 = STRLEN( SRC_QS1 ) 32 ; 33 ;Entire length of the string -1 34 Q55 = Q53 - 1 35 ;If the INSTR command does not fine the "\" 36 ;character, it return the length of the string 37 ;beginning with place 1. If the "\" character 38 ;is no longer contained in QS1, the control 39 ;jumps to the "END" label. 40 FN 9: IF +Q50 EQU +Q53 GOTO LBL "END" 41 ; 42 ;Length of the string - all characters up 43 ;to "\" 44 Q54 = Q53 - Q52 45 QS1 = SUBSTR( SRC_QS1 BEGQ52 LENQ54 ) 46 ; 47 ;Jump to LBL 1 48 FN 9: IF +0 EQU +0 GOTO LBL 1 49 ; 50 ;Remove the file extension 51 ;File name extracted with extension 52 LBL "END" 53 ; 54 ;Remove file name extension, e.g. ".h" 55 ;Q56 = total length of string 56 ;(file name + extension) -2 57 Q56 = Q53 - 2 58 ;Read out file name 59 QS1 = SUBSTR( SRC_QS1 BEG0 LENQ56 ) 60 ; 61 ;Program end; the file name in QS1 is 62 ;transferred to the calling program 63 END PGM 90401_EN MM