If you slPushDatabase the current database is no longer available until you slPopDatabase
Be careful if connection fails, etc.
This might work just as well without rotating database handle
1 IF can't get to host then no need to push and pop database handles
2 If can get to host then disconnect, read local log, reconnect, send local log
Sounds like good planning like no cloud no work.
Did this way to try to avoid lots of IF statements.
After looking at it awhile workinglocal and workingremote would need to duplicate code.
The program would probably need to use IF gconnect to share the routines.
#DIM ALL
#INCLUDE "sqlitening.inc"
GLOBAL gConnect AS LONG
'-------------------------------------------------------
FUNCTION PBMAIN () AS LONG
LOCAL x,ecode,portnumber AS LONG
LOCAL sHost AS STRING
slSetProcessMods "E0"
sHost = "192.168.0.13"
PortNumber = 80
FOR x = 1 TO 1 'try multiple times to connect
ecode = slConnect(shost,portnumber)
IF ecode = 0 THEN gConnect = 1:EXIT FOR ELSE BEEP
NEXT
IF gConnect THEN
WorkingRemote
ELSE
IF MSGBOX("Could not connect, work local?",%MB_YESNO OR %MB_SYSTEMMODAL,"Connect error") = %IDYES THEN
WorkingLocal
ELSE
? "Ending the program",%MB_SYSTEMMODAL,"Thank you"
END IF
END IF
END FUNCTION
'-------------------------------------------------------
SUB WorkingLocal
? "Local routines create log"
END SUB
'-------------------------------------------------------
SUB WorkingRemote
slDisconnect
? "Connected/Disconnected"
END SUB