Import and display (part of) a BigText
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:
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:
But of course it doesn't works as I am dealing with BigTexts.
Is there a good Samaritan to help me? O:)
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)
"I don't want to believe. I want to know." (Carl Sagan)
0
Answers
-
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)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions