[REBOL] Evaluating Rebol Data Types with a switch Re:

2000-04-22 Thread allenk

Hi Tim,

If you want to use switch you could try something like this

my-blk: ["one" "two" "three"]  
switch/default form type? my-blk [
"block" [print "block!"]
"string" [print "string!"]
][print "not a string or a block"]


Cheers,

Allen K

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, April 23, 2000 1:07 PM
Subject: [REBOL] [REBOL] Evaluating Rebol Data Types with a switch


> Thanks Allen:
> the following is what I was looking for:
> my-blk: ["one" "two" "three"]
>  either block? my-blk
>  [print "yup"]
>  [print "nope"]
> BUT: Now I have tried switch with no luck
> ; code I tried is below
> my-blk: ["one" "two" "three"]  
> switch my-blk
>   [
> block? [print "block!"]
> string? [print "else!"]
>   ]
> == none
> At 10:58 AM 4/23/00 +1000, you wrote:
> >
> >Hi Tim,
> >
> >With all types there is an evaluator for the type. It is the data-type's
> >name with a "?" on the end.
> >e.g
> >
> >block? ["one" "two" "three"]
> >==true
> >
> >block? http://www.rebol.com
> >==false
> >
> >url? http://www.rebol.com
> >==true
> >
> >Hope that helps.
> >
> >Cheers,
> >
> >Allen K
> >
> >
> >- Original Message -
> >From: <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Sunday, April 23, 2000 10:18 AM
> >Subject: [REBOL] [REBOL] Evaluating Rebol Data Types
> >
> >
> >> Hello Again:
> >> I want to be able to internally evaluate
> >> rebol data types:
> >> the following code :
> >>
> >> my-blk: ["one" "two" "three"]
> >> print reform ["my-blk is a " type? my-blk]
> >>   either equal? type? proj-args "block"
> >>   [print "my-blk's type is block"]
> >>   [print "my-blk's type is something else"]
> >>
> >> ; returns
> >> my-blk is a block
> >> my-blk's type is something else
> >>
> >> ; It appears that
> >> either equal? [type? proj-args] "block"
> >> ; evaluates as false.
> >>
> >> How may I rewrite this code so that it evaluates
> >> as true?
> >>
> >> Thanks in advance
> >> tim
> >>
> >>
> >
> >
> 
> 




[REBOL] [REBOL] Evaluating Rebol Data Types with a switch

2000-04-22 Thread tjohnson

Thanks Allen:
the following is what I was looking for:
my-blk: ["one" "two" "three"]
 either block? my-blk
 [print "yup"]
 [print "nope"]
BUT: Now I have tried switch with no luck
; code I tried is below
my-blk: ["one" "two" "three"]  
switch my-blk
  [
block? [print "block!"]
string? [print "else!"]
  ]
== none
At 10:58 AM 4/23/00 +1000, you wrote:
>
>Hi Tim,
>
>With all types there is an evaluator for the type. It is the data-type's
>name with a "?" on the end.
>e.g
>
>block? ["one" "two" "three"]
>==true
>
>block? http://www.rebol.com
>==false
>
>url? http://www.rebol.com
>==true
>
>Hope that helps.
>
>Cheers,
>
>Allen K
>
>
>- Original Message -
>From: <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Sunday, April 23, 2000 10:18 AM
>Subject: [REBOL] [REBOL] Evaluating Rebol Data Types
>
>
>> Hello Again:
>> I want to be able to internally evaluate
>> rebol data types:
>> the following code :
>>
>> my-blk: ["one" "two" "three"]
>> print reform ["my-blk is a " type? my-blk]
>>   either equal? type? proj-args "block"
>>   [print "my-blk's type is block"]
>>   [print "my-blk's type is something else"]
>>
>> ; returns
>> my-blk is a block
>> my-blk's type is something else
>>
>> ; It appears that
>> either equal? [type? proj-args] "block"
>> ; evaluates as false.
>>
>> How may I rewrite this code so that it evaluates
>> as true?
>>
>> Thanks in advance
>> tim
>>
>>
>
>




[REBOL] Evaluating Rebol Data Types Re:

2000-04-22 Thread allenk


Hi Tim,

With all types there is an evaluator for the type. It is the data-type's
name with a "?" on the end.
e.g

block? ["one" "two" "three"]
==true

block? http://www.rebol.com
==false

url? http://www.rebol.com
==true

Hope that helps.

Cheers,

Allen K


- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, April 23, 2000 10:18 AM
Subject: [REBOL] [REBOL] Evaluating Rebol Data Types


> Hello Again:
> I want to be able to internally evaluate
> rebol data types:
> the following code :
>
> my-blk: ["one" "two" "three"]
> print reform ["my-blk is a " type? my-blk]
>   either equal? type? proj-args "block"
>   [print "my-blk's type is block"]
>   [print "my-blk's type is something else"]
>
> ; returns
> my-blk is a block
> my-blk's type is something else
>
> ; It appears that
> either equal? [type? proj-args] "block"
> ; evaluates as false.
>
> How may I rewrite this code so that it evaluates
> as true?
>
> Thanks in advance
> tim
>
>




[REBOL] [REBOL] Evaluating Rebol Data Types

2000-04-22 Thread tjohnson

Hello Again:
I want to be able to internally evaluate
rebol data types:
the following code : 

my-blk: ["one" "two" "three"]
print reform ["my-blk is a " type? my-blk]
  either equal? [type? proj-args] "block"
  [print "my-blk's type is block"]
  [print "my-blk's type is something else"]

; returns
my-blk is a block
my-blk's type is something else

; It appears that 
either equal? [type? proj-args] "block"
; evaluates as false.

How may I rewrite this code so that it evaluates
as true?

Thanks in advance
tim




[REBOL] Simple Q: Building filenames Re:(2)

2000-04-22 Thread xyzzy

Hello strejcek,

7 minute response time, terrific!  My thanks to everyone who answered
this.

Saturday, April 22, 2000, you wrote:

>>   Can someone provide a REBOL example of this?

smmc> Here it is:

>>> rootdir: %/config/  
smmc> == %/config/
>>> join rootdir "log.txt"
smmc> == %/config/log.txt 

smmc> or 

>>> join rootdir %log.txt
smmc> == %/config/log.txt 

Best regards,
 Andy





[REBOL] Re: online database manipulation Re:(2)

2000-04-22 Thread giesse

Hello [EMAIL PROTECTED]!

On 21-Apr-00, you wrote:

 r> Thanks, Gabriele, but I am searching each line for a specific
 r> string. I hope I am correct in that converting it to hash
 r> speeds up such searches. To see the beta searchable version of

If I understand you correctly, you are doing something like:

foreach line db [
if find line something [ ... ]
]

If I'm correct, then there's no point in converting the db to a
hash (at least AFAIK). The hashtable would speed up searches like:

find db something

Regards,
Gabriele.
-- 
Gabriele Santilli <[EMAIL PROTECTED]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/




[REBOL] Simple Q: Building filenames Re:

2000-04-22 Thread Petr . Krenzelok



[EMAIL PROTECTED] wrote:

> Hello fellow REBOLites,
>
>   I want to compose filenames, I have a known directory that contains
>   a predefined set of files, now I want to open those files.  In C I'd
>   do something like:
>
>   #define ROOTDIR "/config/"
>
>   fopen( ROOTDIR "log.txt", "r); ...
>   fopen( ROOTDIR "prog.cfg", "r"); ...
>

->> root-dir: %/D/Rebol/
== %/D/Rebol/
->> print load join root-dir "Contra/"
Webol/ YARWeS/ RebolToHTML/ xmltest/ Messenger/ REBOL.exe betaadd1950.htm
beta1946.html scroll.r N
EWSITE.LST feedback.r vzvz.vvv rebol.r user.r sites checksite.r etc, etc.

->> exists? root-dir/Contra/user.r
== true

Is it what you wanted?

-pekr-

>
>   Thus I could change the root directory by changing just one line of
>   code.
>
>   Can someone provide a REBOL example of this?
>
> Best regards,
>  Andy




[REBOL] Simple Q: Building filenames Re:

2000-04-22 Thread kracik

Hi,

REBOL has much more expressive power than the C preprocessor :-)
It's quite easy to convert programs from other languages to REBOL.

rootdir: %/config/

a: open/read join rootdir "log.txt"
b: open/read join rootdir "prog.cfg"

-- 
Michal Kracik

[EMAIL PROTECTED] wrote:
> 
> Hello fellow REBOLites,
> 
>   I want to compose filenames, I have a known directory that contains
>   a predefined set of files, now I want to open those files.  In C I'd
>   do something like:
> 
>   #define ROOTDIR "/config/"
> 
>   fopen( ROOTDIR "log.txt", "r); ...
>   fopen( ROOTDIR "prog.cfg", "r"); ...
> 
>   Thus I could change the root directory by changing just one line of
>   code.
> 
>   Can someone provide a REBOL example of this?
> 
> Best regards,
>  Andy




[REBOL] Simple Q: Building filenames Re:

2000-04-22 Thread strejcek

> Hello fellow REBOLites,
> 
>   I want to compose filenames, I have a known directory that contains
>   a predefined set of files, now I want to open those files.  In C I'd
>   do something like:
> 
>   #define ROOTDIR "/config/"
> 
>   fopen( ROOTDIR "log.txt", "r); ...
>   fopen( ROOTDIR "prog.cfg", "r"); ...
> 
>   Thus I could change the root directory by changing just one line of
>   code.
> 
>   Can someone provide a REBOL example of this?

Here it is:

>> rootdir: %/config/  
== %/config/
>> join rootdir "log.txt"
== %/config/log.txt 

or 

>> join rootdir %log.txt
== %/config/log.txt 

Regards
Jan

--
Jan Strejcek
[EMAIL PROTECTED]




[REBOL] Simple Q: Building filenames

2000-04-22 Thread xyzzy

Hello fellow REBOLites,

  I want to compose filenames, I have a known directory that contains
  a predefined set of files, now I want to open those files.  In C I'd
  do something like:

  #define ROOTDIR "/config/"

  fopen( ROOTDIR "log.txt", "r); ...
  fopen( ROOTDIR "prog.cfg", "r"); ...

  Thus I could change the root directory by changing just one line of
  code.

  Can someone provide a REBOL example of this?

Best regards,
 Andy





[REBOL] [REBOL] passing args to another script Re:(2)

2000-04-22 Thread tjohnson

Hi Mike: 
That did it!! 

I hope some day to return something for all
the great help that I have received also. 

I'm putting together a cgi object that will be
available as an external resource (library).
- And this question was part of the process. 

I note also that args can be sent as a 
block for multiply args of any type.

Thanks so much Mike! :>) tim

At 03:26 PM 4/21/00 -0800, you wrote:
>Hi Tim,
>
>Finally my big chance to help someone. This is what it's all about. You
>learn and pass it on. 
>
>The list isn't very active maybe i can respond before someone else does
>
>
> 
>>> How do I pass arguments to another script?
>>> Haven't had much success with the /args
>>> refinement.
>>> I've written two scripts. One "do's" the
>>> other as follows:
>>> ;CALLING script
>>> REBOL [
>>> Title: "testload.r (loading another file)"
>>> Date:   21-Apr-2000
>>> Author: ["newbie"]
>>> ]
>>> do %loadtest.r
>>> ;CALLED script
>>> REBOL [
>>> Title: "loadtest.r loaded from testload.r"
>>> Date:   21-Apr-2000
>>> Author: ["newbie"]
>>> ]
>>> print "in load test"
>>> print ["Command Line Arg: " system/script/args]
>
>>> ;I would like to pass one or more arguments to
>>> ;loadtest.r. What would be the correct way to do
>>> ;it?
>
>>> Thanks to all!! :>) tim
>
>
>The calling script would call the called script with:
>
>do/args loadtest.r x
>
>The called script would pick up x via:
>
>filearg: system/script/args
>
>
>Mike.
>
>
>




[REBOL] [REBOL] online database manipulation

2000-04-22 Thread ralph

Thanks to all REBOLers who contributed to this topic thread for helping me
get my head straight. What the heck wuz I thinking of to read the entire
database into a variable. This would have truly become fun if 40 or 50
people were trying to look up values at once and tortured my poor server's
available memory.

As ever in REBOL, there are simple solutions. I hope this example proves
helpful.

Here are the basics of how I do it now. I pass the search criteria from the
form on the initial search page using the GET method (let's say we seach for
'Smith,' as example). My search.r script (http://abooks.com/cgi-bin/search.r
calls search1.r via the form action HTML line:



The search1.r script gets the form name data ('Smith,') from search.r as
below:

data: decode-cgi system/options/cgi/query-string

The above returns a block with the name/search info in the second position
(data/2). I now open my autograph price database (tab-delimited text), see
how long it is, and use the length to check all lines for matches to the
search string. Any line with a match is appended to block b. Now it is just
HTML stuff to print out the results from block b.

a: open/lines %/autograph/auto.db

b: []
repeat count (length? a) [

 line: pick a count
 if find line data/2 [append b line]

]

close a

We find 113 entries with the string "smith," in it.

I loves REBOL! With only a little more work, I'll have my complete autograph
price lookup service ready to go public in a day or two, and I only started
last Thursday, I believe. REBOL is web application development on
steriods! And just imagine what we all can do when REBOL/Command is
available.

Are we having fun yet? Yeah!

--Ralph Roberts





[REBOL] FTP help needed!

2000-04-22 Thread carlos

Hi Rebols,

I know probably everyody here is tired of
seeing newbie's troubles with FTP. But
there's no other place where I can ask for
help :)

The attached script crashes everytime
after the fourth
downloaded file and Windows issues the
following warning:

"REBOL caused an invalid page fault in
module KERNEL32.DLL at 015f:bff87eb5.
Registers:
EAX=c00300f0 CS=015f EIP=bff87eb5
EFLGS=00010212
EBX= SS=0167 ESP=0055fff4
EBP=00560060
ECX= DS=0167 ESI=815ec7e0 FS=3c1f
EDX=c00300f4 ES=0167 EDI=815ec9ec GS=
Bytes at CS:EIP:
53 56 57 8b 30 83 7d 10 01 8b 4e 38 89 4d
f8 75
Stack dump:"

What am I doing wrong? Can anyone test the
script for me?

Don't forget to create a folder c:\tvprog
(it's where the script dowloads the files
to)

Thank you very much

Carlos Lorenz

REBOL [
  title:   "LisTV" 
  file:%listv.r
  date:[10-jan-2000]
  lstupd:  [11-apr-2000]
  file:"%listv.r"
version: 1.0
author:  "Carlos Lorenz" 
  email:   [EMAIL PROTECTED]
purpose: {multiple dowloads from FTP site LisTV}
]

grids: [ 
  1 "CMT.TXT" "CMT"
  2 "CNE.TXT" "CNN Espanhol"
  3 "CNN.TXT" "CNN Int"
  4 "CUL.TXT" "CULTURA"
5 "DWL.TXT" "DEUTSCHE WELLE"
  6 "DIK.TXT" "DISCOVERY KIDS"
7 "DIS.TXT" "DISCOVERY"
  8 "ECO.TXT" "ECO"
  9 "EET.TXT" "E!"
 10 "ESB.TXT" "ESPN Brasil"
 11 "ESP.TXT" "ESPN Int"
 12 "EUR.TXT" "EUROCHANNEL"
 13 "BRA.TXT" "FILM & ARTS"
 14 "FOX.TXT" "FOX"
 15 "KID.TXT" "FOX KIDS"
 16 "FUT.TXT" "FUTURA"
 17 "GNT.TXT" "GNT"
 18 "HAL.TXT" "HALLMARK"
 19 "HBO.TXT" "HBO"
 20 "HB2.TXT" "HB2"
]

grid-search: make function! [series seek where] [
 grid: find series seek
 if where == "rec"  [ return first grid ]
 if where == "file" [ return second grid]
]

local-date: make function! [some-date [date!] ][
 months: [2 4 5 8 9 12]
 locale-months: ["-Fev-" "-Abr-" "-Mai-" "-Ago-" "-Set-" "-Dez-"]
 if found? find months some-date/month[ 
return join some-date/day [pick locale-months 
   index? find months some-date/month some-date/year]
 ]
 return some-date
]

left: func [str num][copy/part str num]
right: func [str num][copy skip tail str negate num]
substr: func [str num length][copy/part at str num length]

user: "tvprog"
pass: "znerol01"

;remore server
site: to-url join "ftp://" [user ":" pass "@ftp.intermega.com.br/REBOL/Scripts/"]
sitedata: to-url join "ftp://" [user ":" pass "@ftp.intermega.com.br/REBOL/Txt/"]

; local server
;site: ftp://127.0.0.1/
;sitedata: ftp://127.0.0.1/txt/

print "^Lconnecting to FTP site TVProg"

either not exists? %../tvprog/lista.cf[

print trim {^LAvailable TV Listings at LisTV: 

  1 CMT  10 ESPN Brasil
  2 CNN Espanhol 11 ESPN Int
  3 CNN Int  12 EUROCHANNEL
  4 CULTURA  13 FILM & ARTS
5 DEUTSCHE WELLE   14 FOX
  6 DISCOVERY KIDS   15 FOX KIDS
7 DISCOVERY16 FUTURA
  8 ECO  17 GNT
  9 E!   18 HALLMARK
 19 HBO  
 20 HBO2 
}  

go-out: true

  print trim {Enter the code numbers of the lists you want to download 
separated by spaces.
  For example: 05 20 24 34 78 04 and press . 

  In c:\tvprog\lista.cf you'll find the names of channels you 
chose.
  To alter your selection just delete the file [lista.cf]
before running the script again.

The downloaded lists will be saved in c:\tvprog\tvprog.txt.
  }
  a: ask "Code numbers? : "

  if a == "" [quit]

args: make block! parse a "-"

print join newline ["Wait..." newline] 

foreach arg args[
  if greater? arg "20" [
 arg: "20"
  ]
  if lesser? arg "0" [
 arg: "1"
  ]
  if equal? arg "0" [
 arg: "1"
  ]
  nfile: grid-search grids (to-integer arg) "file"   
write/append %../tvprog/lista.cf join nfile newline
  files: make block! read %../tvprog/lista.cf 
]
][
files: make block! read %../tvprog/lista.cf 
]

if error? try [write %../tvprog/tvprog.txt join read site/header.txt [newline 
newline]][
  print "^LDial-up connection error detected! Try to reconnect."   
  wait 3
  quit
]  

foreach file files [
  if (length? (to-string file)) < 7 [
  print "^LFile c:\tvprog\lista.cf corrupted!"
  print "Please delete it and run the script again."
  wait 4
  quit
  ]

  nfile: grid-sear

[REBOL] Rebol webserver which executes Rebol scripts? Re:(2)

2000-04-22 Thread bobkanuri

Thanks very much Andrew. This helps a lot...

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 20, 2000 7:53 PM
Subject: [REBOL] Rebol webserver which executes Rebol scripts? Re:


> Bob wrote:
> > ... is it possible to create a Rebol webserver which executes Rebol
> scripts?
>
> Have a look at http://www.rebol.org
>
> There's a rebol web server or two there. Plus there's a simple one in the
> examples, I believe in the rebol site. There's also been other web servers
> posted on this mailing list. Nearly all of them can run rebol scripts.
>
> You could also get the beta REBOL Apache module, which, I believe, runs a
> lot quicker.
>
> And, as a cgi, you can run REBOL under several non-rebol web servers, such
> as MS PWS and others.
>
> I hope that helps.
>
> Andrew Martin
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-
>
>