Import and display (part of) a BigText

dulaman
dulaman Member Posts: 73
Hi all,

I am trying NAV does this when I press a button in a form:

1. First, open a dialog
2. Choose a text file (that BTW contents a lorry route)
3. Import the content of that file into a BLOB field ("Full Route")
4. Display the first 250 chars of the BLOB field in a text box

My current code (for the button) is:
"Full Route".IMPORT(file,TRUE);
CALCFIELDS("Full Route");
"Full Route".CREATEINSTREAM(istream);
textLarge.READ(istream);
textLarge.GETSUBTEXT(MegaRoute, 1, 250);
Rec.RouteOne := MegaRoute;
CurrForm.UPDATE;

This seems to work fine but I wonder if there is a better way to store the Full Routes as my method implies to use an external program (NotePad), write down the route on it and then save the result. Too much work for an end user! :)

Could it be possible to write the route directly in a Navision window? i.e., creating a textbox with the variable MegaRoute inside: you write the route on that textbox (max 1024 chars), the result of the variable goes to "Full Route" field and the first 250 chars goes to another short version of the field, just to be displayed.

How should I change my code to do that?? The steps should be something like this:
"Full Route" := MegaRoute;
textLarge.GETSUBTEXT(MegaRoute, 1, 250);
RouteOne := textLarge;

But of course it doesn't works as I am dealing with BigTexts.

Is there a good Samaritan to help me? O:)
-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)

Answers

  • dulaman
    dulaman Member Posts: 73
    Meanwhile... I've just found a solution for my own question. A couple of burnt neurones was the price I had to pay, but it was worthwhile. :)

    The question was: how can you import a BigText to a BLOB Field and display (part of) it?

    The plain answer:

    a) If you want to import the BigText from an external file:

    "Your BLOB Field".IMPORT(file,TRUE);
    CALCFIELDS("Your BLOB Field");
    "Your BLOB Field".CREATEINSTREAM(istream);
    BigTextVar.READ(istream);
    BigTextVar.GETSUBTEXT(YourVar, 1, 250);
    Rec."Short version of BLOB Field" := YourVar;
    CLEAR(YourVar);
    CLEAR(BigTextVar);
    CurrForm.UPDATE;
    


    b) If you want to input the BigText in a textbox (limit of 1024 chars!):

    BigTextVar.ADDTEXT(YourVar);
    "Your BLOB Field".CREATEOUTSTREAM(ostream);
    BigTextVar.WRITE(ostream);
    MODIFY();
    
    "Short version of BLOB Field" := COPYSTR(YourVar, 1, 247) + '...';
    CLEAR(YourVar);
    CLEAR(BigTextVar);
    CurrForm.UPDATE;
    


    OK, enjoy it!
    -- dulaman
    "I don't want to believe. I want to know." (Carl Sagan)