Fwd: Modifying a .plist file
Fwd: Modifying a .plist file
- Subject: Fwd: Modifying a .plist file
- From: Michelle Steiner <email@hidden>
- Date: Sun, 23 Feb 2003 20:18:52 -0700
Begin forwarded message:
From: Michelle Steiner <email@hidden>
Date: Sun Feb 23, 2003 6:31:57 PM America/Phoenix
To: "David R. Pierce" <email@hidden>
Subject: Re: Modifying a .plist file
On Sunday, February 23, 2003, at 05:08 PM, David R. Pierce wrote:
I'm not an Applescript wizard or guru, I mostly just modify other
people's scripts. I have never opened a file using Applescript
(except to tell some program to do it). As for it always being in the
same place, yes with the proviso that I don't know if .plist files can
be modified by the author in future revisions. So how do I find the
location of a number in a file? And half the time it will be the
number 5, and the other half of the time it will be the number 17.
Well, you would have to visually inspect the file in a word processor
to determine the position of the number, and you would have to
determine whether the has a leading zero. Let's assume that the 5
doesn't have a leading zero, because that is harder. I created a dummy
file just for this example, with the 28th character as "5". This will
assume that the number will be either a one-digit number in the 28th
position, or a 2-digit number in the 28th and 29th positions.
--Michelle
property myPList : missing value
try
set myFile to (open for access myPList with write permission)
on error
set myPList to choose file
set myFile to open for access myPList with write permission
end try
set plistData to read myFile
set part1 to text 1 through 27 of plistData
if character 28 of plistData is "5" then
set part2 to text 29 thru end of plistData
set replacement to "17"
else
set part2 to text 30 thru end of plistData
set replacement to "5"
end if
set newText to part1 & replacement & part2
set eof myFile to 0
write newText to myFile
close access myFile
--
"There's some good in the world, Mr. Frodo, and it's worth fighting
for."
--
"There's some good in the world, Mr. Frodo, and it's worth fighting
for."
_______________________________________________
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.