> tail_data: ""
Use:
tail_data: make string! 0
instead.
Think of ":" as being:
Set the word to the left to _POINT_ to the string at the right.
So this:
tail_data: ""
actually means:
Set the word "tail_data" to this particular empty string. It's like
assigning a pointer in C/C++, OK?
The same thing applies here:
> result: []
Use:
result: make block! 0
instead.
Andrew Martin
ICQ: 26227169
http://members.nbci.com/AndrewMartin/
-><-
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, November 11, 2000 10:10 AM
Subject: [REBOL] Func, why does it remeber previous data?
> Hi all,
>
> I am playing around with a function that search through a block containing
> binary values.
> My function searches through the block for the binary #{ACDC} plus #{??}
>
> The problem I encounter is when I run the function multiple times, the
> binary variable "data_to_find" remembers old data from the same function,
> even if I clear it.
>
> Can someone please explain this behaviour and give me some hints of how to
> get around it?
>
> Here's the script:
> -----------------------------------------------------------
> find_stuff: func ["Find stuff in data_block"] [
>
> tail_data: ""
> tail_data: ask "what data do you want to find after ACDC? "
> probe data_to_find: ""
> probe clear data_to_find
> probe data_to_find: #{ACDC}
> probe append data_to_find do rejoin ["#{" tail_data "}"]
>
> result: []
> clear result
> foreach data data_block [
> if find data data_to_find [
> append result data
> ]
> ]
> print rejoin ["Found " length? result " containing " data_to_find]
> ]
> ------------------------------------------------------------
> Here's an example of running the script:
> ------------------------------------------------------------
> >> data_block: [#{ACDC01} #{ACDC02} #{ACDC03} #{ACDC01} #{ACDC02}]
> == [#{ACDC01} #{ACDC02} #{ACDC03} #{ACDC01} #{ACDC02}]
>
> >> find_stuff
> what data do you want to find after ACDC? 01
> ""
> ""
> #{ACDC}
> #{ACDC01}
> Found 2 containing #{ACDC01}
>
> >> find_stuff
> what data do you want to find after ACDC? 01
> ""
> ""
> #{ACDC01} <----- Where does 01 come from?
> #{ACDC0101}
> Found 0 containing #{ACDC0101}
> >> find_stuff
> what data do you want to find after ACDC? 02
> ""
> ""
> #{ACDC0101} <----- Where does 0101 come from?
> #{ACDC010102}
> Found 0 containing #{ACDC010102}
> >>
> -----------------------------------------------------------
> Brgds /Micael
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.