XMPie help

janiner

New member
I need to know how to write an if statement for if "chips" was in a text string "gaming chips", then to put another string in. The problem we're having is the field has different denominations and we would have to make a ton of statements so if we can search the field for just the one word that would be better. Thanks ahead for any advice.
 
Here you go.

Use Find function. It will return the starting position of string you are searching for, if the string is not found it will return -1. When any other value is returned you can then set the replacement string with your if statement.
Find (data to evaluate, expression your looking for, starting position [note 0 is the first character])

If (Find(|->[field1],"chips",0) = -1
|->[field1]
else
replacement string

If you are trying to replace "chips" with "tokens" but want to leave all the other text in the original string intact use the FindAndReplace Function.
FindAndReplace (data to evaluate, expression your looking for,replacement value)

FindAndReplace (|->[field1], "chips","tokens")

if |->[field1] = "gaming chips" the result will be "gaming tokens"
if |->[field1] = "gaming pieces" the result will be "gaming pieces"
if |->[field1] = "fish and chips" the result will be "fish and tokens"

Hope this helps someone.

t.
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top