Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: writing file



Rhon,

Perhaps this will get you started:

-- BEGIN SCRIPT SNIPPET

set theResults to "{" & return & " timer = {" & return & " value = " & timerValue & ";" & return & " color = " & timerColor & return & " };" & return & " beep = {" & return & " setting = " & beepSetting & ";" & return & " };" & return & " ws1 = {" & return & " wstring = " & ws1 & ";" & return & " color = " & ws1Color & ";" & return & " };" & return & " ws2 = {" & return & " wstring = " & ws2 & ";" & return & " color = " & ws2Color & ";" & return & " };" & return & " ws3 = {" & return & " wstring = " & ws3 & ";" & return & " color = " & ws3Color & ";" & return & " };" & return & "}"

try
set theDestination to ((path to "cusr") as string) & "Documents:output:theResults.txt"
set fileResult to open for access file thedestination with write permission
set eof fileResult to 0

write theResults to fileResult starting at eof

close access fileResult

on error
try
close access file wFile
end try
-- Either destination folder does not exist or the file is already open.
display dialog ("File could not be written. It may already be open, or the output folder did not exist.")
end try

-- END SCRIP SNIPPET

You can alternately leave carriage returns within the " "'s for easier reading:
set theResults to "{
timer = {
value = " & timerValue & ";
color = & timerColor & "
};
" etc. etc.

Cheers,
Joe

P.S. did you intend on omitting the semicolon after the variable TimerColor?



On Sunday, August 24, 2003, at 02:50 PM, Rhon Fitzwater wrote:

I have some text that I need to save to a file, but I am not sure of
the best way to go about writing the file. Below is the data that I
need to save to one file.
===================================
{
timer = {
value = timerValue;
color = timerColor
};
beep = {
setting = beepSetting;
};
ws1 = {
wstring = ws1;
color = ws1Color;
};
ws2 = {
wstring = ws2;
color = ws2Color;
};
ws3 = {
wstring = ws3;
color = ws3Color;
};
}
=========================
Note that, timerValue, timerColor, beepSetting, ws1, ws1Color, etc. are
all variables that are defined in my script. What would be the easiest
way to write the data above out to a file (i.e: ~/Documents/output. I
need this file to keep its formatting.

Thanks in advance for the help.

-Rhon
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: writing file (From: Rhon Fitzwater <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.