How to Use Serial in Xojo

663 views Asked by At

I am working with Xojo for the first time and have a little problem with the Serial Class The compiler does not know my serial object, in spite of adding it before.

https://i.stack.imgur.com/SoFQ2.png

This is a Screenshot of my Xojo project window. The Serial Object was added from the Library (serial1) why does the compiler mean, that serial1 does not exist. What does Serial.Baud9600= 8 mean? How can i solve this problem?

Thank You Macman2010

1

There are 1 answers

0
ianmjones On

It looks like you've added your new Serial control to the project (effectively as a new class) rather than as a new control on your window.

Do you want to create a Serial subclass, or just use a new Serial control from your Window?

To keep your Serial1 sub-class (might be an idea to rename it though) just drag it from the Navigator where you see it on the left onto "Window1". This will add something like "Serial11" as a control on your Window1 which you can use by changing your existing code in the Window1.Open event to:

Serial11.Baud = Serial.Baud9600

Otherwise, if you don't need to make a subclass of Serial and just want to use its methods and events from your Window1, then delete "serial1" from the left navigator, select your "Window1" again so that you see the Window1 layout editor and drag a Serial control from the right-hand library into the Window's layout. This will drop a "Serial1" into the shelf at the bottom of the Window's layout and the new control will be available to use from code in Window1.

Oh, and don't worry so much about the Serial.Baud9600 = 8 help text, it's just telling you that the Serial's Baud9600 constant has a value of "8" behind the scenes, this is not something you really need to deal with as it's just a way for the Serial class to switch to one of the well known baud rate constants.

Hope that helps.