File searches in Navision

lgoodin
Member Posts: 6
Is there a way to do a file search with a standard Navision data type?
I looked at the functions and methods in the Navision 'File' data type and couldn't see a way to do this.
What I need to accomplish is this:
When the user runs a dataport and types in the filename to import/export to, instead of typing in c:\temp\data.txt, they would type in c:\temp\*.txt.
At this point the dataport needs to do a search in the c:\temp directory and find the first file with a .txt extension and continue processing using that file.
Is there an easy way to do this?
I looked at the functions and methods in the Navision 'File' data type and couldn't see a way to do this.
What I need to accomplish is this:
When the user runs a dataport and types in the filename to import/export to, instead of typing in c:\temp\data.txt, they would type in c:\temp\*.txt.
At this point the dataport needs to do a search in the c:\temp directory and find the first file with a .txt extension and continue processing using that file.
Is there an easy way to do this?
0
Comments
-
You should use the virtual table 'File' en set ranges until you are in the right directory. Here is an example:
recFile is a variable of record 'File' CLEAR(recFile); recFile.RESET; recFile.SETRANGE(Path, ltxtDirectory + '\'); recFile.SETRANGE("Is a file", TRUE); IF (recFile.FIND('-') = TRUE) THEN BEGIN REPEAT ... UNTIL(recFile.NEXT = 0);
0 -
You could also look at Codeunit 412 Common Dialog ManagementAnswer the question and wait for the answer.0
-
Waldo wrote:You should use the virtual table 'File' en set ranges until you are in the right directory. Here is an example:
[code]
Hi Waldo,
Is there a simple way to search for a file through subdirectory's
I now use a shell command to run a batchfile with:
dir g:\secr\word\*cToSearch*.doc/s/b >c:\dirlist.txt
(a dos box is showing, not so nice)
and import the results (dirlist.txt) in a temporay table. with a dataport.
Eric0 -
When you use the code I showed you, you see that the table "File" contains a field "Is a file". When this is false, I suppose it is a directory.
Now, when there are an unlimited amount of directories, you should have a recursive function, and I don't really know C/SIDE can do such things (never tried).
I hope this answer is sufficient...0 -
Waldo wrote:You should use the virtual table 'File' en set ranges until you are in the right directory. Here is an example:
recFile is a variable of record 'File' CLEAR(recFile); recFile.RESET; recFile.SETRANGE(Path, ltxtDirectory + '\'); recFile.SETRANGE("Is a file", TRUE); IF (recFile.FIND('-') = TRUE) THEN BEGIN REPEAT ... UNTIL(recFile.NEXT = 0);
But as a sample: i have different files inside a directory, like *.txt, *.rtf, etc. If i want to filter out only *.txt, how can i do this?
recFile.SETRANGE(Name, '*.txt') shows no result.
If i use it w/o 'SETRANGE(Name....)', i get ALL files.
Any idea for this?
.0 -
The refFile.SETFILTER (Name, varName); work but is case sensitive. For example,
recFile.SETFILTER(Name, 'abc*');
cannot find the file with file name ABCD.txt but can get file with file name abcd.txt.
How to make the SETFILTER case-insensitive ?
Thanks,
Hawwa0 -
0
-
The @ is not able to make the SETFILTER case-insensitive. Is there any setting that I missed out.
recFile.SETRANGE(Path, 'C\PO\');
recFile.SETRANGE("Is a file", TRUE);
recFile.SETFILTER(Name, '@po*');
Thanks.0 -
I should realy work.
What you can try is to make a new form on the file table and set your filter.
Then you can try visualy if the filter is correct.
The file table is somewhat odd; it is only filled after setting a filter.
Maybe you should make code like:
file.setrange("is a file" true);
if find.find('-') then repeat
fileexists := strpos('PO', UPPERCASE(File.name)) <> 0;
until file.next = 0;
Suc6.
Marq0 -
Hi Mark,
I have tried the File table with a List Form. No matter what combination of filter I used, it is still case-sensitiv for the Name field.0 -
try to put a @ infront of your filter. It makes it case insensitive.0
-
Tried already but not work.
recFile.SETRANGE(Path, 'C\PO\');
recFile.SETRANGE("Is a file", TRUE);
recFile.SETFILTER(Name, '@po*');0 -
This works for me:
recFile.SETRANGE(Path, 'c:\delme'); recFile.SETRANGE("Is a file", TRUE); recFile.SETFILTER(Name, '@se*'); IF recFile.FIND('-') THEN REPEAT MESSAGE(recFile.Name); UNTIL recFile.NEXT = 0;
The messages I got are "setup.ini", "Setup.exe", "SETUP.LST".No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Luc Van Dyck,
That doesn't work for me. What version of Navision are you using ? I am using Navision Version 4.0 running on SQL Server 2000.0 -
I used MBS-Navision W1 3.70, local Navision database.
Tested is now on MBS-Navision W1 4.0, local Navision database: works also.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Hi
I just wanted to have a look at this table but the table is empty. :-s
I created a new Tabular-Type Form using the 'File'-Table and saved the form without any filters.
Working with Navision 3.7
:-k0 -
wakestar wrote:Hi
I just wanted to have a look at this table but the table is empty. :-s
I created a new Tabular-Type Form using the 'File'-Table and saved the form without any filters.
Working with Navision 3.7
:-k
oops, Mark wrote it already. :oops: After setting a constant filter on 'Path' the form shows the records.
thanks0 -
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