Hello,
Here is an alternative solution to get the username and computer name, you can create a global function which you can call upon opening the application.
string ls_userName
string ls_cmd1, ls_cmd2
integer li_return = 1 // 1= ok or -1 = not ok
string ls_currentdir
integer li_ufile, li_cfile, li_b1file, li_b2file
integer li_readstatus
string ls_ufile, ls_cfile
string ls_script
string ls_cr = char(13)
// getuser.bat and getcomputer.bat will be generated in order to create the following files: username.txt and computername.txt
ls_currentdir = GetCurrentDirectory()
ls_cmd1 = trim(ls_currentdir) + "\" + "getuser.bat"
ls_cmd2 = trim(ls_currentdir) + "\" + "getcomputer.bat"
ls_script = "echo %USERNAME% > " + trim(gs_tmpdir) + "\username.txt"
li_b1file = FileOpen(ls_cmd1, TextMode!, Write!, LockWrite!, Replace!, EncodingANSI! )
li_return = FileWriteEx(li_b1file, ls_script)
FileClose(li_b1file)
if li_return > 0 then
li_return = run(ls_cmd1)
if li_return = -1 then
return li_return
end if
else
return li_return
end if
ls_script = "echo %USERDOMAIN% > " + trim(gs_tmpdir) + "\computername.txt"
li_b2file = FileOpen(ls_cmd2, TextMode!, Write!, LockWrite!, Replace!, EncodingANSI! )
li_return = FileWriteEx(li_b2file, ls_script)
FileClose(li_b2file)
if li_return > 0 then
li_return = run(ls_cmd2)
if li_return = -1 then
return li_return
end if
else
return li_return
end if
ls_ufile = trim(gs_tmpdir) + "\username.txt"
ls_cfile = trim(gs_tmpdir) + "\computername.txt"
// get the username variable
if FileExists(ls_ufile) then
li_ufile = fileOpen(ls_ufile,LineMode!,Read!)
li_readstatus = FileReadEx(li_ufile,gs_username)
if li_readstatus <= 0 then
// default user name to system since could not get user name from the workstation
gs_username = "system"
end if
FileClose(li_ufile)
FileDelete(ls_ufile)
else
// default user name to system since could not get user name from the workstation
gs_username = "system"
end if
// get the computer name variable
if FileExists(ls_cfile) then
li_cfile = fileOpen(ls_cfile,LineMode!,Read!)
li_readstatus = FileReadEx(li_cfile,gs_computername)
if li_readstatus <= 0 then
// default user name to system since could not get user name from the workstation
gs_computername = "unknown"
end if
FileClose(li_cfile)
FileDelete(ls_cfile)
else
// default user name to system since could not get user name from the workstation
gs_computername = "unknown"
end if
return li_return
I have created a function of_getcomputername and of_getusername both are having Unknown function name: of_getcomputername and of_getusername error.