Hey guys this is really annoying me, i have a way to remove a line from the output of a shell cmd but when i put it into xcode it sees /n as a cmd to instert a new line :s , is there a way to disable this or how would you suggest i go about this
great thanks for the reply, how would i put the second option into my code:
on getXY(theCoords)
--
set oldTID to AppleScript's text item delimiters
set text item delimiters to {" "}
set theX to first text item of theCoords
set theY to second text item of theCoords
set text item delimiters to oldTID
return {theX, theY}
end getXY
--runs motion cmd to find x and y axis
set theCoords to do shell script thisHere & "Contents/Resources/AMSTracker"
if theCoords is not "" then
set {theX, theY} to getXY(theCoords)
set theUpperX to theX + 1002
set theLowerX to theX + 998
set theUpperY to theY + 1002
set theLowerY to theY + 998
end if
thanks for the quick reply, but when i put it in the alarm wouldnt sound anymore, i think by doin what you suggested it has now set the results permentatly
I don’t think you’re getting the right text items:
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set test to text items of " 1 1 55"
set AppleScript's text item delimiters to ASTID
return test
if i get what you said by that last post in the delimters " " i would put 3 spaces :S
-- alarm.applescript
-- alarm
-- Created by Steven Halford on 08/04/2006.
-- Modified by semaja2 on 13/04/2006
-- Copyright 2006 Steven Halford. All rights reserved.
property appName : "MultiAlarm"
--machType is either powerbook or ibook
property machType : "powerbook"
property alarmActivated : ""
property thisHere : ""
property theUpperX : ""
property theLowerX : ""
property theUpperY : ""
property theLowerY : ""
on launched theObject
alarmActivate(1)
end launched
on idle theObject
--runs motion cmd to find x and y axis
do shell script thisHere & "Contents/Resources/AMSTracker"
set theNewCoords to last paragraph of result
if theNewCoords is not "" then
set {theNewX, theNewY} to getXY(theNewCoords)
set theNewX to theNewX + 1000
set theNewY to theNewY + 1000
--Checks the x and y axis for change if change is found it will start the process
if theNewX is greater than theUpperX or theNewX is less than theLowerX or theNewY is greater than theUpperY or theNewY is less than theLowerY then
alarmAlert(1)
else
--stops sound and reactivates systems
stop (load sound "caralarm.aiff")
set alarmActivated to "0"
end if
end if
end idle
on getXY(theCoords)
set oldTID to AppleScript's text item delimiters
set text item delimiters to {" "}
set theX to first text item of theCoords
set theY to second text item of theCoords
set text item delimiters to oldTID
return {theX, theY}
end getXY
on getSystem(theMachine)
set oldTID to AppleScript's text item delimiters
set text item delimiters to {" "}
set theModel to first text item of theMachine
set text item delimiters to oldTID
return {theModel}
end getSystem
on smsSystem(theCMD)
set oldTID to AppleScript's text item delimiters
set text item delimiters to {" "}
set smsState to first text item of theCMD
set text item delimiters to oldTID
return {smsState}
end smsSystem
--Alarm Activation Script
on alarmActivate(do)
---------------Sets paths---------------------
set thisHere to path to me
set thisHere to POSIX path of thisHere
--------------Sound Configs-----------------
--Sets the sound for alarm activation
set theArming to load sound "armx2.wav"
--------------------------------------------------
--plays the arming sound
beep
play theArming
--runs motion cmd to find x and y axis
do shell script thisHere & "Contents/Resources/AMSTracker"
set theCoords to last paragraph of result
if theCoords is not "" then
set {theX, theY} to getXY(theCoords)
set theUpperX to theX + 1002
set theLowerX to theX + 998
set theUpperY to theY + 1002
set theLowerY to theY + 998
end if
GrowlNotify("Alarm Activated", "Alarm", "Warning : Alarm Primed")
end alarmActivate
on alarmAlert(do)
--Play alarm sound
play (load sound "caralarm.aiff")
--Say
say "Help! I am being stolen."
beep
--Checks if growl has already been activated
if alarmActivated is less than 1 then
--Set the volume to MAX
set volume 100
set alarmActivatedl to "1"
GrowlNotify("Theft in progress", "Alarm", "Warning : Theft in progress")
end if
return
end alarmAlert
--Checks and controls growl
on GrowlNotify(myName, myTitle, myText)
set myApp to ""
tell application "System Events" to set GrowlRunning to ((application processes whose (name is equal to "GrowlHelperApp")) count)
if GrowlRunning ≥ 1 then
try
set myApp to "GrowlHelperApp"
set notifs to "{\"Alarm Activated\", \"Alarm Deactived\",\"Theft in progress\"}"
tell application myApp to run script "register as application \"" & appName & "\" all notifications " & notifs & " default notifications " & notifs & " icon of application \"" & appName & "\""
tell application myApp to run script "notify with name \"" & myName & "\" title \"" & myTitle & "\" application name \"" & appName & "\" description \"" & myText & "\" icon of application \"" & appName & "\""
end try
end if
end GrowlNotify
Yes. You would also need to get the second and third items instead (the first item will be “”).
You could also try doing it this way:
--runs motion cmd to find x and y axis
do shell script thisHere & "Contents/Resources/AMSTracker | /usr/bin/grep -o \"[0-9]\\+\""
set theCoords to paragraphs of result
if theCoords is not "" then
set {theX, theY} to {first item of theCoords, second item of theCoords}
set theUpperX to theX + 1002
set theLowerX to theX + 998
set theUpperY to theY + 1002
set theLowerY to theY + 998
end if