[REBOL] Re: Advanced port stuff
From: al:bri:xtra at: 7-Jan-2001 9:23
Paul wrote:
> I think the complexity is that these objects are port objects that have
been added to a block. The block is referenced by the word 'waitports.
waitports contains the port objects which are appended to it dynamically as
the script runs. For example if waitports contained three port objects -
then the following:
> >> print waitports
> ?port? ?port? ?port?
>
> ok print now this:
> >> print first waitports
> irc-open-port
>
> now I try moving the index to get the literal of the second port since the
first port responded correctly:
> waitports: next waitports
>
> >> print first waitports
> ?port?
>
> I notice that it shows only one ?port? instead of two and it didnt give me
the literal word referencing that port object. Is this a bug or is there
new information we need to document regarding objects appended to blocks
when they are port datatypes.
I think you may have an unseen space lurking in your script. I tried out
your example using ports on local files like this:
>> p1: open %f1.txt
>> p2: open %f2.txt
>> p3: open %f3.txt
>> waitports: make block! 0
== []
>> append waitports reduce [p1 p2 p3]
== [
make object! [
scheme: 'file
host: none
port-id: none
user: none
pass: none
...
>> print waitports
?port? ?port? ?port?
>> print first waitports
?port?
>> waitports: next waitports
== [
make object! [
scheme: 'file
host: none
port-id: none
user: none
pass: none
...
>> print first waitports
?port?
Note that I couldn't duplicate this:
> ok print now this:
> >> print first waitports
> irc-open-port
I suspect that "waitports" might be: "wait ports" in your script. Note the
space between "wait" and "ports". I think it would be a good idea to call
'waitports something else more descriptive of it's purpose.
> However, I am getting ready to add more code to this function to perform
some logic based on the literals within waitports block. Thats is what Im
having trouble determining since its dynamically assigned during execution.
There are no "literals" inside the waitports block. According to my example,
there are only port! objects inside it. Note that 'p1, 'p2 and 'p3 still
refer to their respective values.
> dcctemp: :dcc-client
> dcctemp: make set-word! :dcctemp
> mold dcctemp :dcc-open-client
What's the intent of the above line? It seems to do nothing.
> append waitports get make word! copy :dcc-client
I'm fairly sure the above line is where your problem lies.
> dcc-chat-flag: off
> dcc-client-port: dcc-connect: none
Perhaps better is something like:
Nicks: make block! 0 ; in your initialisation code.
Nick: to word! message/nick
set Nick dcc-open-client ; Note lack of apostrophe {'}
append Nicks Nick
The above assumes that 'message/nick fits in a subset of valid rebol
words.
I hope that helps!
Andrew Martin
Learning something new each and every day...
ICQ: 26227169 http://members.nbci.com/AndrewMartin/