Hi Ladislav

You are right. I did not understand the meaning of { ; Don't forget to add
'screen-size to our functions locals }.
It's cristal clear now thanks to you. I will have a better night !

Patrick

----- Original Message -----
From: "Ladislav Mecir" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 25, 2001 7:23 PM
Subject: [REBOL] Re: what to do with bind ?


Hi Patrick,

I will try to explain it ...

1)  Let's have a look at the: { ; Don't forget to add 'screen-size to our
functions locals} sentence. That means, that Ingo wanted to have the word
'screen-size local in the function. Why?
- He knew, that the word was defined only for the function to work as he
wanted it to.
- Forgetting to define a local word as local may become a source of some
hard to find bugs (interactions of some functions that are supposed to be
independent).

2) That is why Ingo defined the word as local:

cursor2: func [
    {Cursor positioning dialect (iho)}
    [catch]
    commands [block!]
    /local rules string arg screen-size cnt
][
    screen-size: (
          c: open/binary/no-wait [scheme: 'console]
      prin "^(1B)[7n"
      arg: next next to-string copy c
      close c
      arg: parse/all arg ";R"
      forall arg [change arg to-integer first arg]
      arg: to-pair head arg
    )

    string: copy ""
    commands: compose commands ; NEW LINE HERE
    rules: [
        any [
            'clear (append string "^(1B)[J") |
            'at set arg pair! (append string rejoin ["^(1B)[" arg/x ";"
arg/y "H"]) |
            set cnt integer! set arg string! (
                append string head insert/dup copy "" arg cnt
            ) |
            set arg string! (append string arg)
        ]
    ]
    parse commands rules
    string
]

(see the screen-size word above).

3) After the above definition, the situation changes:

>> print cursor2 [clear at 1x10 (screen-size/y / 2) "x"]
** Script Error: screen-size has no value
** Where: cursor2
** Near: screen-size/y / 2

<<Patrick>>

Hi, ladislav

The first time I found 'bind was in some of your code. But I wonder if
'bind is only useful for those who explore the guts of Rebol. I'm looking
for an example that enlighten the use of bind in a simple way. I thank
Andrew Martin for his help, but ML.r is far too complex for me. Comme on dit
chez nous "ce qui se conçoit bien s'énonce clairement".

Searching for the light, I found Ingo Hohmann's TUI Dialect article on
Rebol-Force site. I thought it was it, because he was using 'bind in a way
that was logical to me (to avoid an error). I have experimented his code and
to my surprise and disbelief I have found that the program works fine with
or without 'bind .

So I'm more puzzled than ever. This is the code I extract from Ingo article.
It should give an error because screen-size is not in the same context but
it did not.

What is wrong with it ?



Rebol [ title: "test"
 purpose: "what to do with bind?"]

cursor2: func [
    {Cursor positioning dialect (iho)}
    commands [block!]
    /local rules string arg
][
    ; Don't forget to add 'screen-size to our functions locals
    screen-size: (
          c: open/binary/no-wait [scheme: 'console]
      prin "^(1B)[7n"
      arg: next next to-string copy c
      close c
      arg: parse/all arg ";R"
      forall arg [change arg to-integer first arg]
      arg: to-pair head arg
    )

    string: copy ""
    commands: compose commands ; NEW LINE HERE
    rules: [
        any [
            'clear (append string "^(1B)[J") |
            'at set arg pair! (append string rejoin ["^(1B)[" arg/x ";"
arg/y "H"]) |
            set cnt integer! set arg string! (
                append string head insert/dup copy "" arg cnt
            ) |
            set arg string! (append string arg)
        ]
    ]
    parse commands rules
    string
]

print cursor2 [clear at 1x10 (screen-size/y / 2) "x"]
print cursor2 [at 2x10 "no bind but no error too"]
halt


--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.


 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to