Vision Posted March 12, 2008 Share Posted March 12, 2008 hi, i trying something with this code, the data what incomine are written in the console, this works wonderful, so how i can write the directly to a txtfile oder excel file .xls ?? thanks in adavance HotKeySet("{ESC}", "_Killit") $NetComm = ObjCreate("NETCommOCX.NETComm");Create NETComm.ocx object ;Set object settings With $NetComm .CommPort = 1 ;Set port number .Settings = "9600,N,8,1" ;Set port settings .InputLen = 0 ;reads entire buffer .InputMode = 0 ;reads in text mode .HandShaking = 3 ;uses both RTS and Xon/Xoff handshaking .PortOpen = "True" ;opens specified COM port EndWith While 1 _GetData() WEnd Func _GetData() If $NetComm.InBufferCount > 0 Then ConsoleWrite($NetComm.InputData) Sleep(250) EndIf EndFunc Func _Killit() Exit EndFunc Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 Dim $filename = "nameonthefile.txt" Dim $write = "This is the text I want to write, this is what you are going to write";;This could be Dim $write = $NetComm.InputData Dim $filehandle = FileOpen($filename, 1) FileWrite($filehandle, $write) FileClose($filehandle) Link to comment Share on other sites More sharing options...
Vision Posted March 12, 2008 Author Share Posted March 12, 2008 thanks for fast response, where i can find a review of the $NetComm variable? or how i can send a defined value? like "1inc" to the rs232 port? thanks and best regards Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 I thought you asked for how to write a value to a file, and I posted how to do it Dim $filename = "nameonthefile.txt" Dim $write = "This is the text I want to write, this is what you are going to write" Dim $filehandle = FileOpen($filename, 1) FileWrite($filehandle, $write) FileClose($filehandle)Dim $filename = "nameonthefile.txt" *The name of the file you want to write toDim $write = "This is the text I want to write, this is what you are going to write"*What you are going to write to the fileDim $filehandle = FileOpen($filename, 1)*Opens the fileFileWrite($filehandle, $write)*Writes to the file from the variable $write that was declearedFileClose($filehandle)*Closes the file (Kind of useless) Link to comment Share on other sites More sharing options...
Vision Posted March 12, 2008 Author Share Posted March 12, 2008 (edited) yes thanks for explaining but thats not the problem^^ i will send "1inc" to the rs232 port via $NetComm the read and write to the txt file works perfect Edited March 12, 2008 by Vision Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 (edited) Yes, but I am sorry I cant help you with that as Im not familiar with NetComm.I hope I helped anyway, and that anybody can answer his question!EDIT: Have you checked this topic? http://www.autoitscript.com/forum/index.ph...showtopic=52025 Edited March 12, 2008 by LinuZ Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 12, 2008 Share Posted March 12, 2008 HotKeySet("{ESC}", "_Killit") $NetComm = ObjCreate("NETCommOCX.NETComm");Create NETComm.ocx object ;Set object settings With $NetComm .CommPort = 1 ;Set port number .Settings = "9600,N,8,1" ;Set port settings .InputLen = 0 ;reads entire buffer .InputMode = 0 ;reads in text mode .HandShaking = 3 ;uses both RTS and Xon/Xoff handshaking .PortOpen = "True" ;opens specified COM port EndWith $file = FileOpen("output.txt", 1) While 1 If $NetComm.InBufferCount > 0 Then FileWrite($file, $NetComm.InputData) EndIf Sleep(250) WEnd Func _Killit() FileClose($file) Exit EndFunc This will take everything from the line and just write it to the file. I don't know the object so I can't tell you how to send things. Also, I removed your get data function by just putting it's code in the loop. It's more efficient this way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now