Reading Big Text

Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
Hi everybody!
I need a little help!
I've a BigText variable that contains the value of a BLOB field.
I need to bring the first 1024 characters and put them into the first element of an array.
I tried with the COPYSTR Function but I knew that it won't work because BigText doesn't support classic text function.
RecordVar.BlobField.createinstream(VarInstream);
BigTextVar.read(VarInstream);
VarArray[1] := CopySTR(BigTextVar,0,1024);
So I'm wondering if there's another way...
~Rik~
It works as expected... More or Less...

Answers

  • SNielsenSNielsen Member Posts: 37
    As seen in the online help:

    GETSUBTEXT
    Use this function to retrieve part of a BigText variable.

    [RetLength] := BigText.GETSUBTEXT(Variable, Position [,Length])
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    SNielsen wrote:
    As seen in the online help:

    GETSUBTEXT
    Use this function to retrieve part of a BigText variable.

    [RetLength] := BigText.GETSUBTEXT(Variable, Position [,Length])

    I'd already tried with this function but i didn't understand how to avoid the error that it shows: "You can't open an empty BLOB"
    IF VarRecord.BlobField.HASVALUE THEN BEGIN
      VarRecord.BlobField.CREATEINSTREAM(ISInstream);
      VarBigText.READ(ISInstream);
      VarBigText.GETSUBTEXT(TXTArray[1],0,1024);
    END;
    
    ~Rik~
    It works as expected... More or Less...
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    I still post my attempts with hope that someone could help me...
     VarBigText.ADDTEXT(VarRecord.BLOBField);
      VarBigText.GETSUBTEXT(TXTArray[1],1,1024);
    

    and i put TXTarray[1] as SourceExpr a textbox in the report. with this method it prints only ' * '
    ~Rik~
    It works as expected... More or Less...
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    Solved!
    Thanks all!
    ~Rik~
    It works as expected... More or Less...
  • RChurchillRChurchill Member Posts: 55
    Well done for solving it.

    Would you like to consider posting how you solved it?
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    here is the method I used to solve my problem...
    I := 0;
    Len := 0;
    CLEAR(VaInstream);
    VarText := '';
    REPEAT
      I := I + 1;
      Array[I] := '';
    UNTIL I = 10;
    
    VarRecord.CALCFIELDS(Blob Field);
    IF VarRecord.BlobField.HASVALUE THEN BEGIN
      VarRecord.BlobField.CREATEINSTREAM(VarInstream);
      I := 1;
      WHILE NOT (VarInstream.EOS()) AND (I < 10) DO BEGIN
        Len := STRLEN(Array[I]);
        IF (len >= 1024) OR ((len + 50) >= 1024) THEN BEGIN
          I := I +1;
          VarInstream.READTEXT(VarText);
          Array[I] := Array[I] + VarText + ' ';
        END ELSE BEGIN
          VarText := '';
          VarText := Array[I];
          VarInstream.READTEXT(Array[I], 50);
          Array[I] := VarText +' '+ Array[I];
          VarText := '';
        END;
      END;
      IF I >= 10 THEN
        ERROR('Description too large Contact the programmer.);
    END;
    

    in this way i put all the blob in an array. in each element there's 1024 characters of the blob. the array has got 10 elements so user can write 10240 characters. if you need for more characters you can set dimensions of the array to a larger number.

    I hope that this topic could be usefull.

    regards!
    ~Rik~
    It works as expected... More or Less...
  • nbangazanbangaza Member Posts: 30
    thank you very much for this post, it also helped me with a problem i have been sitting with for months!!
    you have made my day.
  • animaconsultinganimaconsulting Member Posts: 10
    That's a brilliant solution - thanks for posting this!
    Chris
    ánima Consulting
    http://animaconsulting.co.uk
Sign In or Register to comment.