Page 1 of 1

execsystem file dynamically

Posted: May 18th, 2019, 10:19 am
by Yass

Code: Select all

function showmapl()
	string mapPath = maketext("%map.pdf", 
							     pathname(Application));
	if getos() in 20:29 then
		if execsystem(maketext("view:%s", mapPath)) <> 1 then
			errmsg("Failed to load manual. Make sure you have a PDF viewer installed.");
		endif;
	else
Hi CSPpro, please i have a set of maps in .pdf saved by Interviewer ID. I want to modify the above codes , thus base on interviewer login ID , when you call the function showmap the map name which is same as the login should open.

For instance , In a resource folder on a tablets i have these files 12.pdf, 13.pdf, and 14.pdf. If i loging as 14 then call the shownMap() function then map 14.pdf should open. Please is it possible ?




Kwamena

Re: execsystem file dynamically

Posted: May 19th, 2019, 4:14 pm
by josh
Your code looks almost correct but you need "%s" instead of just "%". Replace maketext("%map.pdf", with maketext("%smap.pdf",

Re: execsystem file dynamically

Posted: May 20th, 2019, 1:38 am
by Yass
Hi Josh,

I don't want to use "%smap.pdf", rather the maps are saved by the login, thus i have 11.pdf, 12.pdf etc where the 11,12 etc are login id. I want a situation that if i call the function based on my login that file open, thus ID 11 should open file 11.pdf. I tried something like this

Code: Select all

function showmap()
   string mapPath = maketext("%smap.pdf", login, pathname(Application));
   if getos() in 20:29 then
      if execsystem(maketext("view:%s", mapPath)) <> 1 then
         errmsg("Failed to load manual. Make sure you have a PDF viewer installed.");
      endif;
   else
Am off.

Re: execsystem file dynamically

Posted: May 20th, 2019, 7:09 am
by josh
Assuming login is numeric then use %d to add the login code to the filename:
string mapPath = maketext("%s%dmap.pdf", pathname(Application), login);
The %s gets replaced with the application path and the %d gets replaced with the login code.