SerialPortCount issue 
Author Message
 SerialPortCount issue

Hi,

I've got a B&W G3 with a Stealth Serial port and a uConnect (USB ->
Serial) adapter.

I've tried writing a small Real Basic program that shows all the serial
ports that are available, but "System.SerialPortCount" always comes back
with "0".

Here's a snippet of code that I'm running at startup:

---
01  Dim ii as Integer
02  Dim ports as Integer
03  Dim p as SerialPort

04  ports = System.SerialPortCount

05  ' Show Serial ports
06  EditField1.Text = ""
07  If ports <> 0 Then
08    For ii=0 to ports
09      p = System.SerialPort(ii)
10      EditField1.Text = EditField1.Text + p.Name + chr(13)
11    Next
12  Else
13    EditField1.Text = "Ports: " + str(ports) + chr(13)
14  End If
---

Is there something here that I'm doing wrong? At line 07, "ports" is
always "0", so the code jumps to the "Else" clause (line 12) and
displays "Ports: 0" in the edit field.

I downloaded a program called "SerialKiller" that ostensibly was written
in RealBasic, and it shows both the Stealth and the uConnect serial
ports. So, I know it's possible.

Thanks for any clues you can offer! I did search all over your web site,
and many of the other RealBasic web sites, to no avail.

 -- Mark

P.S. I'm using Real Basic 3.2.



Mon, 09 Feb 2004 15:05:23 GMT  
 SerialPortCount issue
Yeah, several people have mentioned that they don't have the same issues. On
my code, I wasn't even getting there because the "if" statement in line 07
was always false.

Thanks for the response. Any other suggestions you can offer would be greatly
appreciated.

  -- Mark

Quote:


> > Hi,

> > I've got a B&W G3 with a Stealth Serial port and a uConnect (USB ->
> > Serial) adapter.

> > I've tried writing a small Real Basic program that shows all the serial
> > ports that are available, but "System.SerialPortCount" always comes back
> > with "0".

> > Here's a snippet of code that I'm running at startup:

> ... snip

> >08    For ii=0 to ports

> I did not have the same error as you with your code: for me it was a
> nilobject exception raised, because of line 08. Try with

> For ii=0 to ports-1

> it works for me...

> Patrick



Tue, 10 Feb 2004 13:21:58 GMT  
 SerialPortCount issue
Just want to add the following insights:

1. The same problem exhibits itself in version 3.5 of RB
2. The problem goes away in version 2.1.2 of RB. (IOW, the program works as
expected in v2.1.2 of RB)

  -- Mark

Quote:

> Hi,

> I've got a B&W G3 with a Stealth Serial port and a uConnect (USB ->
> Serial) adapter.

> I've tried writing a small Real Basic program that shows all the serial
> ports that are available, but "System.SerialPortCount" always comes back
> with "0".

> Here's a snippet of code that I'm running at startup:

> ---
> 01  Dim ii as Integer
> 02  Dim ports as Integer
> 03  Dim p as SerialPort

> 04  ports = System.SerialPortCount

> 05  ' Show Serial ports
> 06  EditField1.Text = ""
> 07  If ports <> 0 Then
> 08    For ii=0 to ports
> 09      p = System.SerialPort(ii)
> 10      EditField1.Text = EditField1.Text + p.Name + chr(13)
> 11    Next
> 12  Else
> 13    EditField1.Text = "Ports: " + str(ports) + chr(13)
> 14  End If
> ---

> Is there something here that I'm doing wrong? At line 07, "ports" is
> always "0", so the code jumps to the "Else" clause (line 12) and
> displays "Ports: 0" in the edit field.

> I downloaded a program called "SerialKiller" that ostensibly was written
> in RealBasic, and it shows both the Stealth and the uConnect serial
> ports. So, I know it's possible.

> Thanks for any clues you can offer! I did search all over your web site,
> and many of the other RealBasic web sites, to no avail.

>  -- Mark

> P.S. I'm using Real Basic 3.2.



Tue, 10 Feb 2004 13:40:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CFP: The AI Pride Issue (IEEE intelligent systems special issue)

2. Smalltalk article in the current InformationWeek issue.

3. Squeak News Dec-Jan, Feb and future issues, and season's greetings

4. SqueakNews e-zine August issue is out

5. VisualWorks Call For Issues [GUI]

6. Some issues

7. Compatibility issues

8. Issues porting app from D4 to D5

9. PL2 issues??

10. Communication Issues

11. Lagoon issue

12. Drop Down Combo Box Issue?

 

 
Powered by phpBB® Forum Software