Please recheck "separated word" script

edited 7:54PM in FastReport 4.0
Hi , participant and expert,

I try to separated the word in database field . Data in the same field but separated with upper comma (')
For example, In database field name "Description" . There are 2 data . 1) ABCDE'150 2) FGHIJ'190

In fast report I query field "MatrDesc" to Dataset. Then in the " code page" I codeing script by use pascal script as below.


var MatrDesc,descrip,width:string;

function fetch(var value: string; vDelimiter: string): string;
var
idx: integer;
begin


idx := pos(vDelimiter, value);
if idx > 0 then begin
Result := Copy(value, 1, idx-1);
value := Copy(value, idx+length(vDelimiter), Length(Value));
end else begin
Result := value;
value := '';
end;
end;


begin

MatrDesc := (<tbDetail."MatrDesc">);
descrip := fetch(matrdesc, '''');
width := fetch(matrdesc, '''');


end.

But. The result is not show as I need.
The result can separated the word in the field as well , but it always show only one data as below.

FGHIJ 190

FGHIJ 190



Actually, My prefer result should be.


ABCDE 150

FGHIJ 190




Please advise , What's I have mistaken in code ?

Modnoyx




Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited 7:54PM
    Whatever you put between the main
    begin
    (..)
    end.
    
    only happens 1 time, at the start of the report, so you only actually calculate MatrDesc 1 time. Put a
    <!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->showmessage(MatrDesc); <!--fontc--></span><!--/fontc-->
    there and you will see it only happens once.
    Put that code
    MatrDesc := (<tbDetail."MatrDesc">);
    descrip := fetch(matrdesc, '''');
    width := fetch(matrdesc, '''');
    

    on a MasterData1.OnBeforePrint event and it should be fine, as it will be called for each record in the dataset.

    Modnoyx wrote: »
    Hi , participant and expert,

    I try to separated the word in database field . Data in the same field but separated with upper comma (')
    For example, In database field name "Description" . There are 2 data . 1) ABCDE'150 2) FGHIJ'190

    In fast report I query field "MatrDesc" to Dataset. Then in the " code page" I codeing script by use pascal script as below.


    var MatrDesc,descrip,width:string;

    function fetch(var value: string; vDelimiter: string): string;
    var
    idx: integer;
    begin


    idx := pos(vDelimiter, value);
    if idx > 0 then begin
    Result := Copy(value, 1, idx-1);
    value := Copy(value, idx+length(vDelimiter), Length(Value));
    end else begin
    Result := value;
    value := '';
    end;
    end;


    begin

    MatrDesc := (<tbDetail."MatrDesc">);
    descrip := fetch(matrdesc, '''');
    width := fetch(matrdesc, '''');


    end.

    But. The result is not show as I need.
    The result can separated the word in the field as well , but it always show only one data as below.

    FGHIJ 190

    FGHIJ 190



    Actually, My prefer result should be.


    ABCDE 150

    FGHIJ 190




    Please advise , What's I have mistaken in code ?

    Modnoyx
  • edited 7:54PM
    Dear Anu de Deus,

    Thank a million , I very appreciated.

    Modnoyx

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.