forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Check to see if a file is open

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Tue Jan 22, 2002 4:14 pm    Post subject: Check to see if a file is open Reply with quote

Is there a way to check to see if a file is open in vds? I use
AutoCAD and I want to be able to tell when a plot/print file has
been completely written.

Thanks

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Henrik
Valued Newbie


Joined: 09 Jul 2000
Posts: 35
Location: Copenhagen, Denmark

PostPosted: Wed Jan 23, 2002 2:35 am    Post subject: Reply with quote

Hi LiquidCode !

I am just guessing here but what about trying

rem *** Wait for a file to be completely written / close
%%FILE = somefile.txt
repeat
until @both(@not(@null(@file(%%FILE))),@not(@zero(@file(%%FILE,Z))))

rem *** Check for file status
%%FILE = somefile.txt
if @both(@not(@null(@file(%%FILE))),@not(@zero(@file(%%FILE,Z))))
rem *** Do something useful
end

Henrik

_________________
Henrik Skov
Email: henrikskov@mail.dk
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Wed Jan 23, 2002 12:46 pm    Post subject: Reply with quote

I'll try that, thanks.
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Wed Jan 23, 2002 1:57 pm    Post subject: Reply with quote

Hi Chris,

I'd love to hear how you make out here I use AutoCad too and this would be helpful.
As you probably know ACAD creates temp files constantly, especially when plotting. I'm not sure if it creates a temp file for writting a plot to file or not though. Because the temp names appear to be random it may be difficult to track but if you could find the temp file name for the plot creation you could compare it to the size of the plot file and when they match you know it's done.

You could also monitor for the plot progress window after it closes it is done processing the file. Since it may take a second or 2 to finish writting a short delay after it closes is probably smart.

Lastly you can try the cheesy code below to monitor the file size and compare it to itself to see if it is still changing.

Good luck!
moke

Code:

:FileCheck
%x = 0
rem start checking the file size
%%file = @file(myplot.plt,Z)
rem give it time to start writing
rem giving more time probably a good idea
wait .5
rem compare size
IF @equal(%%file,@file(myplot.plt,Z))
   %x = 1
end
if @equal(%x,1)
   info Plot file written.
   exit
end
goto filecheck
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Wed Jan 23, 2002 5:08 pm    Post subject: Reply with quote

Hey moke,

Well, what my goal is is to make an auto-cueing plot program. I want
to have a program monitor a directory and when it sees a new plot file
with the specified parameters (i.e. MyPlots*.plt), it will send them to
the plotter. I want to make sure that the plots are finished before send
otherwise the program could crash. I have one now that the user must
select the plot files to send, but I want it to do it automatically.

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Thu Jan 24, 2002 8:12 pm    Post subject: Reply with quote

Chris,
The vdsinout.dll is supposed to have the ability to generate a message when reading and open file. I have not been able to make it work Sad but maybe you'll have better luck. I would prefer this method if it works.

Another idea is to search the plot file for the end of plot command (Usually ;PG;) or the closing PJL statement.

Most popular drivers will generate HPGL2 plot files and use the HP-PJL command set so the final line of any plotfile generated this way will be:

@PJL EOJ

Obviously if you search a file for @PJL EOJ and find it the plot file is complete. Smile

Keep me posted. I love to take a look at what your doing at some point if you don't mind.

Good luck!
moke
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Thu Jan 24, 2002 9:12 pm    Post subject: Reply with quote

I'll have to give the ideas a try. I haven't been able to really
start the program yet. I have been busy grading a big site and
writing a lisp project. I hope to get to it soon. I will let you know
how it's coming. I don't think I'm supposed to give out the source
code to any competitors, so if you don't mind me asking what
kind of work do you do on CAD? I'm a Civil Cad Tech. If you
do anything but that, I think I can give you the source code.

Thanks,

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Jan 24, 2002 10:45 pm    Post subject: Reply with quote

I really have no clue about plot files, but does the prog
write directly to the file as it's being formed? Or does it
just create the file, then add the contents from memory
(or a temp file) when finished?

If the latter, periodically checking for file size over 1k
might work...

Just a thought... Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Fri Jan 25, 2002 3:51 pm    Post subject: Reply with quote

Chris,
I am not an engineer of any type and use AutoCAD only because I like to be able to help some of my clients when they have problems. I respect that you are cautious about sharing code that could have an imapct on your employer and would not take offense if you chose not to.

Mac,
Good question. I'm curious now and will try to check when I have some time.

moke
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group