LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2005, 08:01 AM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
converting vb6 code to python


I have the following server code wrote in vb6:


Option Explicit
Dim sServerMsg As String

Private Sub Form_Load()

'Address must be input as a string
Dim Address As String

'Set the address equal to the web address of the pickle line camera
Address = "http://pl7cam2/operator/image_test.shtml?camNo=1&squarepixel=0&resolution=4CIF&compression=35&color=yes&rotation=0&overlayim age=0&overlaypos=0x0&date=1&clock=1&text=1&textstring=%237%20Pickle%20Exit%20Camera&textcolor=white& textbackgroundcolor=black&textpos=top&duration=NaN&fps=0kkkkkkkkkkkkkkk"

'tells the browser window to display whatever is on the web page of the address
WebBrowser1.Navigate Address

'The port number is arbitrary.
' it's best to use a fairly high number
' because the low numbers are used for
' standard services: 21 for FTP, 23 for telnet,
' 80 for HTTP etc...
Winsock1(0).LocalPort = 10119

'start listening for a connection

Winsock1(0).Listen

'Define the message and show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub



Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)

'the winsock control has to be in a closed state
' before it can do anything else. (like accept a connection)
Winsock1(Index).Close

'Let the winsock close
DoEvents

'accept the connection request
Winsock1(Index).Accept requestID

'Define the message and display it in the list box
sServerMsg = "Serving client!"
List1.AddItem (sServerMsg)
End Sub


Private Sub Winsock1_Close(Index As Integer)

'When the other end has closed the connection,
' close server end too
Winsock1(Index).Close

'to continue listening for another connection
Winsock1(Index).Listen

'show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)

Dim strTemp As String
'Dim strTemp2 As String
Dim a As Integer
'This event fires when the process on the other end of the connection(i.e the client)
'sends data

'retreive data from socket
Winsock1(Index).GetData strTemp
'Winsock1(Index).GetData strTemp2

'The following code separates each part of the string based on the comma
'that is present in the incoming string and parses it out into its
'respective textbox

a = InStr(strTemp, ",")
txtcoilid.Text = Left(strTemp, a - 1)

'after the first parse you must refine the string as everthing after the comma and
'repeat the process throughout the entire string
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtwidth.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtlinespeed.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtexitcoillength.Text = Left(strTemp, a - 1)


End Sub

It has been suggested to me that python is the best anguage to write this program in being that it needs to be on a linux machine. Can anyone offer suggestions or information on translating this code to python or steps to rewrite in python. I have never used linux or python before and am open to any suggestions.
 
Old 06-02-2005, 01:17 PM   #2
meonkeys
Member
 
Registered: Apr 2004
Location: Minneapolis
Distribution: Ubuntu
Posts: 45

Rep: Reputation: 15
A good place to start would be the Python tutorial.

What does this VB code do? If you want someone to write the code for you, you probably have to pay them. I'd suggest Google Answers if this is the route you want to take.
 
Old 06-02-2005, 01:27 PM   #3
azucaro
Member
 
Registered: Jan 2005
Location: Washington, D.C.
Distribution: Arch (Custom), CentOS
Posts: 239

Rep: Reputation: 30
First and foremost, welcome to Linux and Python! Python is a great language, and very easy to learn if you've programmed before (in my opinion).

Since you are open to suggestions, I have a few:

-I don't know of any documents on translating code from VB to Python, so I apologize for not being able to help you there. Fortunately VB is pretty easy to read - I think that fact will help you greatly.

-I'd recommend http://www.diveintopython.org for learning the basic ins and outs (it is a free book in many formats). If you want to jump into more deep stuff, I would just browse between the different reference manuals found on http://www.python.org/doc. In particular, if you go to that site and look at the python library reference (http://docs.python.org/lib/lib.html). I think chapter 7, section 2 is what you are looking to imitate. That is the chapter on how to do socket stuff.

-I'd also recommend the eric3 IDE for python. It is pretty good. It can be found at www.die-offenbachs.de/detlev/eric3.html.

I hope I helped a little bit - good luck!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Windows DLL code to Linux shared library DavidW567 Programming 7 07-27-2010 08:15 AM
python: converting a 3 character octal string into and ASCII char llama_meme Programming 1 07-06-2010 02:00 PM
easy python code JoeUser11 Programming 1 01-21-2005 01:40 AM
How to add new apps to Gnome main menu ? / VB6 code compilation to Linux . linuxlover1 Linux - General 3 11-16-2003 05:35 PM
Converting bash command to C code Linh Programming 3 06-13-2003 10:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration