Hi,
I have a problem in my project,
I developed a codeunit that accesses a text file located on a directory in my desktop and do more treatments, and for that I specify the path in the code C / AL, if not I run it automatically NAS, Everything works well,
date the account is good, now I'll specify my problem:
instead of working on a single text file, I want the treatment will be applied every time I create a new text file in this directory, In Another word, a small test at the codeunit that checks if a newtext file in this directory to execute the codeunit on it ..
THANKS ..
0
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
"Create new files in your directory as filename + date", can you give me an example to understand better now "filename + date"?
you can read the same file name through CAL code as i mentioned in previous post.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
InFile.WRITEMODE: = FALSE;
InFile.TEXTMODE: = TRUE;
Filename: = 'C: \ Users \ Administrator \ Desktop \ project + DELCHR (FORMAT (TODAY ),'=','/') + '. txt ';
InFile.OPEN (Filename);
I feel you can help me..
thanks..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
but this idea that it works if I add one file per day, but if I did create several files in the same day, how can I do?
thanks for your help..;)
You can Use NAVISION TIMER automation to import data in regular interval of time.
You have a lot of information here
viewtopic.php?f=23&t=40346&start=0&hilit=timer+automation
viewtopic.php?f=23&t=36032&hilit=timer+automation
Bye
Use this TIMER automation with a FILE record.
You can read each 5 minutes (for example) if new files are stored in your directory.
Example codeunit
Variables
Name DataType Subtype
Timer Automation 'Navision Timer 1.0'.Timer
TFile Record File
Change SINGLEISTANCE property to TRUE and call it from NAS (Codeunit 1 function 99).
Bye
You can rename your files name, "IMP-Oldname.txt".
Inside repeat loop, you can put a
IF copystr(TFile.Name,1,3)<>'IMP' then
BEGIN
// import data
NewFile:='IMP-'+Tfile.Name;
File.Rename(Tfile.Path+Tfile.Name,Tfile.Path+NewFile);
END;
Bye
Timer:: Timer (Milliseconds: Integer) [/ b]
you can m'expliquée if you like it more precisely?
thanks..
This Line is TIMER automation's event.
Go to Timer variable PROPERTIES and change WITH EVENTS properti to YES.
This line will appear.
Bye
and i have Another question please, My directory named PROJECT, He Is in my desktop, so I do a little test to see how it works, but it does not work: (:
Tfile.SETRANGE (Path, 'C: \ Users \ Administrator \ Desktop \ DRAFT \ B_C');
Tfile.SETRANGE ("Is a file", TRUE);
('-') THEN BEGIN IF Tfile.FIND
test: = COPYSTR (Tfile.Name, 1.3);
MESSAGE ('the name of file is:% 1', Tfile.Name) END;
it makes me a message as result: the name of file is:
it does not give me the name of my file ..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I created a new codeunti to a test
the new CODEUNIT named XXXXX,
b]OnRun()[/b]
IF ISCLEAR(Timer) THEN BEGIN
CREATE(Timer);
Timer.Interval := 300000;
Timer.Enabled := TRUE;
END;
Timer::Timer(Milliseconds : Integer)
TFile.reset;
TFile.setrange(Path,'C:\Users\Administrateur\Desktop\PROJET');
TFile.setrange("Is a file",TRUE);
if Tfile.find('-') then
repeat
CODEUNIT.RUN(CODEUNIT::PROJET);
until TFile.next=0;
and i call it from NAS (Codeunit 1 function 99) : CODEUNIT.RUN(CODEUNIT::XXXXX);
](*,)
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
The Path is: C: \ Users \ Administrator \ Desktop \ PROJET
](*,)
On Run[\b]
InFile.WRITMODE:=FALSE;
InFile.TEXTMODE:=TRUE;
InFile.Open('C:\Users\Administrateur\Desktop\PROJET\B_C);
..............
treatements
..............
is that I remove the instruction of opening the file or not?
if so, what level of code I can put this opening statement??
this is the last task of my project..
1 - Change your folder to a smaller path, maybe 'C:\Project'.
2 - What of the 2 codeunit you use has SINGLEINSTANCE property set to TRUE ?. Only the first one must have it.
3 - delete IF ISCLEAR.... condition. USe only CLEAR.
4 - Before try it with NAS, run it from object desiggner using debugger and find where the mistake is.
Bye
Timer:: Timer (Milliseconds: Integer) In The codeunit XXXXX .. if not there, what level should I change this property??
It's Ok here
Bye
P.D.: Use Debugger to identify where is the problem
Timer:: TimerError (errorString)
OnRun ()
-> CLEAR (timer);
CREATE (Timer);
Timer.Interval: = 60000;
Timer.Enabled: = TRUE;
that is to say that the error in the timer !!!!!
I tried this codeunit and it works. Each minute, i've message for each file in C:\ folder
Stupid question. When you change something in your singleinstance codeunit, do you restart Navision ??? If you don't didd it, your modifications not be able until you restart Navision.
Bye
Bye
but if i want move the text file after displaying his name, for example I want her to move to a another directory that has as
path: "C: \ resolved " ,
I tried with with these instructions, but it no longer works, it gives me a message blocking ''the table is read-only TFile''..
in the repeat loop,
REPEAT
MESSAGE ('THE NAME OF FILE:% 1 ', Tfile.Name);
Tfile.Path: = 'C: \ RESOLVED';
Tfile.MODIFY;
UNTIL Tfile.NEXT = 0;
it gives me a message blocking ''the table is read-only TFile''.. So how can I do??
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
from the directory: C \ project to another directory: C: \ RESOLVED
here is the party of codeunit,
REPEAT
MESSAGE ('THE NAME OF FILE:% 1 ', Tfile.Name);
UNTIL Tfile.NEXT = 0;
Try this
Bye