Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run (filename with spaces) ?
Message
From
24/02/2003 09:11:04
 
 
To
24/02/2003 00:50:36
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00756665
Message ID:
00756944
Views:
10
Hi Bill,

On what platform is this command to execute? If Windows Scripting is available you can:
oShell = Createobject('WScript.Shell')
  oShell.Exec(lc + ' "'+lcParameter+'"')
if not then I would recommend the API_RUN class as developed by the late Ed Rauh. You can find this class in the Downloads as file#9477. To implement this class in your code would take the following code:
local lo, lcCmdline
IF NOT '\process' $ LOWER(SET('classlib'))
  SET CLASSLIB TO 'process' additive
ENDIF 
* - Passing string parameters
lcCmdLine = lC + ' "'+ lcParameter + '"'
lo=CREATEOBJECT('api_apprun',lcCmdLine,FULLPATH('.'))
lo.launchapp()
lo = ''
This is a typical implementation of the run command, but I would develop my own procedure for generic running of programs.
Procedure RunCmd
lPar pCmd,p1,p2,p3,p4,p5,p6,p7
local lcCmd, i
lcCmd = ''
if pcount() > 0
  set textmerge on to memvar lcCmd noshow
  \<<lcCmd>>
  for i = 1 to pCount()-1
    lcPar = 'p'+trans(i)
    lcPar = eval(lcPar)
**  Can only pass by value
    do case
    case vartype(lcPar) = 'C'
      \\ "<<lcPar>>",
    case inlist(vartype(lcPar), 'D','T'
      \\ {<<lcPar>>},
    case inlist(vartype(lcPar),'L','N'
      \\ <<lcPar>>,
    endcase
  endfor
  set textmerge to
  *** Remove extra comma
  if i > 1
    lcCmd = left(lcCmd,len(lcCmd) - 1)
  endif
  local lo
  IF NOT '\process' $ LOWER(SET('classlib'))
    SET CLASSLIB TO 'process' additive
  ENDIF 
  lo=CREATEOBJECT('api_apprun',lcCmd,FULLPATH('.'))
  lo.launchapp()
  lo = ''
endif
Bill I did not test this code, but I am sure you can go from here if you choose.

Glenn


>Hi Glenn,
>
>Finally got a simple one to run by doing:
>lc = getfile()
>run ["&lc"]
>
>Now I need to include a parameter in lc:
>
>lc = getfile()
>------ option 1 -------
>lc = lc + [ "] + lcParameter + ["]
>run ["&lc"]     && doesn't work because there are ["]s in lc
>run ['&lc']     && doesn't work either
>
>------ option 2 -------
>lc = lc + [ '] + lcParameter + [']
>run ["&lc"]     && doesn't work either
>
>Any idea how I can accomplish this?
>
>
>
>>Hi Bill,
>>
>>The run command itself requires the quoted string to pass the quotes to the command line therefore to execute this command try this:
>>
>>run ["c:\Set Time\settime.bat"]
>>
>>
>>This will work every time.
>>
>>Glenn Domeracki
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform