Hi Forum,
I couldn't find the 'absolute idiot' section to post this so forgive me for posting what I'm sure is a dumb question (or two) - the general problem is that my background is (68000) assembler and I'm struggling to get my head round OOP / Classes / Destructors / Inheritance etc. Anyway, here goes...
I want to write a fairly simple app that reads data from the Com port and outputs the processed data back to the COM port and occasionally writing info to the screen.
My immediate problem is that I get a Syntax error (:no syntax matching in line 2 col 1) when compiling. I'm 99% sure this is something to do with how I am declaring the Public variables. As far as I understand it, I must declare these variables as Public because they are used in different places in the code.
I'm not even sure if I'm building the app correctly - I'm just looking at examples and trying this and that until I get the correct results.
The following is the 'bare bones' of the code I have written so far which demonstrates the problem.....
************************************** Beginning of code *******************************
'The variable declarations
Public s as string '(s) is the rx'd data store
Public n as integer '(n) is the count of bytes rx'd
Dim zeil(99) as string 'This is a simple data array used later on
Dim I as integer 'A counter used in for-next loops
'This is the start of the main procedure
WaitIp:
'Here we make sure the array zeil is empty - also used as a wait loop
for I=1 to 99
zeil(I)=""
next I
'now we test to see if data has been rx'd at the COM port
if n > 0 goto NextStep 'if n > 0, data has been rx'd so continue processing
end if
goto WaitIp 'otherwise go back and re-run the loop
NextStep:
Editor1.Append(s)
' lots more processing code here
GOTO WaitIp 'End of the main process - go back and wait for new data
'This Sub sets up the COM port at application start up
Private Sub Form_OnOpen()
SerialPort1.Open()
SerialPort1.BaudRate = "Baud2400"
SerialPort1.Flush()
End Sub
'This Sub is the handler for data rx'd at the COM port
Sub SerialPort1_OnEvent()
SerialPort1.ReadLine(s) 'The data rx'd is stored in string variable (s)
SerialPort1.BytesRead(n) 'The byte count is now stored in integer variable (n)
End Sub
'This Sub closes the port and shuts down the app
Private Sub CommandButton1_OnEvent()
Close
Stop
End Sub
********************************** End of code ************************************
If anyone can point me in the right direction, I'd be very grateful (please don't say "give up" as I'd love to complete this !)
Am I correct in putting the main code body at the beginning ? - I assume this is where execution starts.
Should this 'main' code be in a sub such as a Public|Private Sub Main() / End Main ?
As you can see, I'm pretty lost !!
Many thanks for any assistance.
Semper_linux.