Index?
[1/22] from: ptretter:charter at: 25-Aug-2000 14:47
Is there an alternative for:
>>a: "101"
>>foreach item a [print index? item]
1
2
3
Obvious to you REBOL gurus this generates an error. But it illustrates
clearly what I want to do. Damn, index? is native! :) Anyone have some
helpful alternatives.
Paul Tretter
[2/22] from: rryost:home at: 25-Aug-2000 13:31
Paul, I don't see the result as an error.
You're just printing out the "index" of each item in 'a;
Look at this console session, with remarks inserted following the :'s:
>> a: "101"
== "101"
>> foreach item a [print item]
1 ; the index of this '1 is 1.
0 ; the index of this '0 is 2, etc.
1
[3/22] from: jhagman:infa:abo:fi at: 25-Aug-2000 23:31
Quoting [ptretter--charter--net] ([ptretter--charter--net]):
> Is there an alternative for:
> >>a: "101"
<<quoted lines omitted: 5>>
> clearly what I want to do. Damn, index? is native! :) Anyone have some
> helpful alternatives.
Ummm... I don't have clue what you are trying to do, but maybe
following will help:
while [not tail? a] [
print index? a
a: next a
]
Yours,
Jussi
--
Jussi Hagman CS in Åbo Akademi University
Studentbyn 4 D 33 [juhagman--abo--fi]
20540 Åbo [jhagman--infa--abo--fi]
Finland
[4/22] from: ryanc:iesco-dms at: 25-Aug-2000 14:29
Hi Paul,
>> a: "101"
== "101"
>> forall a [print index? a]
1
2
3
== false
>>
This changes the actual index of a, so you will likely want to do this
afterward:
>>a: head a
Foreach does not effect the index, it just feeds you the data. :-()
--Ryan
[ptretter--charter--net] wrote:
> Is there an alternative for:
> >>a: "101"
<<quoted lines omitted: 6>>
> helpful alternatives.
> Paul Tretter
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
[5/22] from: galtbarber:mailandnews at: 25-Aug-2000 17:54
I have often wished I could do what you want.
Sometimes you want to have your cake and eat it, too!
It is a drag to have to insert first everywhere
in examples like this:
forall somelist [print first somelist]
and when you do this:
foreach element somelist [print element]
this is great as long as you don't also need
to know it's position. many times you may
need that position.
You can also do this:
repeat i length? somelist [print somelist/:i]
which is sort of ok
as you can see, in your example below,
item is the actual character from the string,
not the string, therefore you can't ask for it's
position, as it won't have access to that info.
I suppose Rebol could create a local keyword
that stored that index, because obviously, internally
it does know what the index really is.
But Rebol avoids creating new keywords, and
when you get multiple nested structures, exposing
that index as a keyword might be a real drag.
And how come there isn't a short hand for:
list: next list
wouldn't it be helpful to everybody to have
something like this:
advance list
which would do the same thing, and even better
as a native.
I guess one could make up your own function,
but then everybody would be re-inventing this
wheel independently. It seems like it ought to
come with the system.
[6/22] from: agem:crosswinds at: 26-Aug-2000 22:10
a: "101"
forall a [item: first a
print index? a]
[7/22] from: rryost:home at: 26-Aug-2000 15:15
Hi Volker
This may be a partial dupe of one I sent earlier.
Why do you insert the "item: first a", but then not use it?
Here's a console session that prints index and item:
>> a: "101"
== "101"
>> forall a [prin index? a print [" " first a]] a: head a ; This final
statement is needed only if the forall is rerun later.
1 1
2 0
3 1
== "101" ; This results from the "final statement" in the console line
above.
[8/22] from: agem:crosswinds at: 28-Aug-2000 0:34
--- [rryost--home--com] wrote on 26-Aug-2000/15:15:31-7:00
> Hi Volker
> This may be a partial dupe of one I sent earlier.
>
> Why do you insert the "item: first a", but then not use it?
>
Paul needed the index and the item without all that 'first everytime.
this is a big bit ugly, but gives you both values:
> > a: "101"
> > forall a [item: first a
> > print index? a]
its a sample, so i found no use for the 'item..
not as elegant as Gabrieles solution :)
[9/22] from: ptretter:charter at: 5-Sep-2000 17:00
I dont understand the makeup of this file or where to find documentation for
it. Is there a way to change the location for looking for this file so we
can "customize" the interface. The file is below.
REBOL []
name "Test-Site"
summary "A description of this location."
updated daily ;hourly monthly yearly 0:10 never always
expires 1-jan-2001
;notice "hello"
icon "RebSites" dir %view/reb/sites.r
icon "Tests" dir %view/reb/tests.r
icon "Docs" dir %view/reb/docs.r
icon "Demos" dir %view/reb/demos.r
icon "Upgrade" %view/reb/upgrade.r always
icon "REB-Cam" %view/reb/rebcam.r
[10/22] from: bhandley:zip:au at: 6-Sep-2000 10:07
When I downloaded the pre Beta 5 view and the demo screen came up - I
clicked docs and I believe you'l find the info you want there.
Brett.
[11/22] from: bhandley:zip:au at: 6-Sep-2000 10:10
Further to my earlier message:
Doing as I described will get you to:
http://www.rebol.com/view/reb/publish.html
Brett.
[12/22] from: agem:crosswinds at: 15-Sep-2000 20:53
[gchiu--compkarori--co--nz] wrote on 15-Sep-2000/20:52:18+1:00
> Just wondering where I might find the documentation for
> the index.r file
>
in the test-panel-browser. Docs. a rebol/view-script as browser :)
[13/22] from: agem:crosswinds at: 28-Oct-2000 13:38
[carl--cybercraft--co--nz] wrote on 28-Nov-2000/9:58:21+12:00
> On 28-Nov-00, Graham Chiu wrote:
> >
<<quoted lines omitted: 8>>
> > check for the existence of the script locally, and if not
> > present, to download from my server, and then execute it?
there i's load-thru .
you can [do load-thru http://...], downloading/caching is then automatic.
if you need your header-info
[
load-thru http://.../script.r ;will load it in current dir
do %script.r ;will actually do it with header
]
> I've not done anything with index.r pages, but 'browse is the word
> for telling a browser to view a webpage, so adding it to your above
> code somewhere (or other:) might get it to work...
>
i use a mini-script with only [rebol[] browse mailto://my-email]
for example.
[14/22] from: gchiu:compkarori at: 21-Nov-2000 15:36
Just looking for the documentation for index.r ...
--
Graham Chiu
http://www.compkarori.co.nz/index.r << stab that's not
working too well.
[15/22] from: gchiu:compkarori at: 27-Nov-2000 17:53
Just wondering where I might find the documentation for
the index.r file
--
Graham Chiu
[16/22] from: carl:cybercraft at: 27-Nov-2000 23:58
On 27-Nov-00, Graham Chiu wrote:
> Just wondering where I might find the documentation for
> the index.r file
> --
> Graham Chiu
You can get it using the View Test Panel on the rebol.com docs page...
www.rebol.com/view/reb/doc.r
It's saved to your Public directory as: indices2.r
Carl Read.
[17/22] from: gchiu:compkarori at: 28-Nov-2000 9:38
On Mon, 27 Nov 2000 23:58:05 +1200
Carl Read <[carl--cybercraft--co--nz]> wrote:
> > Just wondering where I might find the documentation for
> > the index.r file
<<quoted lines omitted: 4>>
> www.rebol.com/view/reb/doc.r
> It's saved to your Public directory as: indices2.r
Thanks guys.
I have a couple of problems:
1. I want to add a link to a directory on my other web site
in my index.r, but my pages don't end in .html. They either
have no suffix, or they may end in .php. The docs say that
the web browser is launched if the file ends in .html ...
eg: icon "Misc Scripts" http://203.79.82.38/zwiki/SCripts
info "Miscellaneous Rebol Scripts"
2. I have a script which calls other scripts. Do I have to
check for the existence of the script locally, and if not
present, to download from my server, and then execute it?
--
Graham Chiu
http://www.compkarori.co.nz/index.r
[18/22] from: carl:cybercraft at: 28-Nov-2000 9:58
On 28-Nov-00, Graham Chiu wrote:
> I have a couple of problems:
> 1. I want to add a link to a directory on my other web site
<<quoted lines omitted: 6>>
> check for the existence of the script locally, and if not
> present, to download from my server, and then execute it?
I've not done anything with index.r pages, but 'browse is the word
for telling a browser to view a webpage, so adding it to your above
code somewhere (or other:) might get it to work...
Carl Read.
[19/22] from: gchiu:compkarori at: 29-Nov-2000 10:19
On Sat, 28 Oct 2000 13:38:20 +0100
[agem--crosswinds--net] wrote:
> there i's load-thru .
> you can [do load-thru http://...], downloading/caching is
<<quoted lines omitted: 3>>
> load-thru http://.../script.r ;will load it in current
> dir
Is there a way to save it automatically to the same relative
directory as on the website? (this is what happens when you
execute a script off the Rebol browser )
> i use a mini-script with only [rebol[] browse
> mailto://my-email]
Sorry, don't understand. Is this line in your index.r ?
--
Graham Chiu
[20/22] from: agem:crosswinds at: 29-Nov-2000 12:55
>>>>>>>>>>>>>>>>>> Ursprüngliche Nachricht <<<<<<<<<<<<<<<<<<
Am 28.11.00, 22:19:36, schrieb "Graham Chiu" <[gchiu--compkarori--co--nz]>
zum Thema [ALLY] Re: index.r:
> On Sat, 28 Oct 2000 13:38:20 +0100
> [agem--crosswinds--net] wrote:
<<quoted lines omitted: 8>>
> directory as on the website? (this is what happens when you
> execute a script off the Rebol browser )
i think its relative to the scripts start-directory, but not sure.
Which is the same directory, if you start the script fro the
reb-browser
> > i use a mini-script with only [rebol[] browse
> > mailto://my-email]
> Sorry, don't understand. Is this line in your index.r ?
No, seperate script. Rebol-browser loads the script and the script
launches the
browser. This way you can force every extension to use the browser.
[21/22] from: jean:holzammer:faedv-n:bayern at: 1-Dec-2000 7:29
> i use a mini-script with only [rebol[] browse
> > mailto://my-email]
its mailto:my-mail
no // after mailto:
there is no real mailto inetrnet protocol, its more a kind of
pseudo-protocol.
Jean
[22/22] from: gchiu:compkarori at: 1-Dec-2000 11:34
On Wed, 29 Nov 2000 12:55:37 GMT
Volker Nitsch <[agem--crosswinds--net]> wrote:
> > > i use a mini-script with only [rebol[] browse
> > > mailto://my-email]
<<quoted lines omitted: 5>>
> browser. This way you can force every extension to use
> the browser.
I feel a little silly, but I can't get this to work.
Anyone point me to a rebsite that uses this technique?
--
Graham Chiu
http://www.compkarori.co.nz/index.r
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted