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 


Help with Writing to Files

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


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Sun Nov 14, 2004 4:18 am    Post subject: Help with Writing to Files Reply with quote

Im trying to log all messages received via a UDP connection to a log file in a VDS application. So far I have been unable to figure it out. Below is a snippet of the code the im using.


Code:
:UDP-SERVER1ONMESSAGE
  %A = @INTERNET(udp-server,message,1)
  list add,list1,@DATETIME(h:nn:ss)@TAB()@TAB()@DATETIME(mmm d yyyy)@TAB()@TAB()%A
  binfile open,4,C:\test\log.txt
  binfile write,4,text,%A
  BINFILE CLOSE,4
goto evloop


Can somebody tell me what im doing wrong?

Thank you for your time and assistance.

Webdaddy
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Sun Nov 14, 2004 10:08 am    Post subject: Problem Solved - Writing to Log File Reply with quote

Nevermind. I figured it out.
To keep thread integrity however here is what I ended up doing.

Code:
:UDP-SERVER1ONMESSAGE
  %A = @INTERNET(udp-server,message,1)
  list add,list1,@DATETIME(h:nn:ss)@TAB()@TAB()@DATETIME(mmm d yyyy)@TAB()@TAB()%A
  BINFILE OPEN,4,C:\SSyslog\log.txt,APPEND
  BINFILE WRITE,4,TEXT,@DATETIME(h:nn:ss)@TAB()@TAB()@DATETIME(mmm d yyyy)@TAB()@TAB()%A
  BINFILE CLOSE,4
goto evloop
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Nov 14, 2004 12:38 pm    Post subject: Reply with quote

Hi Webdaddy, welcome at VDSWORLD... Smile

The way you did it, does work, but it's better to create a logfile with the list command:

Code:
:UDP-SERVER1ONMESSAGE
  %A = @INTERNET(udp-server,message,1)
  list add,list1,@DATETIME(h:nn:ss)@TAB()@TAB()@DATETIME(mmm d yyyy)@TAB()@TAB()%A
 list create,30
list loadfile,30,C:\SSyslog\log.txt
  list add,30,@DATETIME(h:nn:ss)@TAB()@TAB()@DATETIME(mmm d yyyy)@TAB()@TAB()%A
  list savefile,30,C:\SSyslog\log.txt
list close,30
  goto Evloop


Btw. I added the [ vds ] tag to your posts for better readability... Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Nov 14, 2004 3:21 pm    Post subject: Reply with quote

Either way will work, however, and BINFILE may be faster in some cases,
such as with large files.

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Fri Nov 19, 2004 7:05 pm    Post subject: Results of Testing Reply with quote

I tested this both ways and yes both ways work fine. But the performance seems better with Binfile and since I have no way of knowing just how much traffic will be generated I think Im gonna stick with BINFILE.

I stored the other code though to my reuseable snippets archive. Might come in handy for other applications.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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