How to create a varaible file name?

gdkve9
Member Posts: 161
Hello everyone here in the forum..
I have to create a file whose name is variable which means for every time a processing report is run, a file with varaible name should get generated into a drive.
I have looked for variable file name in the forum but not able to get any clue here.
If is a static file name, for e.g., LSRETAIL.txt then we can use..
OutFileName Text 200
OutFile File
OutFileName := 'C:\LSRETAIL.txt';
OutFile.CREATE(OutFileName); //would create the file
But my problem is every time a new file should get generated in to some temp folder, the name being included with current date,current time,terminal no., transaction no. etc.
May be I am missing the basics here but will be very thankful if I get some solution for this.
Thanks in advance for all.
I have to create a file whose name is variable which means for every time a processing report is run, a file with varaible name should get generated into a drive.
I have looked for variable file name in the forum but not able to get any clue here.
If is a static file name, for e.g., LSRETAIL.txt then we can use..
OutFileName Text 200
OutFile File
OutFileName := 'C:\LSRETAIL.txt';
OutFile.CREATE(OutFileName); //would create the file
But my problem is every time a new file should get generated in to some temp folder, the name being included with current date,current time,terminal no., transaction no. etc.
May be I am missing the basics here but will be very thankful if I get some solution for this.
Thanks in advance for all.
Dilip
Falling down is not a defeat..defeat is when you refuse to get up.
Falling down is not a defeat..defeat is when you refuse to get up.
0
Comments
-
Last time I had to do something similar it was like this:
reportTime := TIME;
timeText := FORMAT(TODAY,0,'<Day>_<Month>_<Year4>');
timeText += FORMAT(reportTime,0,'<Hours24,2>_<Minutes,2>_<Seconds,2>');
fileName := fileName + timeText + '.txt';
Is this close to what you need?0 -
My favorite is to use a number series with the NoSeriesManagement codeunit.
FileNo := NoSeriesManagement.GetNextNo(Setup."File No. Series", WORKDATE, TRUE);
Robert de Bath
TVision Technology Ltd0 -
kapamarou wrote:fileName := fileName + timeText + '.txt';
Because if you assign a path like this
OUtFileName := 'C:\fileName.txt';
OutFile.Create(OutFileName); //would create the file name with fileName.txt but not with value stored in fileName varaible.
Could you please mention the line of code for assigning a file name(which is stored in fileName varaible) along with the path(suppose if the file need to be created in C colon like C:\XXXXXXXXX.txt)
Will be wiating for your valuable reply.
Thanks.Dilip
Falling down is not a defeat..defeat is when you refuse to get up.0 -
OK.
Declare the following text variables:
pathName, fileName,fileStartName, timeText
Declare myTime as time. Then Do:
pathName := 'c:\outpoutfiles\'; <- Or any directory you want.
fileStartName := 'LSRETAIL';
myTime := TIME; <- Get the current time.
timeText := FORMAT(TODAY,0,'<Day>_<Month>_<Year4>');
timeText += FORMAT(reportTime,0,'<Hours24,2>_<Minutes,2>_<Seconds,2>'); <- These two lines give timeText the date and time.
fileName := pathName + fileStartName + timeText + '.txt'; <- this concatenates the texts
Then : OutFile.CREATE(fileName);
Play around with this a bit to make it suit your needs...0 -
You're welcome0
-
gdkve9 wrote:I have to create a file whose name is variable which means for every time a processing report is run, a file with varaible name should get generated into a drive.Use this function to create a temporary file. This enables you to save data of any format to a temporary file. This file has a unique name and will be stored in the temporary files folder.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)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