Request of "Getmacid function"
Request of "Getmacid function"
Dear Gregory,
I would like to know if it's possible to copy the result of the Getmac command line from Dos and use it inside the Cspro's programming language?
If no, it's possible to create a such function(Getmacid) inside the Cspro's programming language?
I think, it'll be very useful instead of Getusername function in the control of data entry using Tablet PC.
Sincerely yours,
I would like to know if it's possible to copy the result of the Getmac command line from Dos and use it inside the Cspro's programming language?
If no, it's possible to create a such function(Getmacid) inside the Cspro's programming language?
I think, it'll be very useful instead of Getusername function in the control of data entry using Tablet PC.
Sincerely yours,
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Request of "Getmacid function"
You can do this. Redirect the output of the getmac command to a file and then read it in CSPro. See attached for an example.
My batch command is this:
My batch command is this:
Then the CSPro code is:getmac /fo list > getmac.txt
PROC GLOBAL
alpha (100) str;
file inputFile;
PROC GETMAC_FF
preproc
execsystem("getm.bat",wait);
setfile(inputFile,"getmac.txt");
while fileread(inputFile,str) do
if pos("Physical Address: ",str) then
errmsg("MAC Address: %s",str[length("Physical Address: ")]);
endif;
enddo;
close(inputFile);
alpha (100) str;
file inputFile;
PROC GETMAC_FF
preproc
execsystem("getm.bat",wait);
setfile(inputFile,"getmac.txt");
while fileread(inputFile,str) do
if pos("Physical Address: ",str) then
errmsg("MAC Address: %s",str[length("Physical Address: ")]);
endif;
enddo;
close(inputFile);
- Attachments
-
- getmac.zip
- (2.22 KiB) Downloaded 449 times
Re: Request of "Getmacid function"
Thanks for this so precious help.But, i would like to know if it's possible to read and store it in Csentry.
Sincerely yours,
Sincerely yours,
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Request of "Getmacid function"
The code that I posted will also work in CSEntry.
Re: Request of "Getmacid function"
Since my request, it's the first time i need to use the logic above in a real situation. The code is used in Csentry and that's ok. It display the Mac adresses in the Warning/error window. But, i would like to store the mac adress in a Csentry's field/item.
Please help me again.
Thanks in advance.
Please help me again.
Thanks in advance.
Last edited by htuser on August 14th, 2013, 3:09 pm, edited 1 time in total.
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Request of "Getmacid function"
If the above code successfully displays a message, simply assign that string to a field:
MAC_ADDRESS_STRING = str[length("Physical Address: ")];
Re: Request of "Getmacid function"
Thanks. You always have good solutions.
But, it store only one mac adress, the last. Can you help me to store two or more?
Regards,
But, it store only one mac adress, the last. Can you help me to store two or more?
Regards,
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Request of "Getmacid function"
You could write a function to loop through the text file and check if the text "Physical Address" exists using the pos function. Then you could parse those lines of code to extract multiple MAC addresses.
Re: Request of "Getmacid function"
Dear Gregory,
Thanks for your precious help. Meanwhile, i'm trying to use code inside Cspro to write a batch.
I create him, but, i can't write the dos code inside, please, can you help me?
Thanks in advance
Thanks for your precious help. Meanwhile, i'm trying to use code inside Cspro to write a batch.
I create him, but, i can't write the dos code inside, please, can you help me?
Code: Select all
filecreate("\mac_adress\getcode.bat");
filewrite(getcode, "getmac /fo list > getcode.txt");
execsystem("getcode.bat",wait);
setfile(inputFile,"getcode.txt");
while fileread(inputFile,str) do
if pos("Physical Address: ",str) then
errmsg("Le Code est:%s",str[length("Physical Address: ")]);
MAC_ADRESS = str[length("Physical Address: ")];
endif;
enddo;
close(inputFile);
G.VOLNY, a CSProuser from Haiti, since 2004