For what it’s worth, I wrote a “conversion” procedure couple years ago when I was upgrading. It looks at all procedures in a database, flags the probable “errors”, suggests what to do with each error, and then does it automatically upon request. I have not posted it before because I know my solution to each error may not be the best solution and I was pretty sure I would be embarrassed should I have to defend my solutions. I’m pretty sure someone could program this better, and everyone is welcome to do just that. But here it is anyway, in case it is of some help.
The “errors” are defined in the SuspectItemLV local variables. I keep this procedure in a separate database called “Macros” and I FarCall it from any database that I want to “convert” to PanX.
;Created September 25, 2020
;Purpose is to perform the necessary tasks for upgrading
;Usually Called by the “Seasonal Special” procedure in any number of databases
/*
search all procedures in current database for all suspect items that may need to be changed, returning the names of those procedures in CR-delimited array
open first procedure window and a form window with a "Resume" button
search for the first suspect item
if an item is found, Pause DialogPause
when resumed, search for the next suspect item, and so on
when all searches have been done, open the next procedure in the array and search as before
*/
Global ProcedureSearchTextGV, ViewListGV, CombinedListGV, CurrentProcedureGV, CurrentDatabaseGV
Local SuspectItemsLV, TempProcedureTextLV, FileLocationLV
CombinedListGV = ""
CurrentDatabaseGV = info("DatabaseName")
FileLocationLV = “~/Documents/Computer/Panorama/Problems to Fix/Pan 6 —> PanX Repairs.txt”
SuspectItemsLV = {info("changes")
info(“changes”)
not info("empty")
not info(“empty”)
Secret
Define
Globalize
Revert
.Initialize
Loop
Hide
GetText
Listwindows(
Console }
SuspectItemsLV = {Console }
;get all the procedure names that include the suspect items
LoopArray SuspectItemsLV, ¶, SuspectItemLV
ProcedureSearchTextGV = SuspectItemLV
;FarCall “Macros”, “.Search in All Procedures (Simpler)”
ShortCall SearchInAllProcedures
CombinedListGV = CombinedListGV + ViewListGV + ¶
EndLoop
;edit the list
ArrayDeDuplicate CombinedListGV, CombinedListGV, ¶
ArrayStrip CombinedListGV, ¶
OpenForm “Resume”, “Database”, “Macros”
LoopArray CombinedListGV, ¶, CurrentProcedureGV, LoopCounterLV
;search for the suspect items
LoopArray SuspectItemsLV, ¶, SuspectItemLV
TempProcedureTextLV = GetProcedureText(CurrentDatabaseGV, CurrentProcedureGV)
If TempProcedureTextLV contains SuspectItemLV
;make sure we haven’t already fixed this problem
Let FixedProblemsLV = FileLoad(FileLocationLV)
If FixedProblemsLV notcontains (CurrentDatabaseGV + ¬ + CurrentProcedureGV + ¬ + SuspectItemLV)
OpenProcedure CurrentProcedureGV, “Database”, CurrentDatabaseGV
;put it on clipboard
ScrapCalc SuspectItemLV
Applescript |||
tell application "PanoramaX"
activate
end tell
tell application "System Events"
tell process "PanoramaX"
--click menu item "Find…" of menu 1 of menu item "Find" of menu 1 of menu bar item "Edit" of menu bar 1
delay 1
key code 3 using {command down} -- f key
delay 1
keystroke "a" using {command down}
delay 1
--click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
key code 9 using {command down} -- v key
delay 1
--key code 36 using {command down} -- return Key
end tell
end tell
|||
Message “Press Return for the first instance of «” + SuspectItemLV + “». Press Command-G to search for «” + SuspectItemLV + “» again, then click the Resume button to search for the next suspect item.”
;give instructions for what to do
If SuspectItemLV contains “not info(”
Message {In Pan 6, if Select was unsuccessful, the database would go back to its previous selection. It PanX, ALL records become selected instead.} + ¶ + ¶ + {This is very dangerous, because if you were planning on, say, filling a small subset of records with 0 if they exist and it turns out they don't exist, then you may end up filling every record instead.} + ¶ + ¶ + {So If (not info("empty")) should always be followed by an else.}
Elseif SuspectItemLV contains {info(”changes")} or SuspectItemLV contains {info(“changes”)}
Message {Pan X does automatic saves, so info("changes") does not exist. You can just replace it with Save, which is on the clipboard.}
ScrapCalc “Save”
Elseif SuspectItemLV contains “Secret”
Message “Secret windows should be used vary sparingly, because Pan gets confused about which database it is working on.”
Elseif SuspectItemLV contains “Define”
Message {Define CREATES a FileGlobal variable, which is bad if you wanted to define a value for a previously-declared GLOBAL variable instead, like in Pan6.} + ¶ + ¶ + {As an alternative, paste the commands that are currently on the clipboard.}
ScrapCalc {AssignGlobal YearlyPayment, catcherror(0, YearlyPayment)} + ¶ + {Use AssignGlobal, AssignLocal, AssignFileGlobal, or AssignWindowGlobal, or MakeFileGlobals ActivityName = catcherror("", ActivityName), ...} + ¶ + {or LetGlobal gVariable = catcherror(“StartingValue”, catcherror(“”, GlobalValue(“gVariable”)))} + ¶
Elseif SuspectItemLV contains “Globalize”
Message {You can replace Globalize with AssignGlobal Variable, FileGlobalValue("", “Variable”)} + ¶ + {or} + ¶ + {MakeFileGlobals AttendDate = catcherror("", AttendDate), …} + ¶ + ¶ + {Those commands are on the clipboard.}
ScrapCalc {AssignGlobal Variable, FileGlobalValue("", “Variable”)} + ¶ + {MakeFileGlobals AttendDate = catcherror("", AttendDate), …}
Elseif SuspectItemLV contains “Revert”
Message “Revert no longer works like it did in Pan 6. Instead, paste the commands that are currently on the clipboard.”
ScrapCalc {StartDatabaseChange "allrecords","Undo Selection" and sendaction "undo:"} + ¶ + {arraybuild tempdata,cr(),"",exportline() and importtext tempdata}
Elseif SuspectItemLV contains “.Initialize”
Message {Make sure one Initialize procedure does not call another Initialize procedure. Also, use try/catch to report errors.} + ¶ + ¶ + {The Message statement won’t work in .Initialize except as part of the catch statement. I like to use as part of the Catch statement the following: Message “Error in ” + info("DatabaseName") + “:.Initialize, ” + info("error"). To display errors in the .Initialize procedure itself, you can also use the zlog statement that is on the clipboard.}
ScrapCalc {zlog “ *** Process Calendar / Email Calendar - 1 - ” + catcherror("", EmailFileName) + " / " + catcherror("", EmailFolder)} + ¶
Elseif SuspectItemLV contains “Loop”
Message {The old format for Loop can be treacherous.} + ¶ + ¶ + {«Until» can no longer CALCULATE the number of times to loop.} + ¶ + ¶ + {You can also use LoopArray, LoopWhile, or For.}
Elseif SuspectItemLV contains “Hide”
Message “Hide should be replaced with NoShow / EndNoShow followed by ShowPage.”
Elseif SuspectItemLV contains “GetText ”
Message {Replace GetText with GetTextSheet “Caption”, Variable / If info("trigger") = "Stop" Stop Endif. The second line is on the clipboard so you can paste it.}
ScrapCalc {If info("trigger") = "Stop" Stop Endif} + ¶
Elseif SuspectItemLV contains “Listwindows(”
Message {Listwindows( should be replaced with arraysearch(info(“files”), “DatabaseName”, 1, ¶) if you are just trying to determine whether the database is open.}
Elseif SuspectItemLV contains “Console ”
Message {Replace Console with zlog. I put zlog on the clipboard so you can paste it.}
ScrapCalc {zlog }
Endif
Pause ""
OpenProcedure CurrentProcedureGV, “Database”, CurrentDatabaseGV
AlertYesNo “Are all the problems with «” + SuspectItemLV + “» fixed in this procedure?”
If info("dialogtrigger") contains “Yes”
FileAppend FileLocationLV, (CurrentDatabaseGV + ¬ + CurrentProcedureGV + ¬ + SuspectItemLV + ¶)
Save
Endif
Endif
Endif
EndLoop
;Pause ""
EndLoop
Message “Congrats, you are finished!”
stop
AlertYesNo “Sure you want to update a Pan 6 form to Pan X?”
If info("dialogtrigger") contains “Yes”
Selectobjects Objectinfo("font") match ".AppleSystemUIFont" ;and Objectinfo("$Fill") = "Hollow"
Changeobjects "$Fill", "Outline",
"$TextEditorPopUpEditing", "0",
"TextSize", "10 px",
"$TextEditorTerminateReturn","1",
"$TextEditorTerminateTab","1",
"$TextEditorTabCycle","1",
"$TextEditorInsertionPoint","All"
Selectnoobjects
Endif
Rtn
;********** ShortCalls ************
SearchInAllProcedures:
Local TempProcedureListLV, TempProcedureTextLV, ProcedureNameLV, ActiveDatabaseLV
Global ProcedureSearchTextGV, ViewListGV
ActiveDatabaseLV = info("DatabaseName")
TempProcedureListLV = dbinfo("Procedures", ActiveDatabaseLV)
TempProcedureTextLV = ""
ViewListGV = ""
LoopArray TempProcedureListLV, ¶, ProcedureNameLV, LoopCounter
TempProcedureTextLV = GetProcedureText(ActiveDatabaseLV, ProcedureNameLV)
If TempProcedureTextLV contains ProcedureSearchTextGV
ViewListGV = sandwich("", ViewListGV, ¶) + ProcedureNameLV
Endif
EndLoop