IF>CHARACTER=. ERROR

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
sailor dude
Pro Scripter
Posts: 50
Joined: Fri Jan 20, 2006 10:43 pm

IF>CHARACTER=. ERROR

Post by sailor dude » Mon Jun 09, 2008 4:12 pm

Below is a part of a script I wrote:

Length>PRODUCT,LENGTH
MidStr>PRODUCT,LENGTH,1,CHARACTER
MessageModal>CHARACTER

If>CHARACTER=.
Let>LENGTH=LENGTH-1
MidStr>PRODUCT,1,LENGTH,MOD_PRODUCT
MessageModal>. %MOD_PRODUCT%
EndIf>


The purpose is to eliminate a period from the end of a word.
However, if CHARACTER is 0, the script goes into the IF/EndIf statements and eliminates a 0 from the end of a word. I have other IF/EndIf statements to eliminate other characters; spaces, commas, etc... These other If/EndIf statements work properly.

Any help is greatly appreciated.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 09, 2008 4:44 pm

See this thread

Since 0 and . are numerically equal, you have to treat them as strings.

Code: Select all

Let>PRODUCT=abcde0
Length>PRODUCT,LENGTH
MidStr>PRODUCT,LENGTH,1,CHARACTER
MessageModal>CHARACTER


//If>CHARACTER=.
//Let>LENGTH=LENGTH-1
//MidStr>PRODUCT,1,LENGTH,MOD_PRODUCT
StringReplace>PRODUCT,.,,MOD_PRODUCT
MessageModal>. %MOD_PRODUCT%
EndIf>

sailor dude
Pro Scripter
Posts: 50
Joined: Fri Jan 20, 2006 10:43 pm

Thank You

Post by sailor dude » Mon Jun 09, 2008 5:26 pm

Thank You

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 09, 2008 5:43 pm

Just occurred to me that you said:
The purpose is to eliminate a period from the end of a word
What I posted above will remove ALL periods. Below will only remove the period if it is the last character.

Code: Select all

Let>PRODUCT=.abcde.
Length>PRODUCT,LENGTH
MidStr>PRODUCT,LENGTH,1,CHARACTER
Sub>LENGTH,1
MidStr>PRODUCT,1,LENGTH,MOD_PRODUCT
//MessageModal>CHARACTER


StringReplace>CHARACTER,.,,CHARACTER
ConCat>MOD_PRODUCT,CHARACTER
MessageModal>. %MOD_PRODUCT%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts