Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Applescript > headache.
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 1576 of 1611
Post > Topic >>

headache.

by Joshua Whalen <joshuafwhalen@[EMAIL PROTECTED] > Feb 17, 2008 at 03:18 PM

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




 3 Posts in Topic:
headache.
Joshua Whalen <joshuaf  2008-02-17 15:18:19 
Re: headache.
Jerry Kindall <jerryki  2008-02-17 12:49:17 
Re: headache.
jb@[EMAIL PROTECTED] (Jo  2008-02-18 21:10:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 20:23:21 CDT 2008.