r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Rebol School] Rebol School

todun
6-Oct-2011
[3912]
What does a misplaced item error mean? I get it when I try to read 
a file like so:

lines: read/lines %file.txt
Geomol
6-Oct-2011
[3913]
Maybe there are some strange data in the file?
Pekr
6-Oct-2011
[3914]
todun - a little bit more dynamic version of counter:


counter: func ['var add-value][if not value? var [set var 0] set 
var (get var) + add-value]


counter x 10   ; --- x does not have to exist, and if is inicialised 
and set to 0
todun
6-Oct-2011
[3915x3]
@Pekr, thanks. Will see if that can fit into my implementation.
@Geomol, no. This worked before.
Can I post code here or something so you can see what I'm doing right 
or wrong?
Geomol
6-Oct-2011
[3918]
A mistake is sometimes, that part of REBOL was changed, as everything 
can be redefined. If that's the case, you can try restart REBOL and 
see, if the error is still there.


And yes, you can post code, but most don't like it, if it's too long.
todun
6-Oct-2011
[3919]
@Geomol, how many lines is too long?
Geomol
6-Oct-2011
[3920]
:D
Post along!
todun
6-Oct-2011
[3921x2]
@Geomol, restarting rebol didn't  me.
button-press?: layout [
    lines: read/lines %question-list.txt
    current-position: 1

;   len: length? lines                                           
                                                            

    show-one: btn "Show answer" [
        one-position: ++ current-position
        line: pick lines one-position
        result/text: line
	show result
    ]

    show-soon: btn "Soon" [

        soon-position: does [current-position: current-position + 5]
        line: pick lines soon-position
        result-soon/text: line
        show result-soon
    ]
    result: info " "
    result-soon: info " "
]
Geomol
6-Oct-2011
[3923x2]
Uh, I think, you make the mistake, that the interiour of the LAYOUT 
block is actually a dialect. You put all kind of code in it.
The dialect is called VID in this case. Read:
http://www.rebol.com/docs/view-guide.html
Pekr
6-Oct-2011
[3925]
It would be probably better if you would describe what you want to 
do, then someone might write the code right from the scratch :-)
Geomol
6-Oct-2011
[3926x3]
We all went through those times, where we needed to realize, what 
dialects are, so don't give up.
A quick guess would be, that the code will work, if you put DO [ 
... ] around the code in the beginning of the block after LAYOUT.
DO in the VID dialect is described here:
http://www.rebol.com/docs/view-guide.html#section-44
todun
6-Oct-2011
[3929x2]
@Geomol, @Pekr, thanks. I am trying to make flashcard display. However 
I want to do it myself so that I see all the places where I hiccuped.
what do I need to do to make it in the VID dialect?
Geomol
6-Oct-2011
[3931]
Try change your block so it starts:

button-press?: layout [
    do [
        lines: read/lines %question-list.txt
        current-position: 1
;       len: length? lines
    ]
...
todun
6-Oct-2011
[3932x2]
@Geomol, when I call the file in the CLI, I use do
DO
Geomol
6-Oct-2011
[3934]
Sure, but that's another DO. :)
Think dialects. I know, it's hard at first.
todun
6-Oct-2011
[3935]
@Geomol, what about dialects ?
Geomol
6-Oct-2011
[3936]
What does the english word "book" mean?


Is it "a book" you can read in, or is it "book a ticket". You see, 
the same word can mean more than one thing. Same in REBOL.
todun
6-Oct-2011
[3937x3]
also you say I put "other stuff" and such. I'm guessing this means 
I'm mixing code in a non-kosher way. From a paradigm-like sort of 
way, how to I separate out my code in REBOL way or the correct way?
@Geomol, ok. In this context, what does dialect mean?
in the context of my problem, my getting this error?
Geomol
6-Oct-2011
[3940x2]
In your example, you use the LAYOUT dialect, and you have to follow 
the rules of that dialect.


A dialect is a sequence of datatypes, that hold a certain meaning, 
because they're used in a certain context.
But try put the DO [..] block in, as I suggested, and tell us, if 
it works then.
todun
6-Oct-2011
[3942x2]
@Geomol, when I run the script with the DO include, I get the following:
>> do %circular_series.r
** Script Error: btn has no value
** Where: forever
** Near: show-one: btn "Show answer" [
    one-position: ++ current-position 
    line: pick lines one-position 
    result/text:...
Geomol
6-Oct-2011
[3944]
Eh, did you put the new DO block around all the content inside your 
LAYOUT block? I just suggested, you should put it around the first 
3 lines.
todun
6-Oct-2011
[3945]
@Geomol, that dialect description is helpful. What context can I 
use a dialect, the VID in this case, and how do I know what data-types 
to use and what external things to the dialect to use(or not to use)?
Geomol
6-Oct-2011
[3946]
To know, how to use the LAYOUT dialect, read the doc:
http://www.rebol.com/docs/view-guide.html

That's what we do.
todun
6-Oct-2011
[3947x2]
@Geomol, oh ok. let me change that now.
@Geomol, I've looked at that doc. It doesn't specifically tell you 
anywhere what to do with the dialect when you want to introduce foriegn 
coding to the dialect.
Geomol
6-Oct-2011
[3949]
Yes, it does. At:
http://www.rebol.com/docs/view-guide.html#section-44
todun
6-Oct-2011
[3950x5]
I stand corrected. Maybe that didn't make sense to me at the time, 
or I skipped that part of the doc.
@Geomol, so why don't I put the DO[...] around code inside the btn 
blocks that are not like VID commands?
I mean to ask, why does it work?
my ultimate goal is to deal with circular lists. Using this doc, 
I can make one:http://www.rebol.net/cookbook/recipes/0017.html
but I want to be able to always go round around the list, go round 
around the file and also write to file the current location I am 
at.
Geomol
6-Oct-2011
[3955]
Because those blocks are action facets described here:
http://www.rebol.com/docs/view-guide.html#section-17


When you interact with a style, in this case a button, those blocks 
are evaluated as if they were normal REBOL code, so the rules of 
the layout dialect doesn't rule there.
todun
6-Oct-2011
[3956x3]
@Geomol, thanks for clearing that up
Doing a file access and then storing the state of your access, writing 
that to file, seems quite difficult to formulate in REBOL, for me 
anyways.
What I mean is that, if I read the file and end my read at a particular 
location before closing the GUI, does REBOL allow you to presist 
your state across executions of the program?
Geomol
6-Oct-2011
[3959]
Things like INDEX? will tell you, where you are in a series. And 
you can easily save rebol code/values to disc using the SAVE function, 
and load them again with the LOAD function.
todun
6-Oct-2011
[3960x2]
@Geomol, INDEX? will tell me its position, but the circular series 
link I sent you talks about how to always go around and around the 
series. I want to do the same with the lines of a file, but I'm not 
sure how to do it without using REPEAT
I don't want to use REPEAT because I only want to do it while I press 
the button