Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How to load func defs at start-up

 [1/4] from: tim::johnsons-web::com at: 18-Sep-2000 8:39


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

 [2/4] from: civicminded4::yahoo 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&nbsp;;protect system words from redefinition with all of my utilities</P> <P>set-net-cases: [<BR>&nbsp;1&nbsp;[[aparman--netzero--net] smtp.netzero.net pop.netzero.net none none none ]<BR>&nbsp;2&nbsp;[[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>&nbsp;print [number tab case]<BR>]<BR>set-net account: select set-net-cases choice: to-integer ask "Enter your number choice here :>> "</P> <P>&nbsp;</P> <P>&nbsp;system/console/prompt: "REBOL:>> "<BR>&nbsp;system/console/result: "REBOL:== "</P> <P>&nbsp;</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&nbsp; ["It is" now/date "at" now/time "."]<BR>print&nbsp; ["You are currently in the" what-dir&nbsp; "directory." newline]<BR>print&nbsp; ["The following are your scripts loaded with utilities.r" newline]</P> <P>do %./utilities/utilities.r&nbsp; ; 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>&nbsp;title:&nbsp;&nbsp;"My Utilities"<BR>&nbsp;file:&nbsp;&nbsp;%utilities.r<BR>&nbsp;purpose:&nbsp;"Things I want available."<BR>&nbsp;date:&nbsp;&nbsp;"22-May-2000/10:43:36-4:00"<BR>]</P> <P>&nbsp;</P> <P>; scripts I want available</P> <P>;--------make 'symlinks' to directory functions------------------------<BR>list:&nbsp;:list-dir<BR>pwd:&nbsp;:what-dir<BR>cd:&nbsp;:change-dir<BR>md:&nbsp;: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>&nbsp; <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--

 [3/4] from: tim:johnsons-web at: 18-Sep-2000 13:08


Thank you! You are indeed civic minded :) regards Tim [civicminded4--yahoo--com] wrote:

 [4/4] from: brett:codeconscious at: 19-Sep-2000 12:58


I'll just add that I do very similar to this but I try to put all my additions in another script called ConfigureSession.r which resides in a data directory (for ease of backing up my volatile configuration). ConfigureSession.r then sets words and calls utility scripts. Doing this allows the same configuration for Core and View. Brett. ----- Original Message ----- From: [civicminded4--yahoo--com] To: [list--rebol--com] Sent: Tuesday, September 19, 2000 5:56 AM Subject: [REBOL] How to load func defs at start-up Re: 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