World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Henrik 25-Oct-2011 [4567] | Example: my-func/boo 6 Does the 6 argument belong to the function or the refinement? |
Duke 25-Oct-2011 [4568] | I'm getting TOTALLY confused here! I'm going to have to stop here and go study this - including all of you guys' advise - a bit more .... |
Henrik 25-Oct-2011 [4569] | ok :-) |
Geomol 25-Oct-2011 [4570x2] | Yeah, that can be confusing! :) >> f: func [arg /ref1 ref-arg] [print [arg /ref1 ref-arg]] >> f/ref1 /ref2 /ref3 ref2 ref1 ref3 |
>> f/ref1 'arg 'ref-arg arg ref1 ref-arg | |
Endo 25-Oct-2011 [4572] | Duke: Don't be confused. my-func/boo 6 If my-func requires an argument and /boo refinement does not require and additional argument, then 6 is for my-func. if my-func and /boo both require args then you will get an error. my-func expects more arg. if my-func doesn't require an arg but /boo does then it belongs to /boo |
Geomol 25-Oct-2011 [4573x2] | I personally consider refinements to be one of the less stellar parts of REBOL. Henrik, do you prefer one additional function for each new way of calling a function, instead of refinements? |
I should have made my example more like this: >> f: func [arg /ref1 ref-arg] [print [arg ref1 ref-arg]] >> f/ref1 /ref2 /ref3 ref2 true ref3 | |
Endo 25-Oct-2011 [4575] | I faced a problem when I use a refinements, my function had an ref. /any Then I forgot it and use ANY native. It gives error about using none, because the function wasn't called /any, so the word ANY was defined and its value was NONE. It was difficult to find the problem. |
Geomol 25-Oct-2011 [4576x3] | Maybe refinements for functions are more clear with examples like this: Let's say, we want a sine function, which default operate with radians, but you can give degrees refinement, if you like, exactly opposite of the normal SINE function: >> sin: func [value /deg] [either deg [sine value] [sine/radians value]] >> sin pi / 6 == 0.5 >> sin/deg 30 == 0.5 |
Another example with additional argument, when refinement is used. The normal COPY function: >> copy "abc" == "abc" >> copy/part "abc" 2 == "ab" | |
And checking help for COPY: >> ? copy USAGE: COPY value /part range /deep Read that as: - COPY takes one argument called VALUE - If you choose to use the /part refinement, you then need to give an additional RANGE argument - If you choose to use the /deep refinement, no additional argument is needed. | |
Duke 25-Oct-2011 [4579] | @Geomol I now understand the syntax of function arguments, function refinements and THEIR arguments. Endo summarized it well. However, I still think that the REBOL Help sub-system should reflect EXACTLY how the function should be written. Thta should be the programmer's first line of help. Like the Unix man pages. So, assuming that the * char indicates optional syntax, IMHO, ?copy should say: USAGE: COPY */part, /deep* VALUE */deep range* To me, that tells me exactly the order in which the optional refinements, the required function argument, and the optional refinement argument should be written. To me this makes more sense. :D |
Henrik 25-Oct-2011 [4580] | COPY */part, /deep* VALUE */deep range* - not sure I understand this order, as it will fail to explain where VALUE belongs and where RANGE belongs (it does not belong with /DEEP). Anyhow, the notation is standard and should not change anywhere. You only need to learn it once, so hopefully, this is not too much of a hurdle. |
Ladislav 25-Oct-2011 [4581x4] | I still think that the REBOL Help sub-system should reflect EXACTLY how the function should be written - this is easy. If you find a better way how to display the help, then simply propose it. In REBOL, it is easier to write the code, than to invent what the code should do. |
But, do not forget, that it must be something that describes what do you want, not a description what you do not like. | |
It would certainly suffice if you wrote a couple of examples, how it should look | |
Aha, you tried to write something above. Well, I do not quite understand the stars you used - where should they be put? | |
Sunanda 25-Oct-2011 [4585] | The REBOL help system is remarkable concise and acts, usually, as an excellent aide memoire. It has weaknesses too -- for example, it does not give hints as to which refinements are incompatible with others. eg HELP TRIM gives no clue that TRIM/HEAD/WITH is not acceptable. A fresh look at the HELP system may help improve it. |
Ladislav 25-Oct-2011 [4586x4] | Nor I did understand how can I recognize that VALUE is a parameter of COPY, not of the /DEEP refinement |
The COPY value /part range /deep actually means, that you can use any of: COPY value COPY/part value range COPY/deep value COPY/part/deep value range COPY/deep/part value range | |
(I must admit, that I never tried some of the above) | |
eg HELP TRIM gives no clue that TRIM/HEAD/WITH is not acceptable - yes, but that can be cured even without a change to the help system, it might suffice to just add that as a new information into the main help string. | |
todun 25-Oct-2011 [4590] | @james_nak: thanks for your Oct-15th 8:33 PM reply. |
MagnussonC 11-Nov-2011 [4591] | Is it possible to open a web page and fill in username, password and press send? It is a POST form. I'm thinking of using it to check if some (of my own) web pages work and it is possible to login. I've tried read URL. |
Geomol 11-Nov-2011 [4592x2] | Yes: http://www.rebol.com/docs/core23/rebolcore-13.html#section-8.6 |
And more here: http://www.rebol.com/docs/core23/rebolcore-13.html#section-13.5 | |
MagnussonC 11-Nov-2011 [4594x2] | Interesting. Thanks, Geomol. |
About the example 8.6 on read/custom and post. I can't find any info about the arguments for post. There is no help for this word. Can I send several arguments at once or do I write one post line for each form field? | |
Sunanda 11-Nov-2011 [4596] | You concatenate the args. Example: as a GET r-get: read http://www.rebol.org/st-topic-details.r?tag=domain//html&start-at=26&limit=25 Same request as a POST: r-post: read/custom http://www.rebol.org/st-topic-details.r[post "tag=domain//html&start-at=26&limit=25"] |
MagnussonC 11-Nov-2011 [4597] | Thanks, Sunanda. |
Burtm10 12-Nov-2011 [4598] | Hello Helpful person. I have a need for a local no-server database function and have explored the sqlite tools which I can get working OK But. The data I want to be storing needs to be secure. I have looked at the encodings.r and that will work but I was wondering if there was another way. I have used Tsunami Records Manager in the past with good success. I have used Euphoria which has an excellent inbuilt database function and I would like something similar if possible. Any clues? |
Endo 14-Nov-2011 [4599] | When I examine the functions in altjson.r and altwebform.r written by Christopher Ross-Gill, I see function definitions like below: load-json: use [...<lots of words>...] [... <lots of definitions etc.> func [...] ] is this method for hiding details in function body? or to make the function body cleaner? |
Gabriele 14-Nov-2011 [4600] | Basically, it's so that the words in the USE are not easily accessible from the outside. A "poor man's module" if you wish. |
Endo 14-Nov-2011 [4601] | I see, I thought that its a good way to keep the body clean. But curious about if there is another reason. Thank you. Btw, I loved functions in utility.r. Is it 1.22.1 (4-Feb-2005) the latest version? fortype, nforeach, import & export are very useful functions. |
Gabriele 15-Nov-2011 [4602] | yes, that's the latest version. |
PeterWood 21-Nov-2011 [4603] | This is a good place to ask questions about getting started with REBOL and getting used to AltME. |
MagnussonC 30-Nov-2011 [4604] | Is there a LDAP module with authentification available for R2? I tried ldap-protocol.r from softinnov.org, but didn't get that to work (with anonymous bind) ... Not sure why I get "Error: Invalid port spec". I'm on Win7 (x64). Maybe it is something on OS level I have to config to use ldap://!? |
Dockimbel 30-Nov-2011 [4605] | Invalid port spec means that you have provided an incorrect argument to OPEN native. |
MagnussonC 30-Nov-2011 [4606] | Thnx, can I not use IP-address for argument? |
Dockimbel 30-Nov-2011 [4607] | Sure you can, but your syntax is maybe wrong, can you post here your connection opening code? |
MagnussonC 30-Nov-2011 [4608] | Hmm, I think I found what was wrong ... *blushing* |
Dockimbel 30-Nov-2011 [4609] | Anonymous login with ldap-protocol.r should work fine. |
MagnussonC 30-Nov-2011 [4610x3] | Now I got connected at least. I used include instead of do. |
Is there a way to loop throu the objects in LDAP? I seem to be able to get just one object at the time. | |
... and I'm not sure what to make of the "make object!" in the resulting block. | |
BrianH 30-Nov-2011 [4613] | That's just for display, like this: >> object [a: 1] == make object! [ a: 1 ] >> length? reduce [object [a: 1]] == 1 |
Dockimbel 30-Nov-2011 [4614] | Loop through objects: I guess you're meaning looping through a block of objects, which can be achieved using any of the REBOL looping function. |
BrianH 30-Nov-2011 [4615] | If you actually want to loop through the key/value pairs of the object itself, you need to use R3's FOREACH, or loop through a BODY-OF the object. |
Izkata 30-Nov-2011 [4616] | It can be done in R2, just a slight bit convoluted: >> X: make object! [a: 1 b: 2 c: 3] >> ? X X is an object of value: a integer! 1 b integer! 2 c integer! 3 >> first X == [self a b c] >> foreach key next first X [print rejoin [key { -> } get in X key]] a -> 1 b -> 2 c -> 3 |
older newer | first last |