Re: referencing a variable from another?
Re: referencing a variable from another?
- Subject: Re: referencing a variable from another?
- From: Paul Skinner <email@hidden>
- Date: Sat, 1 Feb 2003 00:43:54 -0500
On Friday, January 31, 2003, at 09:24 PM, James Burns wrote:
Hello:
I'm just starting out relearning AppleScript, Please bear with me.
I'm trying to use one variable, which contains the name of a second
variable, to change the value of the "named" variable. Make sense?
Here's the snippet I'm working on:
...
set RGBname to "SaveRGBImagesPrefix"
set FirstFrame to "FirstFrame"
set LastFrame to "LastFrame"
set FrameStep to "FrameStep"
set stuffToGet to {RGBname, FirstFrame, LastFrame, FrameStep}
log stuffToGet
repeat with x in stuffToGet
set searchWord to x
try
set text item delimiters to return
set i to text items of fileContents
repeat with foundIt in i
if foundIt contains searchWord then
log "Found line is " & foundIt
set text item delimiters to " "
set cleaned to (text items 2 thru -1 of foundIt) as string
log cleaned
HERE"S WHERE I NEED TO ASSIGN THE VALUE HELD IN CLEANED TO THE
VARIABLE CONTAINED IN SEARCHWORD
exit repeat
end if
end repeat
set text item delimiters to oldDelims
on error what
set text item delimiters to oldDelims
display dialog "Sorry. " & what
end try
...
Thanks in advance for any help.
-----
James Burns
--I made up some data for testing...
set fileContents to "header stuff
SaveRGBImagesPrefix true
FirstFrame 00:00:01:07
other info stuff
LastFrame 00:00:02:44
FrameStep 30
more stuff
"
set oldDelims to text item delimiters
set RGBname to "SaveRGBImagesPrefix"
set FirstFrame to "FirstFrame"
set LastFrame to "LastFrame"
set FrameStep to "FrameStep"
set stuffToGet to {RGBname, FirstFrame, LastFrame, FrameStep}
log stuffToGet
repeat with currentItem from 1 to length of stuffToGet
set searchWord to item currentItem of stuffToGet
try
set text item delimiters to return
set i to text items of fileContents
repeat with foundIt in i
if foundIt contains searchWord then
log "Found line is " & foundIt
set text item delimiters to " "
set cleaned to (text items 2 thru -1 of foundIt) as string
log cleaned
set item currentItem of stuffToGet to cleaned
exit repeat
end if
end repeat
set text item delimiters to oldDelims
on error what
set text item delimiters to oldDelims
display dialog "Sorry. " & what
end try
end repeat
return stuffToGet
-->{"true", "00:00:01:07", "00:00:02:44", "30"}
This could be done more efficiently, but I thought you might appreciate
a direct answer to your question. Happy AppleScripting! You couldn't
have picked a better time to start.
--
Paul Skinner
"The Church says the Earth is flat. But I know the Earth is round, for
I have seen the shadow on the moon, and I have more faith in a shadow
than in the Church." - Magellan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.