A question came up yesterday, I thought I'd share the solution. A customer has several systems with PC-DMIS, and runs the same programs on all. One of these has a network issue, which requires some operator intervention before proceeding. They wanted a way to alert the operator, but only on this particular system. We came up with a short exercise which identified the name of the system, and if it were the one in question, displayed a message to the operator. Here is how we did it.
We wrote a short DOS batch file with the following command -
IPCONFIG /ALL > JUNK.TXT
and we called this file "GET_NAME.BAT" and placed it in the PC-DMIS install folder. Then we added these commands to the top of the program (note that the 1st line is 'wrapped') -
EXTERNALCOMMAND/NO_DISPLAY, WAIT ; C:\PCDMISW_V37B\GET_NAME.BAT
FPTR =FILE/OPEN,JUNK.TXT,READ
V1 =FILE/READLINE,FPTR,{T1}
V2 =FILE/READLINE,FPTR,{T2}
V3 =FILE/READLINE,FPTR,{T3}
V4 =FILE/READLINE,FPTR,{T4}
COMMENT/OPER,NO,T4
ASSIGN/V5 = INDEX(T4,"CMM2")
COMMENT/OPER,NO,V5
IF/V5
COMMENT/OPER,NO,Check the network please
END_IF/
The program runs the batch file, which displays a load of information and re-directs the output into a text file called "JUNK.TXT". The only thing we want out of this text file is on the 4th line, se we read and ignore the 1st 3 lines. On the 4th line, we read it and then check for the existence of the string "CMM2". This 4th line might have had something like the following -
Host Name . . . . . . . . . . . . : Desktop_CMM2PC_AJD
but we only need to determine that it contains any unique character set which will identify it as the one we are searching for.
With this, we were able to make use of an EXTERNAL command and a few FILE I/O commands to achieve what this customer wanted. I doubt that many people will be able to use this utility as-is, but I decided to post it here as an example to stir people into thinking about what else they can write to make their jobs a little easier.
We wrote a short DOS batch file with the following command -
IPCONFIG /ALL > JUNK.TXT
and we called this file "GET_NAME.BAT" and placed it in the PC-DMIS install folder. Then we added these commands to the top of the program (note that the 1st line is 'wrapped') -
EXTERNALCOMMAND/NO_DISPLAY, WAIT ; C:\PCDMISW_V37B\GET_NAME.BAT
FPTR =FILE/OPEN,JUNK.TXT,READ
V1 =FILE/READLINE,FPTR,{T1}
V2 =FILE/READLINE,FPTR,{T2}
V3 =FILE/READLINE,FPTR,{T3}
V4 =FILE/READLINE,FPTR,{T4}
COMMENT/OPER,NO,T4
ASSIGN/V5 = INDEX(T4,"CMM2")
COMMENT/OPER,NO,V5
IF/V5
COMMENT/OPER,NO,Check the network please
END_IF/
The program runs the batch file, which displays a load of information and re-directs the output into a text file called "JUNK.TXT". The only thing we want out of this text file is on the 4th line, se we read and ignore the 1st 3 lines. On the 4th line, we read it and then check for the existence of the string "CMM2". This 4th line might have had something like the following -
Host Name . . . . . . . . . . . . : Desktop_CMM2PC_AJD
but we only need to determine that it contains any unique character set which will identify it as the one we are searching for.
With this, we were able to make use of an EXTERNAL command and a few FILE I/O commands to achieve what this customer wanted. I doubt that many people will be able to use this utility as-is, but I decided to post it here as an example to stir people into thinking about what else they can write to make their jobs a little easier.
Comment