views:

563

answers:

2

When I run the following:

left({_v_kap.cpudesc}, (instr({_v_kap.cpudesc},",") ))

the function outputs : ¤¤Y¤ and other variations

however if I just run

   left({_v_kap.cpudesc}, 48)

it returns the string correctly up to character 48 and if I just run

instr({_v_kap.cpudesc},",") 

it returns 48

If I combine them, shouldn't this work? any ideas? thanks in advance

A: 

Phill,

In the code you provided one ")" is missing.

I believe it should be

left({_v_kap.cpudesc}, (instr({_v_kap.cpudesc},",") ) ) 

Thnks

rookie
I added that in and it didn't seem to make a difference. thanks for the response
phill
+1  A: 

Figured it out. If the instr() function doesn't find the item, the entire function bombs.

I checked the statement to see if its greater than zero. check if it runs, do it, otherwise don't check for the comma

pos := instr({_v_kap.cpudesc},",")

if pos > 0 then left({_v_kap.cpudesc}, (instr({_v_kap.cpudesc},",") )) else {_v_kap.cpudesc}

this fixed the issue.

phill