Different behavior using declared data vs. data from a list
Different behavior using declared data vs. data from a list
- Subject: Different behavior using declared data vs. data from a list
- From: Lorin Rivers <email@hidden>
- Date: Fri, 10 Oct 2003 00:46:03 -0500
This code works in isolation, but when I replace the strings in the
"set theNewText..." with variables I don't get the same result even
though the data is the same.
set theNewText to trim_line("0.0);",");",1)
--returns "0.0"
This, however, does not work.
--{"INSERT INTO nuke_users VALUES (1", "''", "'foobar'",
"'email@hidden'", "''", "''", "NULL", "''", "NULL", "NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"'3858f62230ac3c915f300c664312c63f'", "10", "''", "0", "0", "0", "''",
"0", "''", "''", "4096", "0", "0.0);"}
the last item returns as "0,.,0" -- I don't get it. Looks to me as if
"0.0);" = "0.0);"
set savedTextItemDelimiters to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {","}
repeat with i from 1 to count of theDataIn
set theLine to text items of item i of theDataIn
set item 1 of theLine to trim_line(item 1 of theLine, theBeginning, 0)
set (the last item of theLine) to trim_line(the last item of theLine,
theEnd, 1)
copy theLine to the end of theBigList
end repeat
-- trimLine code
set AppleScript's text item delimiters to savedTextItemDelimiters
on error m number n from f to t partial result p
--also reset text item delimiters in case of an error:
set AppleScript's text item delimiters to savedTextItemDelimiters
--and resignal the error:
error m number n from f to t partial result p
end try
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return
end try
end repeat
end if
-- TRIM ENDING
if the trim_indicator is in {1, 2} then
repeat while this_text ends with the trim_chars
try
set this_text to characters 1 thru -(x + 1) of this_text as string
on error
-- the text contains nothing but the trim characters
return
end try
end repeat
end if
return this_text
end trim_line
--
Lorin Rivers
Marketing Professional
<
mailto:email@hidden>
<
http://homepage.mac.com/lrivers>
512.478.8114
_______________________________________________
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.