I'm trying to strip unwanted characters from some data. the first item
is a name or indeterminate elements. for example, "Frida Hyvonen" or
"Orchestral Maneuvers in the Dark".
I want to end up with "FridaHyvonen" or "OrchestralManeuversintheDark".
So I have subroutine, the one below, and it does this part just fine.
When I repeat the same process to cleanse a date value in a similar way,
for example to turn "Saturday, February 16, 2008 12:15:46 PM" into
"Saturday,February16,200812:15:46PM", that works.
BUT! if I then take "Saturday,February16,200812:15:46PM" and try to
strip the commas, I get:
"Saturday February16 200812:15:46PM" which is not what I want. I want:
"SaturdayFebruary16200812:15:46PM", and eventually, I want to get to:
"SaturdayFebruary162008121546PM", but when I try to run the subroutine
again, to strip the spaces, I end up with:
"Saturday,February16,200812:15:46PM"
The subroutine that should do all but the last operation is below. Any
idea why I keep getting either the commas or the spaces, no matter what
I do?
on ShaveMyFileName(MyFadeDate)
set MyShaveItem to MyShowName as text
set this_text to MyShaveItem
set search_string to (ASCII character 32)
set replacement_string to {}
set MyFadeName to my replace_chars(this_text, search_string,
replacement_string)
display dialog MyFadeName
set MyTrimTime to MyFadeDate as text
set this_text to MyTrimTime as string
set search_string to (ASCII character 32)
set replacement_string to (ASCII character 0)
set MyTrimTime to my replace_chars(this_text, search_string,
replacement_string)
display dialog MyTrimTime
set MyTrimTime to MyFadeDate as text
set this_text to MyTrimTime
set search_string to (ASCII character 44)
set replacement_string to (ASCII character 0)
set MyTrimTime to my replace_chars(this_text, search_string,
replacement_string)
display dialog MyTrimTime
set MyTrimTime to MyFadeDate as text
set this_text to MyTrimTime
set search_string to (ASCII character 32)
set replacement_string to (ASCII character 0)
set MyTrimTime to my replace_chars(this_text, search_string,
replacement_string)
display dialog MyTrimTime
end ShaveMyFileName
Thanks in advance everyone.
BTW, I am running this in AppleScript Studio 2.4.1, but it makes the
same mess if I do it in script editor.
Joshua


|