Help me convert a Visual Basic 6 code to PERL script

Status
Not open for further replies.

Kuzito

Newbie level 6
Joined
Nov 5, 2006
Messages
14
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,459
Hello,
I have this Visual Basec 6 code:
--------
Private Sub cmdOff_Click()
With MSComm1
'make sure the serial port is open
If .PortOpen = False Then .PortOpen = True
'send the data
.Output = Chr$(255)
.Output = Chr$(1)
.Output = Chr$(0)
End With 'MSComm1
End Sub

Private Sub cmdOn_Click()
With MSComm1
'make sure the serial port is open
If .PortOpen = False Then .PortOpen = True
'send the data
.Output = Chr$(255)
.Output = Chr$(1)
.Output = Chr$(1)
End With 'MSComm1
End Sub
-------------

Can someone help me with converting this code into a PERL script code?
Thank you in advance
 

Re: PERL script

First question I have is what is the ultimate goal? Visual Basic is a Windows only language, and Perl is most at home on a Unix/Linux/FreeBSD system. Are you trying to port the functionality of a Windows program to a different operating system? Are you definitely set on using Perl?

If you are trying to port the program, and you are willing to spend money for a solution, you might try REALbasic (www.realbasic.com) which has options allowing you to develop for Windows, Mac OS, and Linux, and is a very similar language to VB. I've done quite a bit of serial port programming in REALbasic.

If it is Perl you want then what OS are you developing for? Does the program need a GUI (since your VB program had one)? There are several GUI options for Perl. One of the most common is TK Widgets (Perl/TK).

Accessing the serial port is probably going to depend on the OS as well. I think you could use the Perl open() function, which works like the C function fopen() and can be used to access the serial port on *NIX systems.

Hope this helps to start off with.
 

Re: PERL script

Hi, Thanks to Kuzito who actually posted this question on my behalf so wont know the answers to the questions posed. The VB6 code he listed controls a a simple relay connected via USB to a Windows PC running Xitami webserver. The aim is to use this relay to switch a circuit on/off from a webpage. I have found PERL scripts to control X10 controlled mains devices and used them succesfully but was hoping to find a PERL script to use the relay to switch low voltage such as a basic battery / bulb circuit initially. I'm new to this but having had success with PERL and the mains operated X10 devices I'd like to stick with it for the low voltage switch too. Many Thanks for any help you can provide.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…