@Word not working

Hi all,

Why is this not working?

y := @Prompt([OkCancelEdit];“Reference Number”; “Which reference # do you want to replace (1, 2…etc).”;“”);

strInref := @Implode(INREF;“,”);

@prompt([ok]; “Concatenated INREF”; strInref);

wrongvalue := @Word(strInref;“,”;y);

@prompt([ok]; “Wrong Value”; wrongvalue);

For y, I have tried different values 1, 2, 3.

THe first prompt for strInref works correctly. It returns 3 values in my test which is correct with “,” in between as the separator.

INREF is a text field with “Allow Multiple Values” selected.

The second prompt for @word however doesn’t retrun anything. Even the prompt box doesn’t display, let alone the value for @word.

Any help would be greatly appreciated.

Thank you,

Gowri

Subject: @Word not working.

Your “y” variable is text – you need to make it a number.

Subject: RE: @Word not working.

That has worked. However my entire code is as follows:

y := @Prompt([OkCancelEdit];“Reference Number”; “Which reference # do you want to replace (1, 2…etc).”;“”);

strInref := @Implode(INREF;“,”);

@Prompt([Ok]; “Concatenated INREF”; strInref);

wrongvalue := @Word(strInref;“,”;@TextToNumber(y));

@Prompt([Ok]; “Wrong Value”; wrongvalue);

z := @Prompt([OkCancelEdit];“Correct Reference Number”; “Enter the correct reference # to replace the wrong one.”;“”);

Field INREF := @ReplaceSubstring( INREF; wrongvalue; z );

Field INREF2 := @ReplaceSubstring( INREF2 ; wrongvalue; z );

SELECT @All

I want to get the position of the wrong value and only replace that instance of the wrong value and not all of them.

example: If the list has 1, 2, 2, 2 etc…, I want to replace say the third occurance of 2 and not 2 in the first and the second position.

@Replacesubstring however replaces all instances of 2 like this. I want to replace 2 in position 3 by 4 and not the rest.

The result with @replacesubstring = 1, 4, 4, 4. I want the result to be 1, 2, 2, 4.

How do I do this. Any suggestion would be greatly appreciated.

Thank you,

Gowri

Subject: RE: @Word not working.

Thank you Stan!! That worked.

Subject: RE: @Word not working.

I suspect you’re having a problem because 1 != “1” – @Prompt returns a string, and @Word expects a number.

However, I have to wonder why you’re asking the user to enter a numeric position in the list, rather than letting them choose a value from the list. Use OkCancelList with INREF as the choices argument. Say you have 14 values – do you really want to make them count to see whether the value they wanted to select was number 8 or 9?

Subject: RE: @Word not working.

The reason why I am prompting the user to enter a numeric position is because the field INREF has the same value displayed at number of positions (This has been caused by an error). We need to replace the wrong value with the correct one only in certain positions and not all of them. WIth OKCANCELList, it will replace all the instances of a given value with the new one and that would not be correct.

The list will only contain 5 to 6 values at the max.

Thanks for your help with the 1! = “1”. I will look into that.