execsystem file dynamically

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

execsystem file dynamically

Post 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
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: execsystem file dynamically

Post by josh »

Your code looks almost correct but you need "%s" instead of just "%". Replace maketext("%map.pdf", with maketext("%smap.pdf",
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: execsystem file dynamically

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: execsystem file dynamically

Post 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.
Post Reply