Why cant mutually exclusive refinements have the same argument name
[1/6] from: princepawn::lycos::com at: 5-Sep-2000 8:03
I have a function that will either get or put a filename... of course I want to use the
same name for the file regardless, and this will not pose a problem because the arguments
are mutually exclusive.
However, REBOL is complaining about me using the same name for 2 mutually exclusive arguments
REBOL [ Title: "Main script" ]
main: func [ "Performs order file transfer"
/name-product product-name [string!] "The product name"
/index-upfile upfile-index [integer!] "The index to be used for the upfile. Useful when
you have many upfiles and don't want to overwrite a previous one."
/put orderfile-name [string!] "Put an orderfile on our server"
/get orderfile-name [string!] "Put an orderfile on our server"
/date-upfile upfile-date [date!] "The date to be encoded into the upfile name"
/create-upfile upfile-name [string!] "This automatically creates and upfile. The argument
to this option is the word 'cancel' or 'nocancel', specifying whether you want the upfile
to contain a cancel or nocancel command"
/wait-on-controlfile controlfile-wait-time [time!] "Specifies the localtime that the
script will continue to try to look for the control file until. This option can only
be used with the /get option"
] [ ]
[2/6] from: allen:rebolforces at: 6-Sep-2000 1:51
----- Original Message -----
From: <[princepawn--lycos--com]>
To: <[list--rebol--com]>
Cc: <[feedback--rebol--com]>
Sent: Wednesday, September 06, 2000 1:03 AM
Subject: [REBOL] Why cant mutually exclusive refinements have the same
argument name
> I have a function that will either get or put a filename... of course I
want to use the same name for the file regardless, and this will not pose a
problem because the arguments are mutually exclusive.
> However, REBOL is complaining about me using the same name for 2 mutually
exclusive arguments
Since all the refinements can be used, how would REBOL know that you mean
them to be mutually excusive? (or for that matter how would anyone else
using your function know that)
If it is mutally exclusive, a better approach would be to use a single
refinement with two parameters.
/file orderfile-name [file!] method "Put an orderfile on our server"
e.g
main/file %this.txt 'put
main/file %this.txt 'get
Cheers,
Allen K
[3/6] from: ptretter:charter at: 5-Sep-2000 10:51
Looks like you will have to use a differnet argument for either /put or /get
refinements. Then possibiy incorporate the Copy function into the body of
the function if necessary. You may want to perform some logical operators
on the /put or /get refinements and just pass the filename as a separate
argument or as a seperate /refinement argument.
Paul Tretter
[4/6] from: alex:pini:mclink:it at: 5-Sep-2000 22:49
>- Open Your Mind -<
Quoting from [princepawn--lycos--com's] message (05-Sep-00 17:03:50).
p> I have a function that will either get or put a filename... of course I want to use
the same name for the file regardless, and this will not pose a problem because the arguments
are mutually exclusive.
p>
p> However, REBOL is complaining about me using the same name for 2 mutually exclusive
arguments
p>
p>
p> REBOL [ Title: "Main script" ]
p>
p> main: func [ "Performs order file transfer"
p> /name-product product-name [string!] "The product name"
p> /index-upfile upfile-index [integer!] "The index to be used for the upfile. Useful
when you have many upfiles and don't want to overwrite a previous one."
p> /put orderfile-name [string!] "Put an orderfile on our server"
p> /get orderfile-name [string!] "Put an orderfile on our server"
p> /date-upfile upfile-date [date!] "The date to be encoded into the upfile name"
p> /create-upfile upfile-name [string!] "This automatically creates and upfile. The
argument to this option is the word 'cancel' or 'nocancel', specifying whether you want
the upfile to contain a cancel or nocancel command"
p> /wait-on-controlfile controlfile-wait-time [time!] "Specifies the localtime that
the script will continue to try to look for the control file until. This option can only
be used with the /get option"
p> ] [ ]
Try something like this:
(...)
/put put-orderfile-name [string!] "Put an orderfile on our server"
/get get-orderfile-name [string!] "Get an orderfile from our server"
(...)
if put [ orderfile-name: put-orderfile-name ]
if get [ orderfile-name: get-orderfile-name ]
But be careful: this way, /get overrides /put *for the string only*, they're not actually
mutually exclusive. That is, you can specify both, and the rest of the function can malfunction
reacting to both (and with just the /get string).
Computers do what you tell them to do, not what you want.
:-/
Oh, and note both /put's and /get's help strings say "Put". :-)
Alternatively, since you state they're mutually exclusive, it means at least one *must*
apply, so eliminate one refinement and keep orderfile-name among the common arguments.
For example do a get (by default) unless the /put refinement is specified.
Alessandro Pini ([alex--pini--mclink--it])
We are programmed just to do / Anything you want us to
(Kraftwerk)
[5/6] from: agem:crosswinds at: 6-Sep-2000 0:23
main: func[ /file the-file /get /put ] ... should look fine?
another:
main: func[ /put p-file /get g-file ][ file: any[p-file g-file ... ]
but:
> /put orderfile-name [string!] "Put an orderfile on our server"
> /get orderfile-name [string!] "Put an orderfile on our server"
if you want to put in both cases, why the differcne?! ;-)
Volker
--- [princepawn--lycos--com] wrote on 5-Sep-2000/8:03:50-7:00
[6/6] from: al:bri:xtra at: 6-Sep-2000 19:18
princepawn wrote:
> /create-upfile upfile-name [string!] "This automatically creates and
upfile. The argument to this option is the word 'cancel' or 'nocancel',
specifying whether you want the upfile to contain a cancel or nocancel
command"
Probably could be better as refinements, like:
/Cancel
/NoCancel
Andrew Martin
The man of many holes...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/