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

[REBOL] Re: Why cant mutually exclusive refinements have the same argument name

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)