#135912 - 2005-03-1812:56 AMWriteline isn't actually writing a line... ideas?
Georges_KGeorges_K
Getting the hang of it
Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Hello all,
I'm writing a quick'n'dirty script to gather all printers installed on the clients for a project I'm working on. I wrote this script, and everything seems to be working ok, EXCEPT for actually writing the line with the Writeline command. I checked this script for quite a while, and I can't figure out why Writeline isn't working, maybe someone can see it clearer than me? Thanks for your assistance. Below is the code that I got.
_________________________
Network Specialist Chino Unified School District
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
5 should allow you to write to the file.
Also, don't get in a bad habit of not Dimming your code, you may want to go back at a later date and plug this into a larger script and you might run into issues with scope if other vars have same names.
Georges_KGeorges_K
Getting the hang of it
Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Thanks for the quick responses guys. yes you're right, I do need to DIM my variables.
As for the Open function, this is the first time I use it, usually I use an INI file. I wasn't aware that you can't open a file for both reading AND writing. I assumed you can, because the documentation said that the mode numbers for the Open function are cumulative. but i guess it doesn't work for 4+2 .... oh well.. I'll figure another way then. Thanks again,
_________________________
Network Specialist Chino Unified School District
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Quote: Note: These values are cumulative. So if you want to open a file for write access, and create it if it does not yet exist, you should specify 5. Notice, however, that a file can not be opened for read and write access at the same time.
Code:
Break On
Dim $File, $OpenFile, $WL, $CloseFile
$File='C:\TEMP\TEST.TXT'
$OpenFile=Open(1, $File,5)
$WL=WriteLine(1,'Wow my data was written to the file'+@CRLF)
$CloseFile = Close(1)