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 


Open a file while it is already open.

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Wed Feb 22, 2017 12:41 am    Post subject: Open a file while it is already open. Reply with quote

I am trying to create a script that opens a file as read only that is created by another program that is writing that file from a USB stream. I know that the file is not locked because I can open it with notepad while it is streaming.
I have had no luck with "List loadfile" or "@new(File,filename,READ)". Anyone have any ideas or tricks?

_________________
Hooligan

Why be normal?
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1562

PostPosted: Wed Feb 22, 2017 1:56 am    Post subject: Reply with quote

Sorry I don't have code for you in VDS but maybe some clues to help you progress through this.

You need to use the OpenFile windows api:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).aspx

and pass the OF_READ parameter, so it opens it in readonly mode. I'm guessing that is what Windows Notepad is doing to allow you to open/read the file.
Back to top
View user's profile Send private message
nickos
Valued Newbie


Joined: 17 Mar 2007
Posts: 26

PostPosted: Wed Feb 22, 2017 8:57 am    Post subject: Re: Open a file while it is already open. Reply with quote

Hooligan wrote:
I am trying to create a script that opens a file as read only that is created by another program that is writing that file from a USB stream. I know that the file is not locked because I can open it with notepad while it is streaming.
I have had no luck with "List loadfile" or "@new(File,filename,READ)". Anyone have any ideas or tricks?


Maybe it just kinda busy file, have you tried to put in a loop?

Code:

list clear,(list)
while @zero(@count(list))
list loadfile,(list),etc.txt
wait 0.1
wend
Back to top
View user's profile Send private message Send e-mail
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Wed Feb 22, 2017 4:22 pm    Post subject: Reply with quote

I have tried looping it... It updates a 80byte burst every second. Not very busy...
I'll try PGWare's suggestion. I assumed that was the call @new used....

_________________
Hooligan

Why be normal?
Back to top
View user's profile Send private message
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