Clyde and Kai,
I found an older thread with the same response from Clyde. Took a few tries (since my SQLese isn't very good), but managed to figure it out. Repost of what I have now below.
Keep it if you like. It addresses the sqlget issue and sets a reverse sort order on the dataset. Just some minor tweaks to get what I was looking for. Maybe add an option box to select all the log types individually? That unfortunately requires a build of the SQL statement.
I found an older thread with the same response from Clyde. Took a few tries (since my SQLese isn't very good), but managed to figure it out. Repost of what I have now below.
CODE |
#******************************************* # MacDescription = Copy found logs to GSAK logs section # MacFileName = FoundLogstoGSAKLogs.gsk # MacAuthor = Kai Team # MacVersion=1.3 # MacUrl= #******************************************* #$_sql="Select lParent,ldate,lText from LogsAll where (g_foundlog(ltype) OR lType='Didn''t find it')and lIsOwner and lParent IN (Select Code from Caches where $_Where) Order By lDate" #Modified SQL statement to get all logs for which I am the owner and have a parent in the Caches Table. Also added the DESC (descending) option to the lDate sort to retrieve most recent log first, and the remaining in reverse chronological order to simplify putting them in where I want them. $_sql="Select lParent,ldate,lText from LogsAll where lIsOwner and lParent IN (Select Code from Caches where $_Where) Order By lDate DESC" #Use the crlfcvt option to install markers in the text. $Logs=Sqlite("sql",$_sql,"crlfcvt=<CRLF>") IF $Logs="" CANCEL Msg=There are no caches with your found logs in this database or filter. Macro canceled. ENDIF $Count=RegExCount($_CrLf,$Logs) + 1 $x=1 WHILE $x<=$count $ThisLog=Extract($Logs,$_CrLf,$x) #Convert the subbed text back to CRLF's. $ThisLog=Replace("<CRLF>",$_CrLf,$ThisLog) $Code=Extract($ThisLog,";",1) #Trap error for invalid dates $TestDate=Extract($ThisLog,";",2) $TestDate=Replace("-","",$TestDate) IF ValidDate($TestDate)=TRUE $LogDate=DateFormat(SqlToDate(Extract($ThisLog,";",2))) $LogText=RegExReplace("$Code;",Extract($ThisLog,";",3),"") ELSE CANCEL Msg="Your database contains one or more logs with invalid dates. Macro canceled." ENDIF IF Seek($Code) TRANSACTION Action=Begin $ExistingNote=Extract($d_UserNote,"$~",1) $ExistingLog=Extract($d_UserNote,"$~",2) IF At($LogText,$ExistingLog)=0 IF $ExistingLog<>"" #If the existing log is not blank, copy the remaining logs to the ExistingNote section. $d_UserNote=$LogDate + $_CrLf + $_CrLf + $LogText + $_CrLf + $_CrLf + $ExistingNote + "$~" + $ExistingLog ELSE #If this is the first log discovered for this cache, record it as the current ExistingLog. $d_UserNote=$ExistingNote + "$~" + $LogDate + $_CrLf + $_CrLf + $LogText ENDIF ENDIF #Added a status message so the wait wasn't quite so boring. $SSMsg="Updating " + $Code + "for log entered on " + $LogDate ShowStatus Msg=$SSMsg Width=450 TRANSACTION Action=End ENDIF $x=$x+1 ENDWHILE |
Keep it if you like. It addresses the sqlget issue and sets a reverse sort order on the dataset. Just some minor tweaks to get what I was looking for. Maybe add an option box to select all the log types individually? That unfortunately requires a build of the SQL statement.