SELECTSTR limitations in NAV

There is a function in NAV that enables you to retrieve a string at a certain position in a comma seperated string.

There are a few limitations to this functions.

  1. You are foreced to use a comma ‘,’
  2. You cannot use the same string twice in the same comma seperated string

From the NAV help file:

A simple solution can be found on mibuso. Using this function removed both limitations as you can specifiy which seperation value to use.

SELECTSTR treats string values as OPTIONS. This
means that identical values in different strings are not allowed.


fctGetFieldContent(pFieldNo : Integer;pText : Text[1024]) : Text[1024]
// ******************************************************************* //
//                    Code From Mibuso:                                //
//   //
// ******************************************************************* //

ReturnString := '';
FieldsFound := 1;
boo := -1;
 CounterPos += 1;
 IF pText[CounterPos] = '"' THEN
   boo *= -1
   IF (pText[CounterPos] = ',') AND (boo = -1) THEN
     FieldsFound += 1
     IF FieldsFound = pFieldNo THEN
       ReturnString := ReturnString + COPYSTR(pText,CounterPos,1);
UNTIL (CounterPos = STRLEN(pText)) OR (FieldsFound > pFieldNo);


NOTE: You could also pass the seperation string to the function and replace the line IF (pText[CounterPos] = ‘,’) AND (boo = -1) THEN with IF (pText[CounterPos] = pSerperator) AND (boo = -1) THEN

All credits go to PrebenRasmussen who posted this on Mibuso.

Tagged with:
Posted in NAV
2 comments on “SELECTSTR limitations in NAV
  1. Could be the greatest blog post I have ever seen!

  2. I could not think you are more right..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: