Mark & Shane,
I was writing a script get the contents of Safari history from the the web page after I did a “Show All History” from the History menu of Safari 10.0.2. I am running the released Script Debugger 6.0.4 (6A198). I was using UI Browser 2.5.0 to script the interface of the Safari window. The script script was to read the history from safari and put that history in Apple’s Numbers. It was reading the history with no problems before the the saving problem. I am running under 10.11.6 El Capitan. I had no indication of any problems with anything while doing this until the contents of the window disappeared and a dialog showed up after I tried to save the script by pressing command-S. I did include of a picture of the dialog in this post but the dialog said something about global variables or properties had exceeded AppleScripts limits (errOSAInternalTableOverflow). I also included the text of the script I was working on.
I check the console and no errors or any kind of status appeared there. The I clicked the “Recompile & save” buttons and I got the spinning beach ball for a while, maybe a minute to a minute and a half. Then it saved. Then I pressed command-Z to undo until I got my original script back. I copied my script from the window to another application with no problems. Then I went to Finder and double clicked the file and a blank window opened in Script Debugger. There had been something in the file before. I quit Script Debugger and restarted it and tried opening the file from both Finder and from Script Debugger and the text I typed was still gone.
After I clicked the “Save & compile” button something did come up in in the console. It said “2/5/17 1:45:22.242 AM Script Debugger[3884]: void CGSUpdateManager::log() const: conn 0x1b167: spurious update.” I am not sure what to make of that that. It doesn’t sound like it’s related but I thought I would include it anyway.
I did have Script Debugger in debug mode while I was working on the script but I had not used the debug function to step through any thing for about a half an hour before the problem occurred. I used the debugger to watch the script and make sure it was really doing what I wanted it to. The script was not having any problems before I ran the debugger.
I did upload a zip version of the file that was blanked out after the save. I’m not sure what information you can get from that but I figured I would in case you thought of something you wanted to check.
Normally I quit “UI Browser” as soon as I get all the information I need for the script. Then I start writing the script. But this time I forgot and left “UI Browser” running while I wrote the script. This might have caused the problem. “UI Browser” does strain the application a bit when it’s running. But at the same time there are probably a number of people who use UI Browser with Script Debugger.
While it did destroy the file contents but the text I retrieve from pressing undo did get the full text of my script. I tried to include everything I could think of. But it well of been the case that “UI Browser” was interacting with Script Debugger when the problem occurred, although Script Debugger was not acting sluggish before the problem. Unfortunately in this case I have no idea if “UI Browser” caused this problem.
Bill
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on GetNumberOfRows()
set AppName to "Safari"
tell application AppName to activate
tell application "System Events"
tell process AppName
set NumberOfRows to count of rows of outline 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1
end tell
end tell
end GetNumberOfRows
on GetFieldValue(TheField, TheRow)
script ReturnObj
property FieldValue : -1
property Successful : false
property DisclosureTriangleLine : false
end script
set AppName to "Safari"
tell application AppName to activate
tell application "System Events"
tell process AppName
try
if ((TheField ≠ 1) and (TheField ≠ 2)) then
display dialog "An invalid field number of \"" & TheField & "\" was sent to the GetFieldValue handler." buttons {"OK"} default button "OK" with title "Error"
set (Successful of ReturnObj) to false
return ReturnObj
end if
if (exists (text field 1 of group 1 of row TheRow of outline 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1)) then
-- This is a line with the date and disclosure triangle on it
set DisclosureTriangleLine to true
if (TheField = 1) then
set (FieldValue of ReturnObj) to value of text field 1 of group 1 of row TheRow of outline 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1
else if (TheField = 2) then
set (FieldValue of ReturnObj) to ""
end if
else
set DisclosureTriangleLine to false
set (FieldValue of ReturnObj) to value of text field TheField of row TheRow of outline 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1
end if
set (Successful of ReturnObj) to true
return ReturnObj
on error errMsg number errNum from offendingObject partial result resultList to expectedType
display dialog "Error " & (errNum as string) & " occured trying to get the value of field " & TheField & " in row " & TheRow & "." & return & return & errMsg ¬
buttons {"OK"} default button "OK" with title "Error"
display dialog "Error " & (errNum as string) & " occured." & return & return & errMsg ¬
with title "Error"
set (Successful of ReturnObj) to false
return ReturnObj
end try
end tell
end tell
end GetFieldValue
return GetFieldValue(1, 2)
set NumberOfRows to GetNumberOfRows()
set ListOfLines to {}
repeat with TheLine from 1 to 3
-- Get the value for field 1
set TheResult1 to GetFieldValue(1, TheLine)
if (not Successful of TheResult1) or (not Successful of TheResult1) then return false
-- Get the value for field 1
set TheResult2 to GetFieldValue(2, TheLine)
if (not Successful of TheResult2) then return false
if (DisclosureTriangleLine of TheResult1) ≠ (DisclosureTriangleLine of TheResult2) then
display dialog "message" buttons {"Cancel", "OK"} default button "OK"
end if
DisclosureTriangleLine
FieldValue
set LinePart1 to GetFieldValue(1, TheLine)
set LinePart2 to GetFieldValue(2, TheLine)
set OutputLine to {Title:LinePart1, Adress:LinePart2, DisclosureTriangleLine:IsDisclosureTriangleLine, ErrorOccured:ErrorDidOccur}
if (ListOfLines = {}) then
set ListOfLines to {OutputLine}
else
set ListOfLines to ListOfLines & {OutputLine}
end if
end repeat
Safari 10.0.2 list out history.scpt.zip (246.8 KB)