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

World: r3wp

[Rebol School] Rebol School

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
Geomol
6-Oct-2011
[3962]
Pass! I'm not enough into your problem to point you into a direction. 
But go on and read some more of the docs, and you should be able 
to help yourself some more:

http://www.rebol.com/docs/core23/rebolcore.html
http://www.rebol.com/docs/dictionary.html
todun
6-Oct-2011
[3963]
@Geomel, thanks. Also, is it allowed for me to use REBOL/Core when 
doing stuff in REBOL/View?
Henrik
6-Oct-2011
[3964]
graphics related stuff is not possible in REBOL/Core.
GrahamC
6-Oct-2011
[3965]
R/View incorportes R/Core
todun
6-Oct-2011
[3966]
@Henrik, @GrahamC, thanks.
todun
8-Oct-2011
[3967x2]
Is there anyway to clear an info view after a button is pressed?
For example, if I press question button(displays the question in 
an info view), and then I press answer button(which displays the 
corresponding answer), when next I press question, I want the answer 
info view to go back to being blank. How can I do this? thanks.
Sunanda
8-Oct-2011
[3969x2]
The code in the next post demonstates most of the mechanics of what 
you are asking for:
question-database: [
    ["Doctor who?"  "Oops -- silence has fallen"]

    ["Is there a doctor in the house?" "Yes -- his name is Gregory"]
]



next-question: func [ ;; function to find and display the next question
   ][
   question-database: next question-database

   if tail? question-database [question-database: head question-database]
   question-field/text: first first question-database
     answer-field/text: ""
     show question-field
     show answer-field
    ]


   ;; code to define and run the panel
unview/all
view/new layout [
  across
  question-field: field ""
  answer-field: field ""
  return
  answer-button: button "show answer" [
               answer-field/text: second first question-database
               show answer-field
               ]
  next-button: button "Next question" [
                 next-question
                  ]
     ]

  ;; open code to start it running
next-question     
do-events
todun
8-Oct-2011
[3971]
@Sunanda, thanks. Let me play with it to see where the info view 
reseting takes place.
Henrik
8-Oct-2011
[3972x2]
try SET-FACE and CLEAR-FACE instead of setting and clearing face/text 
directly.
if you use:

source set-face

you can see what it does
todun
8-Oct-2011
[3974]
@Henrik, thanks. will do.