Taking photos on the Navbar

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Taking photos on the Navbar

Post by Don »

Hi, I created two navbar buttons that would take a photo and display a photo for the current case. I would like the photo to be named with the ID items. However, when I take the photo, the photo name is blank even if I take it after entering the ID items. My code is below.

Code: Select all

PROC GLOBAL
string 	photoDir,		//Stores the location of the photos folder
		photoFileName 	//filename of photo
		;
		
//Function to take a photo using the device's camera. It saves to a filename matching the ID items
function takePhoto()
	if direxist(photoDir) then
		execsystem(maketext("camera:%s",photoFileName));
	else
		dircreate(photoDir);
		execsystem(maketext("camera:%s",photoFileName));
	endif;
end;

//Function to view photo of current case
function viewPhoto()
	if direxist(photoDir) then
		execsystem(maketext("view:%s", photoFileName));
	else
		dircreate(photoDir);
		execsystem(maketext("view:%s", photoFileName));
	endif;
end;

PROC LABOURFORCE_FF
preproc
	photoFileName = pathname(CSEntry) + maketext("Menu/Photos/%03d-%03d-%d-%03d.jpg", visualvalue(RNDNO),visualvalue(EDNO),visualvalue(STRATUM),visualvalue(HHNO));  //DEBUG: Not saving file with Rndno, edno, and stratum
	photoDir = pathname(CSEntry) + "Menu/Photos";
	
	userbar(clear);
	userbar(add button, "Get Location", getgps());		//adds a "Get location" button to get coordinates
	userbar(add button, "Take a photo for the current case", takePhoto());		//adds a button to take a photo of current case. 
	userbar(add button, "View photo of current case", viewPhoto());		//adds a button to view photo of current case
	userbar(show);
When I press the button, I get a photo with the name " - - - .jpg". As I said before, It happens even after entering RNDNO, EDNO, STRATUM and HHNO. Is there a reason for this? I've tried it with and without visualvalue on the variables.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Taking photos on the Navbar

Post by josh »

You are setting the value of photoFileName in LABOURFORCE_FF preproc which is the preproc of the application. It gets called once when the application first starts well before entering the values of the id-items. At the time that LABOURFORCE_FF preproc is run the id-items do not yet have any value.

Try moving the line that sets photoFileName to the beginning of the takePhoto() function.
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Re: Taking photos on the Navbar

Post by Don »

It works thanks!
Post Reply