Repeat read folder

julkifli33
Member Posts: 1,092
Hi All,
i have created how to read file and then insert to NAV
like this
but this one is I did it using hardcode
which is only can read TestItem.txt
how to read all the txt file in GLSetup."Import Path" ??
and how to read only the file which start with "ABC" ?
thanks
i have created how to read file and then insert to NAV
like this
SFile.TEXTMODE(TRUE); SFile.WRITEMODE(FALSE); SFile.OPEN(GLSetup."Import Path" + 'TestItem.txt'); REPEAT //codeinsert to NAV UNTIL SFile.POS = SFile.LEN;
but this one is I did it using hardcode
which is only can read TestItem.txt
how to read all the txt file in GLSetup."Import Path" ??
and how to read only the file which start with "ABC" ?
thanks
0
Answers
-
Try
SFile.SETRANGE(Path,GLSetup."Import Path"); // Name Filter IF SFile.FINDSET THEN REPEAT // Read the file and insert into NAV UNTIL SFile.Next = 0;
0 -
mohana_cse06 wrote:Try
SFile.SETRANGE(Path,GLSetup."Import Path"); // Name Filter IF SFile.FINDSET THEN REPEAT // Read the file and insert into NAV UNTIL SFile.Next = 0;
SFile is datatype file, is it?
i cant do setrange0 -
Create new global variable with Datatype record and Subtype File
Use that for Filtering..0 -
mohana_cse06 wrote:Create new global variable with Datatype record and Subtype File
Use that for Filtering..
and how about to change the file name ?
this part -->SFile.OPEN(GLSetup."Import Path" + 'TestItem.txt');
for example i just want to read every txt file start with "ABC"0 -
mohana_cse06 wrote:Try
SFile.SETRANGE(Path,GLSetup."Import Path"); // Name Filter IF SFile.FINDSET THEN REPEAT // Read the file and insert into NAV UNTIL SFile.Next = 0;
Add your Name filter just below Path..0 -
Hi Mohana,
now it works
thanks for your help
final codeGLSetup.GET; SFile1.SETRANGE(Path,GLSetup."Import Path"); SFile1.SETRANGE("Is a file",TRUE); IF SFile1.FINDSET THEN REPEAT SFile.TEXTMODE(TRUE); SFile.WRITEMODE(FALSE); SFile.OPEN(GLSetup."Import Path" + SFile1.Name); REPEAT . . .
\:D/ \:D/0 -
julkifli33 wrote:Hi Mohana,
now it works
thanks for your help
\:D/ \:D/0 -
I am getting errors using either global or local variable for the record type File
the code so far is:
Local Vars:
Name DataType Subtype LengthlvFile Record File lvField Text 100 lvWebImport Record Web Import 1 lvString Text 1000 lvStringLine Text 1000 lvFile1 File CLEAR(lvFile); lvFile.setrange(path,'C:\temp\'); lvfile.setfilter(name, '%1' , 'test*.txt'); if lvFile.FINDSET THEN BEGIN
(next 3 lines give error)//LVfile.TEXTMODE(TRUE); //LVFile.WRITEMODE(FALSE); //LVFile.OPEN(lvFile.path + name);
? How to get text lines in the file into lvString?with lvString do repeat lvField[1] := copystr(lvStringLine,1,20); etc until lvString.next = 0; end;
I am obviously missing something key here, I can find my .txt files, I then need to read each file and for each line in the file insert to a field in a table.Experience is what you get when you hoped to get money0 -
colingbradley wrote:(next 3 lines give error)
//LVfile.TEXTMODE(TRUE); //LVFile.WRITEMODE(FALSE); //LVFile.OPEN(lvFile.path + name);
Use LVFile1 instead of LVFile0 -
You are correct, these work.
LVfile1.TEXTMODE(TRUE);
LVFile1.WRITEMODE(FALSE);
LVFile1.OPEN(lvFile.path + lvfile.name);
next question is how do I read the data within lvFile1 into a table?Experience is what you get when you hoped to get money0 -
colingbradley wrote:next question is how do I read the data within lvFile1 into a table?0
-
Hi Mohana,
How to find Dataport imported file path.
My requirement is to find the path of the file selected by user and create an exception file in the same path
Thanks
ChowdaryPleasure in the job puts perfection in the work0
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