Strings larger then 250 characters

In the early version of Navision it was only possible to handle string with a length up till 250 characters. This was often not enough and there was only a few ways to handle those strings. E.g. store the info in several fields, variables or a text file – that was imported to a blob field.

From Navision 4 it was suddenly possible to handle strings with a length up till 2147483647 characters – this is equivalent to 2 gb. In Navision 4 the data type BigText was introduced.

BigText can only be used for variables (global, local) and not as a field type (in a table). If you need to store a BigText value in a table, then the BigText data must be moved to a BLOB.

BigText can not be displayed in forms, message windows or in the debugger.

To assign text to a BigText variable use the commands ADDTEXT.

varBigText.ADDTEXT(’my text’);
varBigText.ADDTEXT(varMyText);
varBigText.ADDTEXT(varMyText,atPosition);

If no position is omitted, the text will be added to the end of the BigText variable.

To read text from a BigText variable use the command GETSUBTEXT

varBigText.GETSUBTEXT(varText,atPosition,Length) ;

If Length is not ommitted, then the function GETSUBTEXT will retrieve data from the beginning position (atPosition) till the end of the BigText Variable.

The command TEXTPOS, can be used to search for a text in a BigText variable.

atPos := varBigText.TEXTPOS(’my search text’);

This function will often be used in combination with GETSUBTEXT

To get current length of a BigText variable use the command LENGTH.

StrLength := varBigText.LENGTH

To stream a BigText variable into a BLOB use the command WRITE.

varBigText.ADDTEXT(’Text to be stored in a BLOB field ‘);
myDemoTable.BlobField.CREATEOUTSTREAM(outstr);
varBigText.WRITE(outstr);
myDemoTable.INSERT;

To stream a BLOB into a BigText variable use the command READ.

myDemoTable.FIND(’-‘);
myDemoTable.CALCFIELDS(BlobField);
myDemoTable.BlobField.CREATEINSTREAM(InStr);
varBigText.READ(InStr);

Now you are able to create functionality which reads entire text files, text streams into BigText variables, perform searches in the BigText variables and store the entire file info in a BLOB field.

You can leave a response, or trackback from your own site.

One Response to “Strings larger then 250 characters”

  1. tomi says:

    This is very well explained, thank you!

Leave a Reply


two × = 6