I'm not sure to post in the right section, sorry if not.
I seek some help with the execsystem function.
I'm trying to automize a few things, one of four works, not the others.
I'm more unix oriented, I have very low skills with windows system.
If not too complicated, I would really appreciate some help, once again, to resolve this
I would like to set up something like that:
when the operator press 3, an index.html file starts
when the operator press 4, the BatchHTML.pff starts
when the operator press 5, the Tables application starts
------------------------------------
...
elseif $ = 2 then
Execsystem("c:..\Tools\Locate_Incomplete_Cases.exe"); {<----This one works fine}
reenter;
elseif $ = 3 then
execsystem("c:..\Docs\index.html"); {<----This one doesn't work}
execsystem(maketext('%s\Internet Explorer\iexplore.exe /c:..\Docs\index.html',pathname(ProgramFiles64))); {<----I tried also this but no success}
reenter;
elseif $ = 4 then
execpff("c:..\Batch\\BatchHTML.pff"); {<----Here the batch application starts but the HTML file is not found}
reenter;
elseif $ = 5 then
Execsystem("c:..\\Tables.xtb"); {<----There is no pff file for the tables so execpff cannot be used?}
reenter;
execsystem
Re: execsystem
I tried also this but doesn't work
execpff("c:..\\Tables.xtb.pff");
execpff("c:..\\Tables.xtb.pff");
-
- Posts: 1793
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: execsystem
There are a few tricky things when using CSPro with filenames, especially because CSPro doesn't handle backslashes consistently. On Windows machines the pathname contains backslashes, which also can be used to format text. So it's not always clear what you will get when you write "path\name" because the "\n" might get treated as a newline character, or it might get treated as two characters, a backslash and 'n.'
For that reason, I prefer to use forward slashes when possible, such as when calling execsystem. But if you are writing names to a PFF file, you should use backslashes, so I get around the ambiguity by using the maketext function with backslashes as separate parameters.
In any case, see the attached file for an example of a menu program using both execsystem and execpff. I suggest using absolute paths for your arguments to these functions, rather than the relative paths that you are attempting to use.
For that reason, I prefer to use forward slashes when possible, such as when calling execsystem. But if you are writing names to a PFF file, you should use backslashes, so I get around the ambiguity by using the maketext function with backslashes as separate parameters.
csvFilename = maketext("%sData%s%d_%s",pathname(Application),"\",sysdate("YYYYMMDD"),csvFilename);
You'll see that this even messes up CSPro's coloring scheme, revealing CSPro's quirky behavior regarding this issue.In any case, see the attached file for an example of a menu program using both execsystem and execpff. I suggest using absolute paths for your arguments to these functions, rather than the relative paths that you are attempting to use.
PROC GLOBAL
alpha (300) csvFilename = "randomNumbers.csv";
file csvFile,pffFile;
alpha (300) websiteName = "http://www.csprousers.org/forum/";
function OnStop() // disable CSEntry messages about saving data for this "questionnaire"
end;
PROC OPTIONSMENU_FF
preproc
// get an absolute path filename for our output file
csvFilename = maketext("%sData%s%d_%s",pathname(Application),"\",sysdate("YYYYMMDD"),csvFilename);
seed(systime());
PROC MENU_SELECTION
if $ = 1 then // write out 1000 random numbers (with an ID)
setfile(csvFile,strip(csvFilename),create);
numeric i;
do i = 1 while i <= 1000
filewrite(csvFile,"%5d,%03d",i,random(0,100));
enddo;
close(csvFile);
errmsg("Created file!");
elseif $ = 2 then // open the file in Excel 2007
execsystem(maketext('%s/Microsoft Office/Office12/excel.exe "%s"',pathname(ProgramFiles64),strip(csvFilename)));
elseif $ = 3 then // create a CSPro table using the random numbers
//execpff(concat(pathname(Application),"Tabulation Application/randomNumberTable.xtb.pff"));
setfile(pffFile,concat(pathname(Temp),"runTable.pff"),create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 4.1");
filewrite(pffFile,"AppType=Tabulation");
filewrite(pffFile,"Operation=All");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=%s%s",pathname(Application),"Tabulation Application/randomNumberTable.xtb");
filewrite(pffFile,"InputData=%s",csvFilename);
filewrite(pffFile,"Listing=.\randomNumberTable.xtb.lst");
filewrite(pffFile,"OutputTBW=%s%s",pathname(Application),"Tables/RandomNumbers.tbw");
filewrite(pffFile,"[Parameters]");
filewrite(pffFile,"ViewListing=OnError");
filewrite(pffFile,"ViewResults=Yes");
close(pffFile);
execpff(filename(pffFile));
elseif $ = 4 then // visit CSPro Users using Internet Explorer
execsystem(maketext('%s/Internet Explorer/iexplore.exe "%s"',pathname(ProgramFiles64),strip(websiteName)));
elseif $ = 5 then
stop(1); // close the menu program (note that the ID has to be on the form for CSEntry to properly close)
else
errmsg("Invalid selection!");
endif;
$ = notappl; // reset the selection
reenter;
See attached for the program.alpha (300) csvFilename = "randomNumbers.csv";
file csvFile,pffFile;
alpha (300) websiteName = "http://www.csprousers.org/forum/";
function OnStop() // disable CSEntry messages about saving data for this "questionnaire"
end;
PROC OPTIONSMENU_FF
preproc
// get an absolute path filename for our output file
csvFilename = maketext("%sData%s%d_%s",pathname(Application),"\",sysdate("YYYYMMDD"),csvFilename);
seed(systime());
PROC MENU_SELECTION
if $ = 1 then // write out 1000 random numbers (with an ID)
setfile(csvFile,strip(csvFilename),create);
numeric i;
do i = 1 while i <= 1000
filewrite(csvFile,"%5d,%03d",i,random(0,100));
enddo;
close(csvFile);
errmsg("Created file!");
elseif $ = 2 then // open the file in Excel 2007
execsystem(maketext('%s/Microsoft Office/Office12/excel.exe "%s"',pathname(ProgramFiles64),strip(csvFilename)));
elseif $ = 3 then // create a CSPro table using the random numbers
//execpff(concat(pathname(Application),"Tabulation Application/randomNumberTable.xtb.pff"));
setfile(pffFile,concat(pathname(Temp),"runTable.pff"),create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 4.1");
filewrite(pffFile,"AppType=Tabulation");
filewrite(pffFile,"Operation=All");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=%s%s",pathname(Application),"Tabulation Application/randomNumberTable.xtb");
filewrite(pffFile,"InputData=%s",csvFilename);
filewrite(pffFile,"Listing=.\randomNumberTable.xtb.lst");
filewrite(pffFile,"OutputTBW=%s%s",pathname(Application),"Tables/RandomNumbers.tbw");
filewrite(pffFile,"[Parameters]");
filewrite(pffFile,"ViewListing=OnError");
filewrite(pffFile,"ViewResults=Yes");
close(pffFile);
execpff(filename(pffFile));
elseif $ = 4 then // visit CSPro Users using Internet Explorer
execsystem(maketext('%s/Internet Explorer/iexplore.exe "%s"',pathname(ProgramFiles64),strip(websiteName)));
elseif $ = 5 then
stop(1); // close the menu program (note that the ID has to be on the form for CSEntry to properly close)
else
errmsg("Invalid selection!");
endif;
$ = notappl; // reset the selection
reenter;
- Attachments
-
- optionsMenu.zip
- (7.5 KiB) Downloaded 560 times
Last bumped by Anonymous on February 6th, 2012, 4:29 am.