How to find NewLine char in a text field

Hi, I am using NA3.60. I have a text field,which has new line char included, now how do i find it…i can see the newline from a Hex Editor though. It would be nice if some one can help like below if gvChar = Newline then //some idea how to detect CR/CF cheers, JHC

Hi, the ASCII Values for CarriagReturn (CR) is 13, that for LineFeed(LF) is 10. so you could search for those two Characters in your Text and compare it to those two values I use something like this, when reading from a File: Define CR, LF, Character as Char CR := 13; LF := 10; // … read next Character f.READ(Character); IF (Character IN [CR,LF]) THEN // do something

Hi, My situation involve’s finding a CR/LF (Newline) in a Text field in a table. I don’t have a file situation. This is because i lately found that some database tables had text fields along with Newline characters in them…Now i would like to remove to newline characters from the text fields. cheers, JHC

Well, if you want to delete the LineFeed and CarriageReturns try DELCHR regards Daniel Zimmermann

Hi, Thanks …but still i haven’t got my WHICH in ur DELCHR NewString := DELCHR(String [, Where] [, Which]) Can u tell me what “WHICH” should be for NewLine or CR/LF… cheers, JHC

Define variable CRLF : Text 2 CRLF[1] := 13; CRLF[2] := 10; NewString := DELCHR(String, ‘=’, CRLF);

Hi Viktros, Maybe ur DELSTR works on while doing a File Reading… But our topic is How to find NewLine char in a TEXT FIELD in a table. Now try this… open excel type Item Decription in a cell, copy and paste in Description Field in Item No. 1000. Now highlight the description , by holding the mouse and drag from First char to end of field. Can u see the last 2 Blank chars its the New Line. If u further need detail copy this Description Field content and paste in any Hex Editor… u can see “0D 0A”…Or if it looks complicated just make a dataport and export this record to text or csv file… u can see after the Description field there would be Line Break ( NewLine or CR/CF)… cheers, JHC

To delete all the CRLF characters in your Item.Description field, build a report (Property Processing Only=TRUE) Define the Variable as Viktoras suggests. then do the following in the Item Section: Item - OnPreDataItem() CRLF[1] := 13; CRLF[2] := 10; Item - OnAfterGetRecord() Item.Description := DELCHR(Item.Description, ‘=’, CRLF); Item.MODIFY; After that, all the CRLF Characters in your Description Field should be history. Daniel

Hi, Thanks for ur efforts chaps… maybe ur way to find Newline works while reading file, but doesn’t work the same way on a Text field in a table. I tried out the suggestions given but only found that it was trying to find 13 or 10 in the string and not CR/LF. As i mentioned if u need a new line characher in ur text field for trial …just type a word in excel cell, copy the whole cell and paste in a Text field in navision and try it out…with ur codes…Oops long way to goo… Is there any function in NA3.60 which can get back ASCII or HEX code…? cheers, JHC

Hi Chander, in fact the code that you have as example is correct and works fine, independant of being applied to reading a file or a text field. The information you are missing is to define the variable CRLF as char and not as text! Have a look at the online help regarding char variables which actually serve to obtain ASCII numbers and corresponding letters. So the complete solutions should look like this: Name DataType Subtype Dimensions Item Record Item CRLF Char 2 CRLF[1] := 13; CRLF[2] := 10; Item.Description := DELCHR(Item.Description, '=',FORMAT(CRLF[1])); Item.Description := DELCHR(Item.Description, '=',FORMAT(CRLF[2])); Item.MODIFY; Saludos Nils

Hi All, Thank u very much…atlast i could understand what all meant…it worked out…[:p] cheers, JHC

Why not try STRPOS(string,Format(CR)) ???

Hi hem, Please try to import this .txt (form 60000) 1. copy a field from excel and paste to sample field (in form); 2. then click ‘clean button’ Cheers.

quote:

OBJECT Form 60000 TestExcelBlank { OBJECT-PROPERTIES { Date=17/02/05; Time=14:32:57; Modified=Yes; Version List=; } PROPERTIES { Width=10340; Height=2860; SourceTable=Table27; } CONTROLS { { 1000000000;TextBox;4070 ;770 ;2750 ;440 ;SourceExpr=“No.” } { 1000000001;Label ;110 ;770 ;3850 ;440 ;ParentControl=1000000000 } { 1000000002;TextBox;4070 ;1320 ;5500 ;440 ;FontUnderline=Yes; SourceExpr=Description } { 1000000003;Label ;110 ;1320 ;3850 ;440 ;ParentControl=1000000002 } { 1000000006;CommandButton;110;1980;2200;550;CaptionML=ENU=Clean; OnPush=BEGIN strlist := ‘’; FOR i := 1 TO STRLEN(Description) DO strlist += FORMAT(Description[i] ) + ‘_’; MESSAGE(’%1 %2’,strlist,i); blankcode1 := COPYSTR(Blanktxt,STRLEN(Blanktxt),1); blankcode2 := COPYSTR(Blanktxt,STRLEN(Blanktxt)-1,1); //“Description 2” := DELCHR(Description,’=’,blankcode1); Description := DELCHR(Description,’=’,blankcode1); Description := DELCHR(Description,’=’,blankcode2); MODIFY; END; } { 1000000007;TextBox;4070 ;220 ;4400 ;440 ;FontUnderline=No; SourceExpr=Blanktxt } { 1000000004;Label ;110 ;220 ;3850 ;440 ;CaptionML=ENU=Sample Text from Excel field } } CODE { VAR blankcode1@1000000000 : Text[20]; blankcode2@1000000003 : Text[20]; Blanktxt@1000000001 : Text[30]; pos@1000000002 : Integer; strlist@1000000004 : Text[1024]; i@1000000005 : Integer; BEGIN END. } }

Hi Jatu, Thanks for ur response. Anyway it would faster solution to use DELCHAR option suggested by our previous respondants with direct ASCII assignment, as ur FOR Loop look a bit slowing down the things, in case our TEXT field or VARIABLE is 250 or above in length… The reason i would like to put the bit of code on OnValidate() of the Description fields on most of the Master Tables and Journals Tables cheers, JHC

quote:

The reason i would like to put the bit of code on OnValidate() of the Description fields on most of the Master Tables and Journals Tables
Originally posted by JHC - 2005 Feb 17 : 14:15:13

I mean I do not know how many “Master” tables you have but you should think about using the ChangeLogManagement and the global “OnModify” and “OnInsert” triggers to do what you want. This will be less work and works for ALL tables.