Characters to Com Port

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
edgellmh
Newbie
Posts: 1
Joined: Thu Mar 24, 2005 6:26 pm

Characters to Com Port

Post by edgellmh » Thu Mar 24, 2005 6:28 pm

How does one send characters to a com port using the Macro Scheduler scripting language?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 24, 2005 6:41 pm

Use VBScript's FileSystemObject, specify the port name and just treat it like a text file. Simple example:

VBSTART
Sub SendData(device,data)
Set fs=CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(device,True)
a.WriteLine(data)
a.Close
End Sub
VBEND
VBRun>SendData,COM5:,Hello World

Clearly if you are sending a steady stream of data you might be better off with a loop within the VBScript code, or split the code up into a connect function, a close function and a send function.

Hope this helps.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts