• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
FastScripts and script editor discrepancies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FastScripts and script editor discrepancies


  • Subject: FastScripts and script editor discrepancies
  • From: 2551phil <email@hidden>
  • Date: Wed, 22 Jun 2016 15:46:50 +0700

I just posted this in the FastScripts forum, but I’m thinking it might be worthwhile getting confirmation that others see this too. I’m not quite sure where the problem arises.

I have what is probably an overly complex script for what it's designed to do (which is check if certain files have been updated in the background by Apple). However, I'm seeing something strange when I run (or try to run it) in FastScripts that I don't see when I run it in either Script Editor or Script Debugger 6.

When I run this in SE or SD, the tabs all line up as intended, but when I run this from FastScripts, the tab spaces are misaligned in the display dialog. It seems that specifically sometimes when the tab after the value 'v' is v\t, FastScripts includes more space for the \t than either SE or SD.

The weird thing is I can’t reproduce this tab spacing discrepancy in other scripts run from FastScripts. Can anyone confirm that they see the same discrepancy, and if so, does anyone know why it might occur?


TIA


Phil



#
#start 

########################################## 
# Variables 
########################################## 
set updateMarker to " *"

# note that this script will write to this location when it’s done
set saveLocation to "~/Library/Preferences/com.appleBackgroundUpdates.CriticalUpdates.txt"

set lastUpdate to {}

set thisDate to {}

set hasBeenUpdated to ""

set TimeStrings to {"/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.meta.plist", "/private/var/db/gkopaque.bundle/Contents/version.plist", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist", "/System/Library/CoreServices/MRT.app/Contents/version.plist", "'/System/Library/Intelligent Suggestions/Assets.suggestionsassets/Contents/version.plist'", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version.plist", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/version.plist", "/usr/share/kdrl.bundle/info.plist"}

set VersionStrings to {"/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.meta.plist Version", "/private/var/db/gkopaque.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/CoreServices/MRT.app/Contents/version CFBundleShortVersionString", "/System/Library/Intelligent\\ Suggestions/Assets.suggestionsassets/Contents/version.plist CFBundleShortVersionString", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version CFBundleShortVersionString", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/info SUVersionString", "/usr/share/kdrl.bundle/info CFBundleVersion"}

set theComponents to {(localized string "XProtect"), (localized string "Gatekeeper"), (localized string "System Integrity Protect..."), (localized string "Malware Removal Tool"), (localized string "Core Suggestions"), (localized string "Incompatible Kernel Ext..."), (localized string "Chinese Word List"), (localized string "Core LSKD (kdrl)")}
set theTabSpaces to ""

--set _multiTabs to tab & tab & tab & tab 
set _multiTabs to getTabs(localized string "Component" & tab)
set displayString to (localized string "Component") & _multiTabs & (localized string "Version") & tab & (localized string "Updated") & tab & tab & (localized string "Time") & return & "_______________________________________________________________" & return & return


########################################## 
# Handlers 
########################################## 


# calculate the number of tabs required for the display dialog 
on getTabs(aWord)
set n to round (25 - (length of aWord)) / 4
if n is less than 0 then set n to 1
if length of aWord is 10 then set n to 3
set this_tab to tab
repeat n times
set this_tab to this_tab & tab
end repeat
return this_tab
end getTabs

#get the last change date 
on getUpdatedDate(aFile)
set d to do shell script "stat -f \"%Sc\" -t \"%d-%m-%Y %H:%M\" " & aFile
set end of my thisDate to d
return d


end getUpdatedDate

#compare the dates to see if there's been a change 
on checkLastUpdate(aDateString, anIndex)
set n to text 1 thru 10 of aDateString
set o to text 1 thru 10 of my (item anIndex of lastUpdate)


if (n is equal to o) then
return ""
else
return my updateMarker
end if
end checkLastUpdate


########################################## 
# Commands 
########################################## 

# read the dates into our script from the last run 
set oldTIDS to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
try
set s to (do shell script "cat " & saveLocation)
set lastUpdate to text items of s
end try
set AppleScript's text item delimiters to oldTIDS

# this is the workhorse, getting all the data for each component 
repeat with i from 1 to number of items in theComponents
try
set component_item to item i of theComponents
set version_item to item i of VersionStrings
set time_item to item i of TimeStrings
set theTabSpaces to getTabs(component_item)
set updatedDate to getUpdatedDate(time_item)


# check if we had some saved dates from a previous run 
#and if so, check them against the current dates 
if (count of (lastUpdate as list)) = (count of theComponents) then
set my hasBeenUpdated to checkLastUpdate(updatedDate, i)
end if


# organise the display string 
set v to (do shell script "defaults read " & version_item)
if length of v < 4 or (length of v < 6 and v contains ".") then set v to v & tab
set displayString to displayString & component_item & theTabSpaces & v & tab & updatedDate & my hasBeenUpdated & return
set my hasBeenUpdated to ""
end try
end repeat

#write out current dates to file 
set writeData to ""
repeat with i from 1 to number of items in thisDate
set this_item to item i of thisDate
if length of writeData is 0 then
set writeData to this_item
else
set writeData to writeData & "," & this_item
end if
end repeat
do shell script "echo " & writeData & "> " & saveLocation

# finally, get the OS version and build 
set theSysInfo to (do shell script "sw_vers")
set sysString to paragraph 2 of theSysInfo & return & paragraph 3 of theSysInfo
set displayString to displayString & return & sysString

# and... 
set _close to localized string "Close"
set _title to localized string "Critical Updates (v.1.3)"
display dialog displayString buttons {_close} default button _close with title _title

#EOF
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: FastScripts and script editor discrepancies
      • From: Shane Stanley <email@hidden>
    • Re: FastScripts and script editor discrepancies
      • From: Yvan KOENIG <email@hidden>
References: 
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)

  • Prev by Date: Re: Mail script puzzlement
  • Next by Date: Re: Mail script puzzlement
  • Previous by thread: Re: Script Libraries
  • Next by thread: Re: FastScripts and script editor discrepancies
  • Index(es):
    • Date
    • Thread