Anchor? - A newbie question
[1/7] from: smeagol::chemi::muni::cz at: 15-Oct-2002 18:15
Hi all Rebolers,
one newbie question:
Is there a keyword or flag that allows direct jump
into a specific part of Rebol source code? Actually
I mean something like anchor in HTML. I probably
missed some basic thing in all the beginner's stuff.
Anyway, thanks in advance for any reply and your kind help.
Trying to keep REBOLUTION spreading!
Regards Smeagol
[2/7] from: al:bri:xtra at: 16-Oct-2002 16:15
Smeagol asked:
> Is there a keyword or flag that allows direct jump into a specific part of
Rebol source code? Actually I mean something like anchor in HTML. I probably
missed some basic thing in all the beginner's stuff.
Do you mean something like BASIC's GOTO statement along with a label? For
example (in BASIC):
10 A = A + 1
20 GOTO 10
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[3/7] from: smeagol:chemi:muni:cz at: 16-Oct-2002 10:46
Hi all Rebolers,
what I meant was following: I am actually trying
to transform my web to reb pages and I have there
several choice buttons.
main: layout [
backdrop 128.128.128
across
choice "TOPIC 1" "---------" "Topic 1 A" "Topic 1 B"
"Topic 1 C" "---------" "Back"
[do %t1.r]
choice "TOPIC 2" "---------" "Topic 2 A" "Topic 2 B"
"Topic 2 C" "---------" "Back"
[do %t2.r]
choice "TOPIC 3" "---------" "Topic 3 A" "Topic 3 B"
"Topic 3 C" "Topic 3 D" "Back"
[do %t3.r]
choice "TOPIC 4" "---------" "Topic 4 A" "Topic 4 B"
"Topic 4 C" "---------" "Back"
[do %t4.r]
choice "TOPIC 5" "---------" "Topic 5 A" "Topic 5 B"
"Topic 5 C" "---------" "Back"
[do %t5.r]
choice "TOPIC 6" "---------" "Topic 6 A" "Topic 6 B"
"Topic 6 C" "---------" "Back"
[do %t6.r]
return
.
.
.
.
I do not want to call for every subtopic a separate file
but rather to have all "A" subtopic in one file and jump to
a specific part only if this is possible.
Or is there any better and more straightforward solution?
Regards Smeagol
[4/7] from: carl:cybercraft at: 16-Oct-2002 22:51
On 16-Oct-02, Jan Kmunicek wrote:
> Hi all Rebolers,
> what I meant was following: I am actually trying
<<quoted lines omitted: 31>>
> Or is there any better and more straightforward solution?
> Regards Smeagol
Hi Jan (Smeagol?:),
You could use *do*'s args refinement to send your scripts the choice
value. ie...
view layout [
choice "A" "B" [do/args %test.r face/text]
]
Then in your scripts grab the arguments supplied to them by looking at
system/scripts/args. ie, if the following's...
rebol []
switch system/script/args [
"A" [print "You chose A."]
"B" [print "That was a B."]
]
the %test.r script that selecting a choice in the above layout runs,
it gives this kind of printout...
That was a B.
You chose A.
You chose A.
That was a B.
You chose A.
Hope that helps.
--
Carl Read
[5/7] from: greggirwin:mindspring at: 16-Oct-2002 10:33
Hi Jan,
<< Is there a keyword or flag that allows direct jump
into a specific part of Rebol source code? Actually
I mean something like anchor in HTML. I probably
missed some basic thing in all the beginner's stuff. >>
You can use DO on a block, so you can set up blocks of code and then DO them
on demand. Also, since function evaluation can be deferred, you can pass
around function names and evaluate them on demand as well.
--Gregg
[6/7] from: jason:cunliffe:verizon at: 16-Oct-2002 13:44
Jan Kmunicek wrote:
> Is there a keyword or flag that allows direct jump
> into a specific part of Rebol source code? Actually
> I mean something like anchor in HTML. I probably
> missed some basic thing in all the beginner's stuff.
Hi Jan
Not sure quite what you are asking, so I apologize if my notes are already too
obvious for your question.
The 'switch' function can be useful to jumping to a certain piece of code based
on conditions. Perhaps that's what you are looking for.
If you mean like Basic's GOTO statements, then Rebol is not really meant to be
approached like that. But it is very flexible. Rebol encourages you wrap
everything up in well-named functions or objects. Objects can include functions
and all sorts of logic detection and routing already available within them. You
have to decide how much you want to create large sophisticated tools or lots of
small modular ones. LEGO-style
But blocks are the main tool for everything. So you can do something very simple
like this:
>> someblock: [print "hello from someblock"]
== [print "hello from someblock"]
>> do someblock
hello from someblock
>> someinstruction: does someblock
>> someinstruction
hello from someblock
'does is useful for defining simple deferred action. For example in REBOL/View
when you want to adding action to buttons, you can define Rebol words using
'does.
>> ? does
USAGE:
DOES body
DESCRIPTION:
A shortcut to define a function that has no arguments or locals.
DOES is a function value.
ARGUMENTS:
body -- The body block of the function (Type: block)
(SPECIAL ATTRIBUTES)
catch
Rebol blocks can be trivial like my example above or scale to large applications
or big databases. In general, you probably want to combine create and combine
your own functions and objects.
>> saysomething: func[][print "hello from someblock"]
>> saysomething
hello from someblock
The difference is that, unlike 'does, you can add function arguments..
>> saysomething: func[something[string!]] [print something]
>> saysomething "say what you want"
say what you want
or define a function which uses do inside to evaluate a block as input:
>> do-something: func[inblock[block!]] [do inblock]
>> do-something someblock ; it's defined above
== hello from someblock
and of course directly too
>> do-something [read %.]
== [%sys-port-drag-accept.r %sys-port-drag-accept.r.bak %ShellExecute.r
%ShellExecute.r.bak]
This is a pretty silly example in practice, but technique is important. In the
above you'd likely want to do much more within the function for it to become
useful. But not always, It can be often helpful to start by 'sketching',
defining simple stub words with names which are meaningful to you and your
application. Rebol encourages rapid continuous experiments in its console shell.
cut'n' paste the results to a script file. Often that means do-ing blocks which
later will be expanded and generalized.
The Deep End of all this has been brilliantly covered by Ladislav Mecir
http://www.sweb.cz/LMecir/
hth
./Jason
[7/7] from: smeagol:chemi:muni:cz at: 23-Oct-2002 10:02
Hi REBOLERS:
especially Andrew Martin, Carl Read, Gregg Irwin, Jason Cunliffe ;-))
Thanks a lot for your kind answers concerning my question.
Those were exactly what I was looking for. Now everything
works perfectly as I wanted. I appreciate your help.
Regards Jan Kmunicek [Smeagol]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted