[REBOL] How to load func defs at start-up Re:
From: civicminded4:ya:hoo at: 18-Sep-2000 12:56
--0-35005211-969307001=:16500
Content-Type: text/plain; charset=us-ascii
Following inline is my %user.r, followed by my %utilities.r script.
All of the functions listed in utilities are then available to me during the session.
*****************start user.r****************************
REBOL [
Title: "User Preferences"
Date: 28-Aug-2000
]
protect-system ;protect system words from redefinition with all of my utilities
set-net-cases: [
1 [[aparman--netzero--net] smtp.netzero.net pop.netzero.net none none none ]
2 [[civicminded4--yahoo--com] smtp.mail.yahoo.com pop.mail.yahoo.com none none none]
]
print "Which net account do you want to use?"
foreach [number case] set-net-cases [
print [number tab case]
]
set-net account: select set-net-cases choice: to-integer ask "Enter your number choice
here :>> "
system/console/prompt: "REBOL:>> "
system/console/result: "REBOL:== "
;--------utilities to do each time----------------
; keep the utilities folder as a subfolder of where the executable is i.e. %./utilities
;----------------------------greeting-------------------
print "***************************************************************"
Print "Hello, Alan!"
print ["It is" now/date "at" now/time "."]
print ["You are currently in the" what-dir "directory." newline]
print ["The following are your scripts loaded with utilities.r" newline]
do %./utilities/utilities.r ; put utilities in utilities folder and call them in %utilities.r
*****************end of user.r**************************************************
*****************start utilities.r**************************************************
REBOL[
title: "My Utilities"
file: %utilities.r
purpose: "Things I want available."
date: "22-May-2000/10:43:36-4:00"
]
; scripts I want available
;--------make 'symlinks' to directory functions------------------------
list: :list-dir
pwd: :what-dir
cd: :change-dir
md: :make-dir
;-----a few simple shortcuts-------
cls: does [prin ["^(1B)[J"]] ; this clears the screen
;---------my utilities--------------
do %../utilities/ls.r
do %../utilities/mail.r
do %../utilities/convert-lines.r
do %../utilities/makehead.r
do %../utilities/s-swap.r
***********end user.r***************************
Hope this helps.
[tim--johnsons-web--com] wrote:
Hi:
How may I load function definitions at startup?
As an experiment, I added the following function def
to both user.r and rebol.r:
import: func[{"do" a file (IMPORT function def}f[string!]]
[do make file! f]
However, upon starting rebol, rebol does not recognize
it.
I note also, that set-user is not recognized.
Just curious...
TIA
Tim
--0-35005211-969307001=:16500
Content-Type: text/html; charset=us-ascii
<P> Following inline is my %user.r, followed by my %utilities.r script.</P>
<P>All of the functions listed in utilities are then available to me during the session.</P>
<P>*****************start user.r****************************</P>
<P>REBOL [<BR>Title: "User Preferences"<BR>Date: 28-Aug-2000<BR>]</P>
<P>protect-system ;protect system words from redefinition with all of my utilities</P>
<P>set-net-cases: [<BR> 1 [[aparman--netzero--net] smtp.netzero.net pop.netzero.net
none none none ]<BR> 2 [[civicminded4--yahoo--com] smtp.mail.yahoo.com pop.mail.yahoo.com
none none none]<BR>]</P>
<P>print "Which net account do you want to use?"<BR>foreach [number case] set-net-cases
[<BR> print [number tab case]<BR>]<BR>set-net account: select set-net-cases choice:
to-integer ask "Enter your number choice here :>> "</P>
<P> </P>
<P> system/console/prompt: "REBOL:>> "<BR> system/console/result: "REBOL:==
"</P>
<P> </P>
<P>;--------utilities to do each time---------------- <BR>; keep the utilities folder
as a subfolder of where the executable is i.e. %./utilities</P>
<P>;----------------------------greeting-------------------<BR>print "***************************************************************"<BR>Print
"Hello, Alan!"<BR>print ["It is" now/date "at" now/time "."]<BR>print ["You
are currently in the" what-dir "directory." newline]<BR>print ["The following
are your scripts loaded with utilities.r" newline]</P>
<P>do %./utilities/utilities.r ; put utilities in utilities folder and call them
in %utilities.r</P>
<P>*****************end of user.r**************************************************</P>
<P>*****************start utilities.r**************************************************</P>
<P>REBOL[<BR> title: "My Utilities"<BR> file: %utilities.r<BR> purpose: "Things
I want available."<BR> date: "22-May-2000/10:43:36-4:00"<BR>]</P>
<P> </P>
<P>; scripts I want available</P>
<P>;--------make 'symlinks' to directory functions------------------------<BR>list: :list-dir<BR>pwd: :what-dir<BR>cd: :change-dir<BR>md: :make-dir</P>
<P>;-----a few simple shortcuts-------<BR>cls: does [prin ["^(1B)[J"]] ; this clears
the screen</P>
<P>;---------my utilities--------------<BR>do %../utilities/ls.r<BR>do %../utilities/mail.r<BR>do
%../utilities/convert-lines.r<BR>do %../utilities/makehead.r<BR>do %../utilities/s-swap.r</P>
<P>***********end user.r***************************</P>
<P>Hope this helps.<BR></P>
<P> <B><I>[tim--johnsons-web--com]</I></B> wrote: <BR>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi:<BR>How
may I load function definitions at startup?<BR>As an experiment, I added the following
function def<BR>to both user.r and rebol.r:<BR>import: func[{"do" a file (IMPORT function
def}f[string!]]<BR>[do make file! f]<BR><BR>However, upon starting rebol, rebol does
not recognize<BR>it.<BR><BR>I note also, that set-user is not recognized.<BR><BR>Just
curious...<BR>TIA<BR>Tim<BR></BLOCKQUOTE>
--0-35005211-969307001=:16500--