Saved GPS reading is retained even after taking a new GPS reading

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
lmoriba
Posts: 56
Joined: June 10th, 2018, 6:21 pm

Re: Saved GPS reading is retained even after taking a new GPS reading

Post by lmoriba »

Dear Josh,

Sorry to come back to you on this, I can't still get the desired result. I have updated the logic in PROC POLE_GPS_TAKE as follows. The application is still not saving the acquired gps coordinates to be used for another household on the same pole.

PROC POLE_GPS_TAKEN
preproc
if loadsetting("POLE_LATITUDE") <> "" then
POLE_LATITUDE = tonumber(loadsetting("POLE_LATITUDE"));
endif;
if loadsetting("POLE_LONGITUDE") <> "" then
POLE_LONGITUDE = tonumber(loadsetting("POLE_LONGITUDE"));
endif;





onfocus
if visualvalue(POLE_LATITUDE) = 99 or visualvalue(POLE_LATITUDE) = notappl then
setvalueset($, GPS_NOT_TAKEN_VS2);
else
setvalueset($, GPS_TAKEN_VS1);
endif;

postproc
if $ = 1 then
// Take new GPS reading
gps(open);

if gps(read,60,10,"Reading GPS, Please wait...") = 1
and accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1 then

{if accept("Save this result", "Yes", "No") = 1 then}
POLE_LATITUDE = gps(latitude);
savesetting("POLE_LATITUDE", "");

POLE_LONGITUDE = gps(longitude);
savesetting("POLE_LONGITUDE", "");
ADVANCE TO COMPOUND_NUMBER;
else
errmsg("GPS signal could not be acquired");
endif;
gps(close);
//reenter;


elseif $ = 2 then
// Show current readings on map
//execsystem(maketext("gps:%f,%f",
// visualvalue(LI_LATITUDE),
// visualvalue(LI_LONGITUDE)));
// reenter;
elseif $ = 3 then
// Keep the readings and move to next field
advance to COMPOUND_NUMBER;
elseif $ = 9 then
// Remove current readings
POLE_LATITUDE = 99.000000000;
POLE_LONGITUDE = 99.000000000;

endif;
Capture1202.JPG
Capture1202.JPG (111.29 KiB) Viewed 1540 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Saved GPS reading is retained even after taking a new GPS reading

Post by josh »

This code is not saving the latitude and longitude. It is setting them to blank:

Code: Select all

POLE_LATITUDE = gps(latitude);
savesetting("POLE_LATITUDE", "");

POLE_LONGITUDE = gps(longitude);
savesetting("POLE_LONGITUDE", "");
Try this:
PROC POLE_GPS_TAKEN
preproc
errmsg
("%s", loadsetting("POLE_LATITUDE"));
if loadsetting("POLE_LATITUDE") <> "" then
   
POLE_LATITUDE = tonumber(loadsetting("POLE_LATITUDE"));
endif;
if loadsetting("POLE_LONGITUDE") <> "" then
   
POLE_LONGITUDE = tonumber(loadsetting("POLE_LONGITUDE"));
endif;



onfocus
if visualvalue
(POLE_LATITUDE) = 99 or visualvalue(POLE_LATITUDE) = notappl then
    setvalueset
($, GPS_NOT_TAKEN_VS2);
else
    setvalueset
($, GPS_TAKEN_VS1);
endif;

postproc
if
$ = 1 then
    // Take new GPS reading
   
gps(open);

       
if gps(read,60,10,"Reading GPS, Please wait...") = 1
       
and accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1  then

        {if accept("Save this result", "Yes", "No") = 1 then}
           
POLE_LATITUDE = gps(latitude);
           
savesetting("POLE_LATITUDE",gps(latitude));

            POLE_LONGITUDE =
gps(longitude);
           
savesetting("POLE_LONGITUDE", gps(longitude));
           
gps(close);
           
ADVANCE TO COMPOUND_NUMBER;
   
else
        errmsg
("GPS signal could not be acquired");
       
gps(close);
       
reenter;
   
endif;

elseif $ = 2 then
    // Show current readings on map
    //execsystem(maketext("gps:%f,%f",
                    //  visualvalue(LI_LATITUDE),
                    //  visualvalue(LI_LONGITUDE)));
   // reenter;
elseif $ = 3 then
    // Keep the readings and move to next field
   
advance to COMPOUND_NUMBER;
elseif $ = 9 then
    // Remove current readings
   
POLE_LATITUDE = 99.000000000;
    POLE_LONGITUDE =
99.000000000;

endif;
lmoriba
Posts: 56
Joined: June 10th, 2018, 6:21 pm

Re: Saved GPS reading is retained even after taking a new GPS reading

Post by lmoriba »

Dear Josh,

I don't know how many times to thank you for your unflinching support and patience. Finally, am elated to bring to your attention that it now worked. :D Thanks so much.
Post Reply