[Newbies] Primitive error handling

Garret Raziel boloomka at gmail.com
Sun Feb 7 12:45:00 UTC 2010


Hello,
I have another "problem". In windows, my microchip is connected on port 7
(COM7) but I dunno which port number it is in Linux. It is connected in
location /dev/ttyUSB0 but I dunno what is its number. I have tried this code
to discover it:

|n|
n := SerialPort new.
1 to: 20 do: [:port | n openPort: port. (n isNil) ifFalse: [Transcript show:
port]. n close]

but it told me that no port after opening is nil (strange, I thought that on
Windows when I tried to open non-existing port, it returned nil). So I have
tried another code, reading string from this port by n readString and
watching when it does primitiveFailed and when doesn't. But I want only this
kind of code (but I dunno how is it named): (n readString isPrimitiveFail)
ifFalse: [Transcript show: ...]. How can I do it? Thanks for response.

Garret Raziel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100207/2d3ba394/attachment.htm


More information about the Beginners mailing list