[REBOL] [REBOL] Reminder

1999-12-01 Thread Al . Bri

Here's a more recent version with corrected inspiration. :-)
[
REBOL [
Title: "Reminder"
Date: 1/December/1999
Name: 'Reminder
Version: 0.0.2
File: %"Reminder.r"
Home: http://members.xoom.com/AndrewMartin/
Author: "Andrew Martin"
Owner: "Andrew Martin"
Rights: "Copyright © 1999, Andrew Martin."
Needs: 2.2.0
Tabs: 4
Usage: {
Reminder? 5/Dec/1999/19:00:34
Reminder? now
}
Purpose: {
To issue reminders for the current time
for a daily and weekly schedule.
}
Comment: {
Inspiration gratefully received from Graham Chiu! :-)
}
Inspiration: {
Graham Chiu
gchiucompkarori.co.nz
http://www.compkarori.com/dynamo - The Homebuilt Dynamo
http://www.compkarori.com/dbase - The dBase bulletin
}
History: [
0.0.1 [1/December/1999 {Created this.} {Andrew}]
0.0.2 [1/December/1999 {Updated this header.} {Andrew}]
]
Language: 'English
Email: [EMAIL PROTECTED]
Site: http://members.xoom.com/AndrewMartin/
Category: 'general
Charset: 'ANSI
Example: {}
]

Daily_Schedule: [
22:00 "Ten O'Clock News - TV1"
]

Weekly_Schedule: [
Tuesday [
18:00 "Six O'Clock News - TV1"
20:30 "StarTrek Voyager - TV4"
]
Thursday [
20:30 "Star Gate - TV3"
]
Friday [
19:30 "Farscape - TV3"
]
Sunday [
19:00 "Futurama - TV2"
]
]

Weekday: function [
{Translates Weekday number to weekday name word.}
Date [date!]] [Weekdays]
[
Weekdays: [
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
]
pick Weekdays Date/Weekday
]

Month: function [
{Translates Month number to month name word.}
Date [date!]] [Months]
[
Months: [
January
February
March
April
May
June
July
August
September
October
November
December
]
pick Months Date/Month
]

Daily?: func [Schedule [block!] Time [time!]] [
Time: Time - (Time // 00:01:00)
select Schedule Time
]

Weekly?: function [Weekly_Schedule [block!] Date [date!]] [Schedule] [
Schedule: select Weekly_Schedule Weekday Date
if block? Schedule [
Daily? Schedule Date/Time
]
]

Reminder?: function [Date [date!]] [Reminder] [
Reminder: Daily? Daily_Schedule Date/Time
if none? Reminder [
Reminder: Weekly? Weekly_Schedule Date
]
Reminder
]

Remind: function [] [Reminder] [
forever [
Reminder: Reminder? now
if string? Reminder [
print rejoin [{Reminder: "} Reminder {"}]
; Call Cellular Telephone Message script here!
; My_Cellular_Telephone_Message Reminder
]
wait 00:01:00
]
]

print Reminder? 5/Dec/1999/19:00:34

]

Andrew Martin
Perspiring over a hot REBOL stove... ;-)
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-



[REBOL] Change console size? Re:(3)

1999-12-01 Thread rryost

But I had to assume a worst case computer/display combination.  A board game
I posted started with a page of instructions.  The left-most 25 or so
characters of the first 12 lines were used to show a diagram of the game
board generated with text characters.  If the instructions got line-wrapped
because the lines of the instructions had too many characters, the diagram
of the game board got badly messed up!  At first I used the  full width of
my Win98 screen, but then realized many computers wouldn't have that many
characters available.

Russell [EMAIL PROTECTED]
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 01, 1999 12:23 AM
Subject: [REBOL] Change console size? Re:(2)


> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, November 30, 1999 6:02 PM
> > To: [EMAIL PROTECTED]
> > Subject: [REBOL] Change console size? Re:
>
> > I wonder if it's possible to force a user's console to a
> > specific size?  I have assumed it's at least 72 characters
> > wide and limited text output line length accordingly.
>
> Hi, on Windows you can resize the window and have a very big console area.
> This is a cool thing! With all these GUI applications for even the most
> simple problems, good old text-style applications can come back :-). But
> there must be enough space to show all the needed information.
>
> Robert M. Muench, Karlsruhe, Germany
> ==> ask for PGP public-key <==
>
>   When do you want to reboot today?
>
> Use the free portable GUI Library
> OpenAmulet from http://www.openip.org
>



[REBOL] Reminder Re:(6)

1999-12-01 Thread icimjs

Hi Graham,
you wrote:
>Sorry you didn't like my script!
>
>I wrote it last night while watching Star Trek Voyager with the ultimate
>intention of using Rebol to update it, so to keep it simple ( which is
>the only way I know how to write! ), kept all the data in one block. 
>

Don't take Andrew's likes and dislikes too personal. He's tried to teach
Carl how to design REBOL and stubbornly refuses to adopt the suggestions in
the REBOL style guide. He prefers his own style, programming and otherwise.

He's certainly entitled to that. Other people prefer to use REBOL as *they*
see fit, which varies based on past experience and current intentions.

IMHO REBOL is very much about the freedom of choice.



Elan



[REBOL] [REBOL] Reminder Re:

1999-12-01 Thread icimjs

Hi Andrew,

you wrote:
>
>Reminder?: function [Date [date!]] [Reminder] [
>   Reminder: Daily? Daily_Schedule Date/Time
>   if none? Reminder [
>   Reminder: Weekly? Weekly_Schedule Date
>   ]
>   Reminder
>   ]

If I understand your code correctly, then there can be reminders scheduled
that are repeated every day. That is done in the Daily_Schedule. Other
reminders can be scheduled to be repeated on a specific day of the week.
Those are the reminders in the Weekly_Schedule.

The code fragment above will only check for a recurring reminder in the
weekly schedule, if it didn't find a recurring reminder in the daily schedule:

>> if none? Reminder

Wouldn't it be possible for two different reminders to be scheduled both in
Daily_Schedule as well as Weekly_Schedule for the same day and time?
Perhaps you want to record a show while you're watching another one? Or
perhaps you want to schedule a different reminder, such as write the
reminder script while you're watching StarTrek?

If that were the case you would miss the weekly reminder, because your
program already found the daily reminder, none? Reminder returns false and
checking the weekly schedule is not invoked.

Take Care,

Elan



[REBOL] Objects: Preventing Code Duplication Re:

1999-12-01 Thread lmecir

Elan wrote:
-

The
> following mechanism can be used to avoid inheriting some code. It uses use
> contexts:
>
> ancestor: make object! [
>   do-something: none
>   use [var-1 var-1 comment {more vars here} func-1 func-2 func-3 ] [
> var-1: "this is var-1"
> var-2: "this is var-2"
> ;- more vars here ...
> func-1: func ["extremely long function. don't inherit."]

>   print "func-1: tons of code here"
> ]
> func-2: func ["also extremely long function. don't inherit."]

>   print "func-2 tons of code here"
> ]
> do-something: func ["this function will be inherited"] [
>   func-1
>   func-2
> ]
>   ]
> ]
>
> descendant: make ancestor []
>
> >> descendant/do-something
> func-1: tons of code here
> func-2 tons of code here
> >> probe descendant
>
> make object! [
>   do-something: func ["this function will be inherited"][
> func-1
> func-2
>   ]
> ]
>
> ;- Elan

-

There are two problems with your solution:

a) it is relying on the persistence of func-1, func-2, ..., which is not
garanteed now (problem with indefinite extent and garbage collector...)
b) the uninherited functions can access only the ancestor's attributes and
not the descendant's

I think the only reliable method is to define the uninherited functions
outside of the object and submit them one more parameter - the object to
operate on.

Ladislav



[REBOL] HL7 utlities Re:(4)

1999-12-01 Thread sqlab

As promised

;msg: to-string read/binary %test/hl7/h024.hl7

hl7: make object! [ 
  msgtype: make block! 2 
  segsep:  "^M"
  fldsep:  "|" 
  compsep: "^^"
  repsep:  "~"
  escape:  "\"
  subsep:  "&"
  frame.start: none
  frame.end:   none
  segments:make block! 50
  segnumber:   0
  ok:  true
  warning: none   
  in:  func ["should parse and check a message according
HL7-Rules"
 msg [string!] /local seg
   ] [
  clear segments clear msgtype segnumber: 0 ok: true
  parse msg [copy frame.start [ to "MSH" | to "FHS"] seg: ( 
append/only msgtype copy/part seg 3
fldsep:  pick seg 4
either fldsep = pick seg 9 [
fldsep:  to-string fldsep
compsep: to-string pick seg 5 
repsep:  to-string pick seg 6
escape:  to-string pick seg 7
subsep:  to-string pick seg 8
]  [ok: false warning: "Delimiter"]
   ) 
   some [ copy seg to segsep (
  if seg [
either fldsep/1 = pick seg 4 [
  segnumber: :segnumber + 1
  append/only segments to-word copy/part seg 3
  seg: skip seg 4
  append/only  segments to-block parse/all seg fldsep
] [ok: false 
   warning: join "Header after segment nro " form
segnumber
  ]
 ) 1 skip 
   ] 
   copy frame.end to end (
 insert segments/msh fldsep
 append/only msgtype replace copy segments/msh/9 compsep ""
) 
  ] 
  return segments
  ]  
  msg: make string! 1000 
  out: func ["should generate a message according the HL7 rules" ]
[
clear msg
fldsep: copy segments/msh/1
remove segments/msh
foreach [head body] segments [
   append msg form head append msg fldsep
   foreach fld body [append msg fld append msg fldsep]
   append msg segsep
]
insert segments/msh fldsep
return msg
  ]   
]

Usage:
s: hl7/in msg
m: hl7/out
msh-segment: s/msh
version-id:  s/msh/12
reply-for: s/msa/2
internal-patientid: s/pid/3
etc.

You see, there's a lot to do. Especially the syntax checking is very
rudimentary. Also the autosensing for the frame type has problems with the MLLP.
I'm still thinking if I really has to do a walk through the segments in
order to get the segment number of an given segment.

If you or someone else knows an easy solution, don't hesitate to post it
or mail me directly!

Regards
AR

> Hi 
> 
> As I'm working with physically separated networks, I do not have this
> routines at hand, but hope to transfer and post some tomorrow.
> 
> Regards 
> AR
> 

-- 
Sent through Global Message Exchange - http://www.gmx.net



[REBOL] Change console size? Re:(4)

1999-12-01 Thread robert . muench

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 01, 1999 9:16 AM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Change console size? Re:(3)

> But I had to assume a worst case computer/display combination.

Well, my application users have to use the right size, otherwise the
application is useless. So, if you want to use it, use the right size ;-).
Not much a problem for me. Robert



[REBOL] Valid e-mail addresses

1999-12-01 Thread lmarzulli

Hi

A question:

Using REBOL
How can I test if the username  has a mailbox at the  e-mail server?

In other words: how can I test if @ is a valid e-mail address?
(Of course I don't know the password)

In other words: how can I send a VRFY SMTP command to a e-mail port?

Thank you


-- 
Lourdes Yero
e-mail: [EMAIL PROTECTED]
e-mail: [EMAIL PROTECTED]
e-mail: [EMAIL PROTECTED]
e-mail: [EMAIL PROTECTED]
web site: http://www.geocities.com/RainForest/4672/
Caracas, VENEZUELA



[REBOL] Bug?

1999-12-01 Thread Al . Bri

I've been fooling around inside REBOL functions and came across this
unexpected behaviour:

>> Spec: func ['f /Set Block [block!]] [either Set [insert clear first
get f Block] [first get f]]
>> Body: func ['f /Set Block [block!]] [either Set [insert clear second
get f bind Block first spec :f] [second get f]]
>>
>> f: func [test] [print test]
>> f 12
12
>> body f
== [print test]
>> rebol/version
== 2.2.0.3.1
>> body/set f [print ["Test:" test]]


REBOL caused an invalid page fault in
module REBOL.EXE at 0137:00402fbb.
Registers:
EAX=10d0 CS=0137 EIP=00402fbb EFLGS=00010212
EBX=010d SS=013f ESP=0065fa48 EBP=0065fa68
ECX=0080221c DS=013f ESI=00db8638 FS=21ff
EDX= ES=013f EDI=03f9 GS=
Bytes at CS:EIP:
8b 4f 08 8b 51 08 8b c2 80 38 00 74 20 3b 58 0c 
Stack dump:
00dc2b08 00db8638 00821cf4 0040307b 03f9 00db8638  00821ce4
 0040a19d 03f9 00db8638  007820e4 00824be0 0065fabc


Andrew Martin
Burning REBOL...
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-



[REBOL] [REBOL] Reminder Re:(2)

1999-12-01 Thread Al . Bri

Elan wrote:
> Wouldn't it be possible for two different reminders to be scheduled
both in Daily_Schedule as well as Weekly_Schedule for the same day and
time?

H, this sounds like a person that has problems with their schedule.
:-) They need to read Covey's "Seven Habits" and the fourth generation
scheduler book, whose name and author I've forgotten.

Script-wise, I would leave this problem up to the schedule setter and
deconflict it there, as the schedule setter would know more about the
situation.

Andrew Martin
Who's just been reminded, it's time to go to bed...
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-



[REBOL] Objects: Preventing Code Duplication Re:

1999-12-01 Thread lmecir

An example code concerning inheritance of object messages:

Rebol[
Purpose: "Demonstrate non-copied object messages."
]

;Define the object without messages
a: make object! [
num: 1
;Other non-message attributes here...
messages: none
]

;Now define the messages, common for all descendants.
;These are created only once
;and aren't copied as long as
;you don't change anything for a descendant...
a/messages: make object! [
;An example message
get-num: func [
;every message must have access to object to which it has been
sent...
obj [object!]
;the room for message parameters...
param
] [
;This is the body of the message
obj/num
]
;Other messages here...
]

;Function to send messages, shouldn't be changed
sm: func [obj [object!]  'message [word!] param [block!]] [
do in obj/messages message obj param
]

;Now you can use the code like this:
>> sm a get-num []
== 1
>> b: make a [num: num + 1]
>> sm b get-num []
== 2


- Ladislav



[REBOL] Q on Array of Objects Re:(10)

1999-12-01 Thread giesse

[EMAIL PROTECTED] wrote:

> Hi Gabriele,
> 
> when you say
> 
> b: get in obj 'f
> 
> you are indeed creating a reference. This was not Andrew's concern. Andrew
> was talking about the following situation:
[...]

Actually, I was referring to the following piece:

Interface: make object! [
; f: get in Implementation 'f   ; Copies
Implementation/f

Ciao,
/Gabriele./
o) .-^-. (--o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o) `-v-' (--o



[REBOL] Objects: Preventing Code Duplication Re:

1999-12-01 Thread giesse

[EMAIL PROTECTED] wrote:

> It uses use
> contexts:

To avoid problems with the garbage collector, my hide.r show work
fine here.

Ciao,
/Gabriele./
o) .-^-. (--o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o) `-v-' (--o



[REBOL] Newby needs some "strings" help Re:(3)

1999-12-01 Thread giesse

[EMAIL PROTECTED] wrote:

> >I'm fairly new to REBOL and wouldn't be surprised if there is a much better
> >way to do it.
> 
> Fairly new, huh? And programming like a veteran  nice work. One little
> detail:
> 
> >substr: func [s k n /local a]
> >[
> >   a: ""
> >   for i k k + n - 1 1 [a: join a pick s i]
> >   a
> >]

Actually, this could be done with:

   copy/part at s k n

:-)

Ciao,
/Gabriele./
o) .-^-. (--o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o) `-v-' (--o



[REBOL] Encouraging functional programming Re:(8)

1999-12-01 Thread mailinglists

Hi,

I've been following this thread (though it goes over my head a bit) with
interest, but with this one you guys have lost me! =)

First of all what are Fibonnacci numbers?

Second, perhaps someone could explain to me what Ladislav's code does?

> -Original Message-
> I calculate the Fibonnacci numbers without recursion using REBOL. For
> example
>
> >> fib 100
> == 3.54224848179262E+20
> >>
>
> How would you calculate it with recursion?
>
> Jerry
>
> fib: func [first second n] [
>
> either n = 1 [first] [
>
> either n = 2 [second] [
>
> fib second first + second n - 1
>
> ]
>
> ]
>
> ]
>
> >> fib 1.0 1.0 100
> == 3.54224848179262E+20
>
> Ladislav
>



[REBOL] system/words question

1999-12-01 Thread ingo

Hi Rebols,

why are locally created words listed in system/words, too?
try:

>> cc: words-of system/words   
== [unset! ...
>> xx: func ["Testfunc" yy /local zz][zz: 1 print [ yy zz ]]
>> dd: words-of system/words   
== [unset! ...
>> ee: difference cc dd
== [xx yy zz]
>> value? 'yy
== false

Are all locally created words listed, and are they the
only one listed without values?


regards,

Ingo

--  _ ._
ingo@)|_ /|  _| _   ingo@| |(_|o(_)| (_| 
http://www.2b1.de/Rebol/ ._|  ._|



[REBOL] Newby needs some "strings" help Re:(2)

1999-12-01 Thread ingo

Hi Andrew,

there's an error in here. The parse should read:

parse line [thru "key1=" copy key1 to "key2=" thru "key2=" copy key2 to "key3=" 
thru "key3=" copy key3 to end]

Without the 'skip s. skip advances one character, so the following "key..." 
string can not be found any more.


regards,

Ingo


Those were the words of Andrew M. Grossmann:
> try something like:
> 
> foreach line read/lines %data.txt [
> parse line [thru "key1=" copy key1 to "key2=" skip thru "key2=" copy key2 to "key3=" 
>skip thru "key3=" copy key3 to end]
> ; do stuff with keys here
> ]
> 
> Take a look at the docs on parse as well.
> 
> --
> Andrew Grossman
> 
> --- You wrote:
> I am new to Rebol and need some help dealing with strings.  I've looked around
> for examples but can't find any - so I would appreciate it if you could give me
> some advise or point me to an example. Here's th
> --- end of quote ---
> 
Hi Rebols,




regards,

Ingo

--  _ ._
ingo@)|_ /|  _| _   ingo@| |(_|o(_)| (_| 
http://www.2b1.de/Rebol/ ._|  ._|



[REBOL] Objects: Preventing Code Duplication Re:

1999-12-01 Thread ingo

Hi Elan,

are you sure it works the way you think? I'm only asking, because
you get exactly the same output for:

>> probe ancestor

make object! [
do-something: func ["this function will be inherited"][
func-1 
func-2
]
]
>> probe descendant

make object! [
do-something: func ["this function will be inherited"][
func-1 
func-2
]
]

and I would like it to work.


regards,

Ingo

Those were the words of [EMAIL PROTECTED]:
> Hi guys,
> 
> Sorry, can't remember all the names. Have little time. 
> 
> Someone observed that descendant objects inherit their ancestor object's
> function implementations and variables. This leads to inflated code. The
> following mechanism can be used to avoid inheriting some code. It uses use
> contexts:
> 
> ancestor: make object! [
>   do-something: none
>   use [var-1 var-1 comment {more vars here} func-1 func-2 func-3 ] [
> var-1: "this is var-1"
> var-2: "this is var-2"
> ;- more vars here ...
> func-1: func ["extremely long function. don't inherit."] [ 
>   print "func-1: tons of code here"
> ]
> func-2: func ["also extremely long function. don't inherit."] [ 
>   print "func-2 tons of code here"
> ]
> do-something: func ["this function will be inherited"] [
>   func-1
>   func-2
> ]
>   ]
> ]
> 
> descendant: make ancestor []
> 
> >> descendant/do-something
> func-1: tons of code here
> func-2 tons of code here
> >> probe descendant
> 
> make object! [
>   do-something: func ["this function will be inherited"][
> func-1
> func-2
>   ]
> ]
> 
> ;- Elan
> 
> 
> 
Hi Rebols,




regards,

Ingo

--  _ ._
ingo@)|_ /|  _| _   ingo@| |(_|o(_)| (_| 
http://www.2b1.de/Rebol/ ._|  ._|



[REBOL] Encouraging functional programming Re:(9)

1999-12-01 Thread 70740 . 503

The Fibonnacci series is defined by the recurrence relations

   a(n)=a(n-1)+a(n-2)
   a(1)=1
   a(2)=1
   
The series resulting is

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ...

 Jerry



[REBOL] Reminder Re:(3)

1999-12-01 Thread ddalley


On 01-Dec-99, [EMAIL PROTECTED] wrote:

> Did I say that?  The 'version in the header is meant for your scripts.
> The 'needs field is for specifying the version of REBOL needed, as well
> as other items, eventually.  It takes a tuple, or a block dialect.

Memories become cloudy, in time. Andrew reposted your message, Carl, which I
failed to find locally, for confirmation.

I can update my headers, now. ;^)

> Also, I think Bo has a CRON REBOL program...

Ok, thanks.
-- 

---===///||| Donald Dalley |||\\\===---
 The World of AmiBroker Support
  http://webhome.idirect.com/~ddalley
   Member: ICOA and Team AMIGA



[REBOL] 1000's of objects's in array - Works fine for me... Re:(2)

1999-12-01 Thread lnusrn1 . bz3r4j



Please elaborate on this for process
 to handle standard comma delimited files (or tab delimited files)...

Any more pointers on the words  set [ x1 x2 x3 x4 ... ] record

I know about "set"  , but what is "record" is that a word or just your
example value.





From: [EMAIL PROTECTED] on 12/01/99 03:46 AM GMT



Please respond to [EMAIL PROTECTED]



To:   [EMAIL PROTECTED]
cc:(bcc: Doug Vos)
Subject:  [REBOL] 1000's of objects's in array - Works find for me... Re:




And, if each record is identical, then you can skip the objects altogether.
Instead, just map the record to variables as you need:

   set [field1 field2 field3 ...] record

Saves a lot of mem space

-Carl


At 11/30/99 04:34 PM -0500, you wrote:
>
>
>If you are talking simple objects - no embedded functions (in each object).
>
>I have scripts that do that every day with thousands of objects in a
>block/series.
>
>I read in a flatfile database with about  16 fields and 1900 records...
>converting to objects as I parse the data.
>
>Works great.
>
>So, my suggestion would be to just try it and see how large it will scale
>before you think it won't work.
>
>- doug
>






[REBOL] Encouraging functional programming Re:(9)

1999-12-01 Thread joel . neely

[EMAIL PROTECTED] wrote:
> 
> Hi,
> 
> I've been following this thread (though it goes over my head a bit) with
> interest, but with this one you guys have lost me! =)
> 
> First of all what are Fibonnacci numbers?
> 

A famous function used VERY frequently in programming as a kind of
Petri dish for experimenting with recursion.  You can find out all
sorts of interesting stuff about them by following the links from:

   
http://dir.yahoo.com/Science/Mathematics/Numerical_Analysis/Numbers/Fibonacci/

They're often described in terms of problems such as:

   Start with one pair of hypothetical newborn rabbits, which can
   produce another pair of offspring each month beginning with age
   one month (and never die of old age, because they're hypothetical!).
   How many pairs of rabbits do you have after N months?

Stepping by months, one get the series:

Month:  1  2  3  4  5  6   7   8   9  ...
Pairs:  1  1  2  3  5  8  13  21  34  ...

Mathematically (and programmatically) they can be defined by the
recurrence relation

F(0)   = 0
F(1)   = 1
F(n+2) = f(n) + f(n+1)   ; or any number of algebraically
 ; equivalent statements

Running the recurrence BOTH ways from the base values, one gets:

   n: ...  -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6  7  8 ...
F(n): ... -21 13 -8  5 -3  2 -1  1 0 1 1 2 3 5 8 13 21 ...

Computing science types have LOTS of fun inventing various ways to
compute these.

>
> Second, perhaps someone could explain to me what Ladislav's code does?
> 
> >
> > fib: func [first second n] [
> > either n = 1 [first] [
> > either n = 2 [second] [
> > fib second first + second n - 1
> > ]
> > ]
> > ]
> >
> > >> fib 1.0 1.0 100
> > == 3.54224848179262E+20
> >
> > Ladislav
> >

It uses tail recursion to accumulate up to the correct answer (for
positive n) starting with the correct answers for n=1 and n=2 in hand.
The initial answers are given in decimal! because the series rapidly
outgrows the range of integer! values (especially on 16- or 32-bit
boxes ;-).

Tracing out the calculation of F(6) using the above function, we get
the following, where the comments are showing what 'first and 'second
"really" are:

fib  1.0  1.0  6  ;  F(1) =  1.0  F(2) =  1.0
fib  1.0  2.0  5  ;  F(2) =  1.0  F(3) =  2.0
fib  2.0  3.0  4  ;  F(3) =  2.0  F(4) =  3.0
fib  3.0  5.0  3  ;  F(4) =  3.0  F(5) =  5.0
fib  5.0  8.0  2  ;  F(5) =  5.0  F(6) =  8.0

which last line returns 8.0, since n=2.  The recurrence relation says
to add a pair of consecutive terms to get the next one, so that's what
this function does, with arguments that always hold two consecutive
terms of the series.

For you trivia buffs, using Ladislav's function above with arguments of

fib 1.0 3.0 n

calculates another recursive series known as the Lucas numbers.

Ah, well, back to coding...

-jn-



[REBOL] Objects: Preventing Code Duplication Re:(2)

1999-12-01 Thread icimjs

Hi Ladislav,
you wrote:
>There are two problems with your solution:
>
>a) it is relying on the persistence of func-1, func-2, ..., which is not
>garanteed now (problem with indefinite extent and garbage collector...)

Where do you take that from? func-1 and func-2 are both referenced by
do-something, which is defined and implemented outside of the use context
in the global object. Since when does REBOL's garbage collector ignore that?

>b) the uninherited functions can access only the ancestor's attributes and
>not the descendant's

That depends on your implementation.

>
>I think the only reliable method is to define the uninherited functions
>outside of the object and submit them one more parameter - the object to
>operate on.
>

Again you emphasize reliable. What makes you think that indefinite extents
are unreliable?

Elan



[REBOL] Objects: Preventing Code Duplication Re:(2)

1999-12-01 Thread icimjs

Hi Ladislav,

I like what you did here. What it does not do, is prevent code duplication.
I copied the stuff as you wrote it into the REBOL console and added one
more, important expression after creating the object 'b:
>> b: make a [num: num + 1]

This additional expression was probe b

>> probe b

make object! [
num: 2
messages:
make object! [
get-num: func [
sent...
obj [object!]
param
][obj/num
]
]
]


Lo and behold, b contains the message object you assigned to a. What have
we gained?

The point of my example was to demonstrate that we could prevent some of
the code from 'a from getting duplicated in 'b by using use contexts. Your
example is very elegant, but fails to solve the problem.

Elan

At 12:19 PM 12/1/99 +0100, you wrote:
>An example code concerning inheritance of object messages:
>
>Rebol[
>Purpose: "Demonstrate non-copied object messages."
>]
>
>;Define the object without messages
>a: make object! [
>num: 1
>;Other non-message attributes here...
>messages: none
>]
>
>;Now define the messages, common for all descendants.
>;These are created only once
>;and aren't copied as long as
>;you don't change anything for a descendant...
>a/messages: make object! [
>;An example message
>get-num: func [
>;every message must have access to object to which it has been
>sent...
>obj [object!]
>;the room for message parameters...
>param
>] [
>;This is the body of the message
>obj/num
>]
>;Other messages here...
>]
>
>;Function to send messages, shouldn't be changed
>sm: func [obj [object!]  'message [word!] param [block!]] [
>do in obj/messages message obj param
>]
>
>;Now you can use the code like this:
>>> sm a get-num []
>== 1
>>> b: make a [num: num + 1]
>>> sm b get-num []
>== 2
>
>
>- Ladislav
>
>
>



[REBOL] Objects: Preventing Code Duplication Re:(2)

1999-12-01 Thread icimjs

Hi Ingo,

yes, you do get the same probe because the use context is hidden both in
the ancestor as well as the descendant. However, it remains available, as
you can easily determine by evaluating 

ancestor/do-something

which successfully evaluates both func-1 and func-2 in both ancestor and
descendant objects.

Elan

At 08:07 AM 12/1/99 +0100, you wrote:
>Hi Elan,
>
>are you sure it works the way you think? I'm only asking, because
>you get exactly the same output for:
>
>>> probe ancestor
>
>make object! [
>do-something: func ["this function will be inherited"][
>func-1 
>func-2
>]
>]
>>> probe descendant
>
>make object! [
>do-something: func ["this function will be inherited"][
>func-1 
>func-2
>]
>]
>
>and I would like it to work.
>
>
>regards,
>
>Ingo
>
>Those were the words of [EMAIL PROTECTED]:
>> Hi guys,
>> 
>> Sorry, can't remember all the names. Have little time. 
>> 
>> Someone observed that descendant objects inherit their ancestor object's
>> function implementations and variables. This leads to inflated code. The
>> following mechanism can be used to avoid inheriting some code. It uses use
>> contexts:
>> 
>> ancestor: make object! [
>>   do-something: none
>>   use [var-1 var-1 comment {more vars here} func-1 func-2 func-3 ] [
>> var-1: "this is var-1"
>> var-2: "this is var-2"
>> ;- more vars here ...
>> func-1: func ["extremely long function. don't inherit."] [ 
>>   print "func-1: tons of code here"
>> ]
>> func-2: func ["also extremely long function. don't inherit."] [ 
>>   print "func-2 tons of code here"
>> ]
>> do-something: func ["this function will be inherited"] [
>>   func-1
>>   func-2
>> ]
>>   ]
>> ]
>> 
>> descendant: make ancestor []
>> 
>> >> descendant/do-something
>> func-1: tons of code here
>> func-2 tons of code here
>> >> probe descendant
>> 
>> make object! [
>>   do-something: func ["this function will be inherited"][
>> func-1
>> func-2
>>   ]
>> ]
>> 
>> ;- Elan
>> 
>> 
>> 
>Hi Rebols,
>
>
>
>
>regards,
>
>Ingo
>
>--  _ ._
>ingo@)|_ /|  _| _  www./_|_) |o(_|(/_  We ARE all FREE> ingo@| |(_|o(_)| (_| 
>http://www.2b1.de/Rebol/ ._|  ._|
>
>
>



[REBOL] 1000's of objects's in array - Works fine for me... Re:(3)

1999-12-01 Thread icimjs

At 10:47 AM 12/1/99 -0500, you wrote:
>
>
>Please elaborate on this for process
> to handle standard comma delimited files (or tab delimited files)...

set [ x1 x2 x3 ... ] parse record ","

This presupposes that there are no commas contained in the fields. If you
may encounter fields that will include commas, were commas are not field
delimiters, usually I'd expect they occur in quoted strings:

"field-with-comma, something", "another field"

and the parse will be a little more complicated.

Elan

>
>Any more pointers on the words  set [ x1 x2 x3 x4 ... ] record
>
>I know about "set"  , but what is "record" is that a word or just your
>example value.
>

my guess is you're right, record indeed is an example, supposedly a string
that contains the contents of your comma delimited file, i.e. record: read
%commada-delimited-file.dat

Elan

>
>
>
>
>From: [EMAIL PROTECTED] on 12/01/99 03:46 AM GMT
>
>
>
>Please respond to [EMAIL PROTECTED]
>
>
>
>To:   [EMAIL PROTECTED]
>cc:(bcc: Doug Vos)
>Subject:  [REBOL] 1000's of objects's in array - Works find for me... Re:
>
>
>
>
>And, if each record is identical, then you can skip the objects altogether.
>Instead, just map the record to variables as you need:
>
>   set [field1 field2 field3 ...] record
>
>Saves a lot of mem space
>
>-Carl
>
>
>At 11/30/99 04:34 PM -0500, you wrote:
>>
>>
>>If you are talking simple objects - no embedded functions (in each object).
>>
>>I have scripts that do that every day with thousands of objects in a
>>block/series.
>>
>>I read in a flatfile database with about  16 fields and 1900 records...
>>converting to objects as I parse the data.
>>
>>Works great.
>>
>>So, my suggestion would be to just try it and see how large it will scale
>>before you think it won't work.
>>
>>- doug
>>
>
>
>
>
>
>



[REBOL] 1000's of objects's in array - Works fine for me... Re:(3)

1999-12-01 Thread carl

Here's how:

1. convert your data files (comma delim, or whatever) to blocks.
   You can use the script on www.rebol.com in user-lib to do it.

2. Now you can loop over the data easily with a foreach or a while
   loop.

Check out the example on the web site then ask a few questions here.
About 5 lines of code to do what you want.

-Carl


At 12/1/99 10:47 AM -0500, you wrote:
>
>
>Please elaborate on this for process
> to handle standard comma delimited files (or tab delimited files)...
>
>Any more pointers on the words  set [ x1 x2 x3 x4 ... ] record
>
>I know about "set"  , but what is "record" is that a word or just your
>example value.
>
>
>
>
>
>From: [EMAIL PROTECTED] on 12/01/99 03:46 AM GMT
>
>
>
>Please respond to [EMAIL PROTECTED]
>
>
>
>To:   [EMAIL PROTECTED]
>cc:(bcc: Doug Vos)
>Subject:  [REBOL] 1000's of objects's in array - Works find for me... Re:
>
>
>
>
>And, if each record is identical, then you can skip the objects altogether.
>Instead, just map the record to variables as you need:
>
>   set [field1 field2 field3 ...] record
>
>Saves a lot of mem space
>
>-Carl
>
>
>At 11/30/99 04:34 PM -0500, you wrote:
>>
>>
>>If you are talking simple objects - no embedded functions (in each object).
>>
>>I have scripts that do that every day with thousands of objects in a
>>block/series.
>>
>>I read in a flatfile database with about  16 fields and 1900 records...
>>converting to objects as I parse the data.
>>
>>Works great.
>>
>>So, my suggestion would be to just try it and see how large it will scale
>>before you think it won't work.
>>
>>- doug
>>
> 



[REBOL] Reminder Re:(7)

1999-12-01 Thread KSMiTH


- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 01, 1999 12:43 AM
Subject: [REBOL] Reminder Re:(6)


> Time flys when writing REBOL... :-)

/me gets out a stopwatch

Kat ;-)
 





[REBOL] Objects: Preventing Code Duplication Re:(2)

1999-12-01 Thread icimjs

At 12:48 PM 12/1/99 +0100, you wrote:
>[EMAIL PROTECTED] wrote:
>
>> It uses use
>> contexts:
>
>To avoid problems with the garbage collector, my hide.r show work
>fine here.

Hi Gabriele, what is hide.r and where do I get it?

Elan



[REBOL] Valid e-mail addresses Re:

1999-12-01 Thread sterling


Do this:
trace/net on
smtp-port: open smtp://you.mail.server
you'll see you just got logged in to the SMTP server
and then just use:
insert smtp-port "your command"

Sterling

> Hi
> 
> A question:
> 
> Using REBOL
> How can I test if the username  has a mailbox at the  e-mail server?
> 
> In other words: how can I test if @ is a valid e-mail address?
> (Of course I don't know the password)
> 
> In other words: how can I send a VRFY SMTP command to a e-mail port?
> 
> Thank you



[REBOL] Objects: Preventing Code Duplication Re:(3)

1999-12-01 Thread lmecir

Hi, Elan. You wrote:

Hi Ladislav,

I like what you did here. What it does not do, is prevent code duplication.
-
It really does, see later...
-
I copied the stuff as you wrote it into the REBOL console and added one
more, important expression after creating the object 'b:
>> b: make a [num: num + 1]

This additional expression was probe b

>> probe b

make object! [
num: 2
messages:
make object! [
get-num: func [
sent...
obj [object!]
param
][obj/num
]
]
]


Lo and behold, b contains the message object you assigned to a. What have
we gained?

--
We have gained a lot. CF:

>no-copying: same? get in a 'message get in b 'message
==true
>no-copying: same? get in a/message 'get-num get in b/message 'get-num
==true



The point of my example was to demonstrate that we could prevent some of
the code from 'a from getting duplicated in 'b by using use contexts. Your
example is very elegant, but fails to solve the problem.

---
Again, it does 8^)

Ladislav
---

Elan

At 12:19 PM 12/1/99 +0100, you wrote:
>An example code concerning inheritance of object messages:
>
>Rebol[
>Purpose: "Demonstrate non-copied object messages."
>]
>
>;Define the object without messages
>a: make object! [
>num: 1
>;Other non-message attributes here...
>messages: none
>]
>
>;Now define the messages, common for all descendants.
>;These are created only once
>;and aren't copied as long as
>;you don't change anything for a descendant...
>a/messages: make object! [
>;An example message
>get-num: func [
>;every message must have access to object to which it has been
>sent...
>obj [object!]
>;the room for message parameters...
>param
>] [
>;This is the body of the message
>obj/num
>]
>;Other messages here...
>]
>
>;Function to send messages, shouldn't be changed
>sm: func [obj [object!]  'message [word!] param [block!]] [
>do in obj/messages message obj param
>]
>
>;Now you can use the code like this:
>>> sm a get-num []
>== 1
>>> b: make a [num: num + 1]
>>> sm b get-num []
>== 2
>
>
>- Ladislav
>
>
>





[REBOL] Objects: Preventing Code Duplication Re:(4)

1999-12-01 Thread lmecir

Sending a more commented version of Methods.

Have fun.

Ladislav

Rebol[
Title: "Methods"
Author: Ladislav Mecir
Email: [EMAIL PROTECTED]
Date: 1/12/1999
Version: 2.0.0
Purpose: "Code to prevent method code copying."

Comment:

It works as follows:

if an object ANOBJECT contains a function attribute FNC,
then if you create a copy of it with:
OTHEROBJECT: MAKE ANOBJECT [],
the code of FNC gets copied in Rebol, because OTHEROBJECT/FNC
must have access to the OTHEROBJECT's attributes, so Rebol
BIND's the OTHEROBJECT/FNC's code to the OTHEROBJECT's context

Rebol works differently, if object's attribute is of type OBJECT!.
In that case it does not copy the attribute, but instead it uses the
same
object (to preserve the memory?).

When we prevented the method code copying,
we must make sure the method has the access
to the object's attributes it operates on.

But that is easy - see later...

}
]

;Define the object like this:
example: make object! [
num: 1
;Other data attributes here...
;Now define the methods, common for all descendants.
;These are created only once
;and aren't copied,
;which means that there is only one copy of them in the computer memory.
methods: make object! [
;An example method
ex-method: func [
;every method must have access
;to object to which it has been sent
self [object!]
;the room for other method parameters...
param
] [
;This is the body of the method
self/num
]
;Other methods here...
]
]


;Function to call methods
!: func [self [object!]  'method [word!] param] [
do in self/methods method self param
]

;Now you can use the code like this:
>> ! example ex-method []
== 1
>> b: make example [num: num + 1]
>> ! b ex-method []
== 2
>> no-copying: same? get in example 'methods get in b 'methods
== true
>> no-copying: same? get in example/methods 'ex-method get in b/methods
'ex-method
== true




[REBOL] Encouraging functional programming Re:(3)

1999-12-01 Thread bo


Joel,

I have added this as Enhancement Request 2.2.0.118.

Thanks for your suggestions!  I personally like them.

-Bo
-- 

On 29-Nov-1999/8:35:07-6:00, [EMAIL PROTECTED] wrote:
>[EMAIL PROTECTED] wrote:
>> 
>> Let's see how it performs on a structure that is naturally recursive:
>> 
> nice code and stack crash deleted ...
>> 
>> But:
>> 
> more deletions ...
>> 
>> 140 levels can hold maximum 2139 + 2138 + ... + 20 elements...
>> 
>> I think running out of memory is a bigger problem than running out of
>> stack space ! :))
>> 
>
>EXCEPT that sometimes a recursive structure is composed from input
>data not under the control of the programmer!  For example, building
>a sort tree from pathologically ordered data can produce a 140-level
>tree that contains only 141 leaves.
>
>Of course the program can be re-written to continually rebalance the
>tree, but means that the programmer is having to make a more complex
>program to work around a limitation of the implementation -- NOT a
>very friendly solution for the casual (or novice) programmer.
>
>CONCRETE SUGGESTIONS:  Why not allow the programmer or user some more
>control over stack size?  I suggest that REBOL would benefit from:
>
>1)  A command-line argument allowing the stack size to be set to a
>supplied value.  On a larger box, one could simply make the size
>bigger to allow deeper recursion.  (As a side note, I recently
>found that I could nest recursive calls deeper under w95 than
>under Solaris, even though the Sun box had WAY more RAM.
>("What a rebolting development THAT is!")
>
>2)  A primitive function allowing running code to query the amount
>of total and free stack space.  This would enable a script to
>predict an impending stack crash and take preventive action,
>rather than simply detecting the crash after the fact.
>It would also be nice to have the same capabilitiy(ies) for
>heap/string space, but I'm assuming more than I know about the
>implementation of REBOL.  ;-)
>
>3)  In the best of all possible worlds, REBOL would have both of
>the above, PLUS a function to grow the stack/heap/whatever by
>a specified amount of memory.  Of course that function would
>fail gracefully if the environment didn't have sufficient
>resources to let the interpreter grow.
>
>How about it, REBOL wizards?  I realize that these may be non-trivial
>changes (depending on how the interpreter is built) but I believe they
>offer some real value, both to those of us who occasionally write
>quick-and-dirty code and to those who deal with really complex or
>large data structures.
>
>-jn-
>
-- 
   Bohdan "Bo" Lechnowsky
   REBOL  Adventure Guide
   REBOL Technologies 707-467-8000 (http://www.rebol.com)
  Download the REBOL Messaging Language for all Platforms



[REBOL] 1000's of objects's in array - Works fine for me... Re:(4)

1999-12-01 Thread BSchneider

Hi,

Actually, I just tried the following:

>> blk: {String 1,"String, 2",string 3}
== {String 1,"String, 2",string 3}
>> set [var1 var2 var3] parse/all blk ","
== ["String 1" "String, 2" "string 3"]
>>

Apparently, REBOL's 'parse word does a little extra here with embedded
commas in quoted strings. It appears to work with other separator characters
also.

Regards,


Bernie Schneider
Systems Analyst
CIBER, Inc.
303-224-4159
[EMAIL PROTECTED]

> -Original Message-
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, December 01, 1999 10:40 AM
> To:   [EMAIL PROTECTED]
> Subject:  [REBOL] 1000's of objects's in array - Works fine for  me...
> Re:(3)
> 
> At 10:47 AM 12/1/99 -0500, you wrote:
> >
> >
> >Please elaborate on this for process
> > to handle standard comma delimited files (or tab delimited files)...
> 
> set [ x1 x2 x3 ... ] parse record ","
> 
> This presupposes that there are no commas contained in the fields. If you
> may encounter fields that will include commas, were commas are not field
> delimiters, usually I'd expect they occur in quoted strings:
> 
> "field-with-comma, something", "another field"
> 
> and the parse will be a little more complicated.
> 
> Elan
> 
> >
> >Any more pointers on the words  set [ x1 x2 x3 x4 ... ] record
> >
> >I know about "set"  , but what is "record" is that a word or just
> your
> >example value.
> >
> 
> my guess is you're right, record indeed is an example, supposedly a string
> that contains the contents of your comma delimited file, i.e. record: read
> %commada-delimited-file.dat
> 
> Elan
> 
> >
> >
> >
> >
> >From: [EMAIL PROTECTED] on 12/01/99 03:46 AM GMT
> >
> >
> >
> >Please respond to [EMAIL PROTECTED]
> >
> >
> >
> >To:   [EMAIL PROTECTED]
> >cc:(bcc: Doug Vos)
> >Subject:  [REBOL] 1000's of objects's in array - Works find for me... Re:
> >
> >
> >
> >
> >And, if each record is identical, then you can skip the objects
> altogether.
> >Instead, just map the record to variables as you need:
> >
> >   set [field1 field2 field3 ...] record
> >
> >Saves a lot of mem space
> >
> >-Carl
> >
> >
> >At 11/30/99 04:34 PM -0500, you wrote:
> >>
> >>
> >>If you are talking simple objects - no embedded functions (in each
> object).
> >>
> >>I have scripts that do that every day with thousands of objects in a
> >>block/series.
> >>
> >>I read in a flatfile database with about  16 fields and 1900 records...
> >>converting to objects as I parse the data.
> >>
> >>Works great.
> >>
> >>So, my suggestion would be to just try it and see how large it will
> scale
> >>before you think it won't work.
> >>
> >>- doug
> >>
> >
> >
> >
> >
> >
> >



[REBOL] Re: 1000's of objects's in array - Works fine for me... Re:(3)

1999-12-01 Thread dm98411

Hello [EMAIL PROTECTED],

On 01-Dec-99, [EMAIL PROTECTED] wrote:

> At 10:47 AM 12/1/99 -0500, you wrote:
>> 
>> 
>> Please elaborate on this for process
>> to handle standard comma delimited files (or tab delimited files)...
> 
> set [ x1 x2 x3 ... ] parse record ","
> 
> This presupposes that there are no commas contained in the fields. If you
> may encounter fields that will include commas, were commas are not field
> delimiters, usually I'd expect they occur in quoted strings:
> 
> "field-with-comma, something", "another field"
> 
> and the parse will be a little more complicated.
-snip-

not really:

## db: {name1,test1,"name,with,comma",test2,name3,test3}
== {name1,test1,"name,with,comma",test2,name3,test3}
## parse db none
== ["name1" "test1" "name,with,comma" "test2" "name3" "test3"]


Best regards
Thomas Jensen



[REBOL] re: Sorting thousands of objects vs. sorting thousands of complex blocks

1999-12-01 Thread lnusrn1 . bz3r4j




To:   [EMAIL PROTECTED]
cc:
From: Doug Vos
Date: 12/01/99 05:50:49 PM
Subject:  Re: [REBOL] 1000's of objects's in array - Works fine for me... Re:(3)

Please don't jump to conclusions.
I read in 1000's of records in tab delimited format every day (with rebol).
So I am not asking how to do it.
Since I aleady do it every day and my scripts sort and filter thousands of
records.

My question was based on looking for a better way to do it...

Perhaps I have a lot of code here with objects that
 I can eliminate, now that I have read the "beta-2.2/manual"
and know how to sort blocks by any field.

Previously I wrote all this code because I like sorting objects by the object
/attribute.
You can sort by any attibute and it is very easy to implement EASY is the
key word here.
It was very easy for me to sort objects and I had no method to sort complex
blocks...
... so that is why I went off on the tangent I did.

There is a great section in the "manual/sersort.html" about sorting
series/blocks
Specifically there is a section with a function called "record-sort"
I won't repeat the code here... see the function called "record-sort"

I am not sure that it will sort any faster or make the program run any faster.
Because I already have a script that reads 2100 or more records and builds
webpages in a few seconds.
But...my point was  that I am always looking for a way to eliminate code and
make things smaller
and maybe faster.  I think Carl is saying that there is an easier and better way
to do it
I am including a few of my routines here.
The function make-objects reads in all the lines and seperate the fields
(parsing for each tab.)

I think what Carl is saying is that I should not use objects and rather than
parse with the tab character just set the values using a SET or COMPOSE or
something
like that???

So, I guess I should not be doing parse/all {^(tab)}?? and then just
just convert the block directly to field names???

So I would possibly change it from "foreach case cases"
to..

foreach [ case-num site-name city severity
   agreement user-name user-phone etc ] cases [

   do the stuff here
   that I normally do
]

And since each record is tab-delimited I can just handle it that way
without parsing the tabs and corverting to items/objects...

Is that what Carl is talking about??

I think so, but I wish he would provide more examples of how he (or BO or
someone at REBOL) would recommend doing it..Since they wrote the
language and know why and how they put certain functions in "R".

;
make-objects: function [
   "Returns the list/array of ticket objects (cases) from file."
   from-file
   o-cases
][
   cases o-case items
][
   cases: read/lines from-file  ; each record/line is a case and will become an
object.

   foreach case cases [
   items: parse/all case {^(tab)}   ; each field is tab delmited

   ; skip the header records
   ; skip the canadian records
   if items/5 = "United States" [
  o-case:  case-object items
  append o-cases o-case
   ]

   ] ; end of foreach loop

   return o-cases
]
;
case-object: function [
   items
][
   o-case
][
   o-case: make object! [
   case-num: site-name: none
   city: severity: agreement: user-name: user-phone: none
   queue: assigned-to: product: svc-type: none
   status: summary: date-opened: days-open: last-inbox: none
   ]

   o-case/case-num: items/1
   o-case/site-name:items/4

   o-case/city: items/6
   o-case/severity: items/8
   o-case/agreement:items/9
   o-case/user-name:items/10

   either (substring items/11 1 3) = "01 " [
   o-case/user-phone: substring items/11 4 (length? items/11 )
   ][
  either (substring items/11 1 2) = "1 " [
 o-case/user-phone: substring items/11 2 (length? items/11 )
  ][
 o-case/user-phone: items/11
  ]
   ]

   o-case/queue:items/12
   o-case/assigned-to:  items/13
   o-case/product:  items/14
   o-case/svc-type: first parse items/9 none

   o-case/status:   items/18
   o-case/summary:  items/19
   o-case/date-opened:  to-rebol-date items/20

   o-case/days-open:calc-days o-case/date-opened
   ;o-case/days-open:to-integer items/22
   ; adjust for the fact that extract is run previous night
   ; --but people are viewing the next day
   ;o-case/days-open: o-case/days-open + 1

   o-case/last-inbox:   if value? items/23 [items/23]

return o-case
]
;


























From: [EMAIL PROTECTED] on 12/01/99 05:30 PM GMT



Please respond to [EMAIL PROTECTED]



To:   [EMAIL PROTECTED]
cc:(bcc: Doug Vos)
Subject:  [REBOL] 1000's of objects's in array - Works fine for  me... Re:(3)




Here's how:

1. convert your data files (comma de

[REBOL] A very cool tool for HTML documenting rebol scripts (that will make you drool.)

1999-12-01 Thread lnusrn1 . bz3r4j



OO!! Tooo  many oo's round here.

Any way here is a cool self-generating HTML table make I wrote
that demonstrated some of the cool things you can do with objects
but also helps investigate the same topic of arrays of objects...

This script works great for building tables of up to several hundred rows.

To try it out set the path to your current REBOL directory.
Also set the path to where you want the HTML output to go.
It will attempt to write a file called "test-vlib.htm"

I am tossing this script out as a discussion starter...

Check out how it self gens the HTML at the bottom.
With this same technique, you can build HTML tables very quickly
...however, it may be a memory hog..accoding to recent discussions
. but who cares since it works so cool

The self-gen table calls a self-gen row which calls a self-gen data-cell...
And you can use it for a lot more than just documenting REBOL scripts...

By the way... the current version is 0.1.0 because it blows up on invalid
rebol headers. Need to try the "try" function on the various header elements...
;;
REBOL [
 Title:  "vHTML Objects"
  Date:  30-Nov-1999
   Version:  0.1.0
Author:  "Doug Vos"
 Email:  [EMAIL PROTECTED]
  File:  %vhtml-lib3.r
   Purpose:  { A library or collection of objects and functions for html...}
]

new-table: func [
   {Create a new, empty html table object.
Assign the table a unique id upon creation for later reference.}
   t-id [string!]
][
   make object! [
   align:   "center"
   bgcolor: #ff
   border:  0
   caption: none
   cellspacing: 0
   cellpadding: 1
   id:  t-id
   otype:   "table"
   row: make block! 1000
   width:   "100%"
   html:""
   append-row: func [
   "Create html rows out of a series"
   a-data
   /local xdata tdata
   ][
   tdata: make block! 100
   foreach xdata a-data [
   append tdata new-td xdata
   ]
   append row new-tr tdata
   ]
   ;--
   self-gen:   func [
   /local xrow
   ] [
   html: rejoin [ html
  build-tag [
 table
align   (align)
bgcolor (bgcolor)
border  (border)
cellspacing (cellspacing)
cellpadding (cellpadding)
width   (width)
  ]
  newline
   ]
   if not (none? caption) [
  html: rejoin [html  caption  newline ]
   ]
   foreach xrow row [
  html: rejoin [html xrow/self-gen ]
   ]

   html: rejoin [ html  newline ]

 ];self-gen
  ];object
];new-table
;-
new-tr: func [
   {Create a new table ROW object.}
   d-cells
][
   make object! [
   otype:"tr"
   cell:d-cells
   html: ""
   self-gen: func [
   /local td
   ] [
   html: rejoin [ html  newline ]

   foreach td cell [
  html: rejoin [html td/self-gen ]
   ]
   html: rejoin [html  newline ]
   ] ;self-gen
   ] ;make
] ;new-tr
;-
;-
new-td: func [
   {Create a new data element TD object.}
   t-data
][
   make object! [
   align:"center"
   bgcolor:  #ff
   valign:   "middle"
   data: t-data
   otype:"td"
   html: "  "
   self-gen: func [] [
   html: rejoin [
   html
   build-tag [
  td
  align   (align)
  bgcolor (bgcolor)
  valign  (valign)
   ]
   data  newline
   ]
  ] ;self-gen
   ] ;make
]
;
;

table: new-table "rebol/dir"
table/caption: "The REBOL Directory"
table/border: 1

table/append-row [
   "File Name" "Size"  "Date / Time" "Title / Purpose
" "Author"
]

path:  "/c/rebol/new/"
files: read to-file path
files: sort files

inc: 2

foreach file files [
   print file
   xfile: to-file rejoin [path file]
   info:  info? to-file rejoin [path file]
   either find/match/any file "*.r" [
  xhead: first load/header xfile
  xtpur: rejoin [ " "  xhead/title   xhead/purpose ]
  table/append-row [ (file) info/size info/date (xtpur) xhead/author ]
  table/row/:inc/cell/1/bgcolor: "yellow"
   ][
  table/append-row [(file) info/size info/date " " " " ]
  table/row/:inc/cell/4/bgcolor: "gray"
  table/row/:inc/cell/5/bgcol

[REBOL] 1000's of objects's in array - Works fine for me... Re:(5)

1999-12-01 Thread icimjs

Hi,

you're both right. I'd first tried it with parse/all, where it did make a
difference. Then I realized that I didn't want the /all refinement but
didn't test it again. So, I reported the behavior with the /all refinement
but included the code w/o /all.

Elan




[REBOL] A very cool tool for HTML documenting rebol scripts (that will make you drool.) Re:

1999-12-01 Thread lnusrn1 . bz3r4j



The reason I put that example code out there
was I thought it tied in really well with the 2 recent discussions.

1. 1000's of objects in an array
2. Functional vs. procedural vs. OO programming styles.

The third reason is that even after I make something,
I find out 2 months later that it can be greatly improved.

Wonder what are all the things wrong you can find with this code
Go back to cool/tool/drool message number 0001.

I already know it embeds the self-gen func in all objects,
but so what? Do you know how to improve it??





[REBOL] Multiple Rebol Shells on MacOS

1999-12-01 Thread mark

Is it possible to open multiple rebol shells on the Mac?

Thanks,

Mark 



[REBOL] Multiple Rebol Shells on MacOS Re:

1999-12-01 Thread Andrew . M . Grossman

--- [EMAIL PROTECTED] wrote:
Is it possible to open multiple rebol shells on the Mac?
--- end of quote ---

You would probably need to make multiple copies of the application itself.  

--
Andrew Grossman
http://web.dartmouth.edu/~grossman/pgp.html



[REBOL] A very cool tool for HTML documenting rebol scripts (that will make you drool.) Re:

1999-12-01 Thread Al . Bri

Actually, I was hoping that you've implemented:

Table [
"Top Left" "Top Center" "Top Right"
"Left" "Right"
"Bottom"
]

Andrew Martin
Making Magic on Web_Dialect...
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-



[REBOL] Objects: Preventing Code Duplication Re:(3)

1999-12-01 Thread lmecir

Hi, Elan, you wrote:

I copied the stuff as you wrote it into the REBOL console and added one
more, important expression after creating the object 'b:
>> b: make a [num: num + 1]

This additional expression was probe b

>> probe b

make object! [
num: 2
messages:
make object! [
get-num: func [
sent...
obj [object!]
param
][obj/num
]
]
]


--
If still not convinced, try this:

>> a/messages/get-num: "8^)"
== "8^)"
>> probe b

No copy can behave like that...

-Ladislav





[REBOL] Objects: Preventing Code Duplication Re:(4)

1999-12-01 Thread icimjs

Hi Ladislav,

you wrote:

>We have gained a lot. CF:
>
>>no-copying: same? get in a 'message get in b 'message
>==true
>>no-copying: same? get in a/message 'get-num get in b/message 'get-num
>==true

I see what you mean. I'd call it a bug ... When objects are inherited,
objects they contain should not be treated any different than other
datatypes. If all other datatypes are copied, they should be copied as
well. Inconsistencies and exceptions tend to become a source for bugs.

I do, however, appreciate this bug as a feature, because I like your
approach. 

1. One thing that disturbs me, though, is that you have to include the
object in each function you create. Passing the object to the function
doesn't bother me because that is being handled by your message-passing
function. But implementing each function with an argument reserved for the
object, that's repetetive and tedious.

Of course this can be easily rectified by modifying the root object and the
! function:

root: make object! [
  methods: make object! [
object: none
get-var: func [] [  print object/var return object/var ]
  ]
]

!: func [object [object!] 'method parm ] [
  set in object/methods 'object object
  do get in object/methods method parm
]

>> o: make root [var: 1]
>>
>> ! o get-var []
1
== []
>>

2. The second thing that really bothers me is the stupid dummy parm and the
fact that multiple arguments have to be passed in a block, because the
function ! can't tell in advance whether the called function expects any
arguments, and if so how many. 

Besides passing dummy values, when the called function does not process
them, the called function also has to require a dummy value it doesn't need
in order to consume the dummy value. If you forget to include the dummy
value in the functions interface, then a value that function returns is
lost and replaced by the dummy value, because the value the function !
evaluates to will be the dummy value that was not consumed:

>> result: ! o get-var []
1
== []
>> print result

>> type? result
== block!

That kind of bug is difficult to detect.

I'd rather be able to 
a) use the full range of function features, including returning values and
b) not have to include a dummy argument in every function to consume the
dummy argument being passed to the function !.
c) Be able to pass multiple values individually rather then in a block and
d) not have to extract values from the block they were passed in.

The only way I have so far figured out to do that is by removing !'s parm
and replacing !'s do by return. Instead of executing the function, ! now
returns it. It can be executed at the same level as the ! function call was
evaluated and therefore any remaining arguments at that level will be
consumed by the retrieved function, if it requires arguments. The ugly side
to this approach is that you now must enter do explicitly:

!: func [object [object!] 'method ] [
  set in object/methods 'object object
  return get in object/methods method 
]

>> do ! o get-var
1
== 1

That's not pretty either. But given the limited choices, I prefer to
preserve REBOL's standard argument passing convention and avoid bugs by not
prescribing that dummy arguments be passed and consumed, when a function
does not need them.

3. Hiding root functions and variables is not addressed by the embedded
object mechanism you proposed. The words defined in the methods sub-object
can all be messed with. Using contexts would solve that problem. Do you
recall 
a) whether the reported instability of indefinite extended local words in
contexts was detected in the current REBOL version (2.2)?
b) Was it reported as an error, and
b) what observations led to the conclusion that it is the garbage collector?

TIA,

Elan