How to save in text file

palan
Member Posts: 26
Hi,
I would like to know what is the returnversion in the below code & I want to save the returnversion in text file. How to do that? Can someone provide me some idea. Thanks.
IF STRPOS("No.",'R') <> 0 THEN
EVALUATE(ReturnVersion,DELCHR(COPYSTR("No.",STRPOS("No.",'R')+1,1)))
ELSE
ReturnVersion := 0;
IF ReturnVersion = 0 THEN
NewSalesOrderHeader."No." := "No." + 'R1'
ELSE
NewSalesOrderHeader."No." := COPYSTR("No.",1,STRPOS("No.",'R'))
+ 'R' + FORMAT(ReturnVersion + 2);
I would like to know what is the returnversion in the below code & I want to save the returnversion in text file. How to do that? Can someone provide me some idea. Thanks.
IF STRPOS("No.",'R') <> 0 THEN
EVALUATE(ReturnVersion,DELCHR(COPYSTR("No.",STRPOS("No.",'R')+1,1)))
ELSE
ReturnVersion := 0;
IF ReturnVersion = 0 THEN
NewSalesOrderHeader."No." := "No." + 'R1'
ELSE
NewSalesOrderHeader."No." := COPYSTR("No.",1,STRPOS("No.",'R'))
+ 'R' + FORMAT(ReturnVersion + 2);
0
Comments
-
I have not tested this but it should work.
"FileName" is a variable with datatype Text, containing the name of the file you wish to create. As is evident from the code, the file will be erased if it already exists.
The same file will be created every time and it will only contain the value of ReturnVersion in text format. You probably would want to construct the filename in some way that make it possible to figure out where the ReturnVersion value originated from. You could also write such information in the file itself.
Anyway i think my code points you to some of the functions you can use to solve your problem.
IF EXISTS(FileName) THEN
ERASE(FileName);
File.WRITEMODE(TRUE);
File.TEXTMODE(TRUE);
IF File.CREATE(FileName) THEN BEGIN
File.WRITE(ReturnVersion);
File.CLOSE();
END;0 -
Hi,
I have saved the returnversion to text file using the below code. Thanks for your help.
file1.CREATE('c:\\test.txt');
file1.CREATEOUTSTREAM(stream);
stream.WRITETEXT(COPYSTR(temno,1,STRPOS(temno,'R')-1) + 'R' + FORMAT( ReturnVersion + 1));
file1.CLOSE();0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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