Possible bug when updating current field from a user function

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

Possible bug when updating current field from a user function

Post by Don »

Hi,

I have an application where when the user gets to the latitude field, they are prompted to press "Get location" in the navbar. It calls a getlocation function with uses the gps to get the coordinates and then fills the latitude and longitude fields automatically. The problem is that the field I'm currently on, which is the latitude field, does not get updated but the other field gets updated.

To illustrate, I've attached my application. If you run the application in the Questionnaire folder and
1. Go into the partially saved case ( 1 12011 1)
2. Make sure that the Latitude field is highlighted
3. Press "Get Location" in the navbar and get a location.
4. The longitude field is updated with the coordinate, but the latitude field is not

The code i'm using is:

Code: Select all

//Function uses device's GPS feature to get Location
function getgps()
	gps(open);
	if gps(read,60,10,"Reading GPS, Please wait...") = 1 then	//read up to 60 seconds. if successful...
		//execsystem(maketext("gps:%f,%f", gps(latitude),gps(longitude)));
		if accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1 then	//if yes
			LATITUDE = gps(latitude);
			LONGITUDE = gps(longitude);
		endif;
	else
		errmsg("Gps location failed, Please try again");
		LATITUDE = notappl;
		LONGITUDE = notappl;
	endif;
	gps(close);
end;
There is no code in the LATITUDE or LONGITUDE procs

Is there any way to work around this? I believe it only affects android.
Attachments
Labourforce.zip
(61.14 KiB) Downloaded 232 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Possible bug when updating current field from a user function

Post by josh »

Try adding a reenter at the end of your getps function. I haven't tried it myself but it might force the field to update.
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Re: Possible bug when updating current field from a user function

Post by Don »

Hi Josh,

Unfortunately, putting a reenter anywhere in the function doesn't seem to do anything.
Last edited by Don on September 5th, 2018, 12:17 pm, edited 1 time in total.
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Re: Possible bug when updating current field from a user function

Post by Don »

Ok I worked around this by prompting the user to run the getgps function before entering the LATITUDE or LONGITUDE fields. I also set those fields to protected so that there's no way that the user can run the function while in those fields.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Possible bug when updating current field from a user function

Post by josh »

Glad you found a workaround. We will fix the problem in version 7.2 so that the field value will be updated after executing user bar function.
Post Reply