World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Maxim 18-Jan-2011 [4148] | the R2 console can actually act like a shell. in the latest release (2.7.8) they added posix style shortcuts to the various file operations directly... so you can do: >> cd %/C/users/alemar/download/ >> ls |
alemar 18-Jan-2011 [4149] | yeah i got it now it is verry simple i just assosciated the.r extension with rebol :D |
Maxim 18-Jan-2011 [4150] | the advantage of opening the console first and executing do is that any console i/o will remain in the current console... if you just double click on a simple script, REBOL will open execute and close so fast, you might not even see it flash on screen! |
alemar 18-Jan-2011 [4151] | aha |
Maxim 18-Jan-2011 [4152] | one of the advantages of being only 700kb ;-) |
alemar 18-Jan-2011 [4153x2] | ok but now when i start the file directly i get ** Syntax Error: Script is missing a REBOL header ** Near: do/args script system/script/args |
my-func: func [] [ n: to-integer ask "enter a number" if n < 0 [quit/return 1] sum: 0 i: 0 while [ i <= n ] [ sum: sum + probe (i * i) i: i + 1] print sum ] | |
Maxim 18-Jan-2011 [4155] | ah yes. scripts *must* start with rebol's header. rebol [ ] |
alemar 18-Jan-2011 [4156] | this is the body of the file |
Henrik 18-Jan-2011 [4157] | did you add the first line: REBOL [] ? |
alemar 18-Jan-2011 [4158x2] | REBOL[] my-func: func [] [ n: to-integer ask "enter a number" if n < 0 [quit/return 1] sum: 0 i: 0 while [ i <= n ] [ sum: sum + probe (i * i) i: i + 1] print sum ] |
like so? | |
Maxim 18-Jan-2011 [4160] | you can see that Rebol is case insensitive ;-) |
Henrik 18-Jan-2011 [4161] | yep |
Maxim 18-Jan-2011 [4162] | yep. and don't forget to run the function at the end... I'd also put a trailing ask "" REBOL[] my-func: func [] [ n: to-integer ask "enter a number: " if n < 0 [quit/return 1] sum: 0 i: 0 while [ i <= n ] [ sum: sum + probe (i * i) i: i + 1] print sum ] my-func ask "press enter to quit" |
alemar 18-Jan-2011 [4163x2] | ok trying that as well,on a side note now the file does not start :D |
sry my mistake | |
Maxim 18-Jan-2011 [4165] | if you didn't put an ask at the end... just just didn't see it cause it closed to quicly. |
alemar 18-Jan-2011 [4166x2] | works fine |
yeah THAT i figured out from reading the libraries thanks alot guys you are great | |
Maxim 18-Jan-2011 [4168] | if you press escape at any point, the execution stops and you are sent to the console... try it. |
alemar 18-Jan-2011 [4169] | cool |
Maxim 18-Jan-2011 [4170x2] | now try it with a negative number and the console will quit on its own (since I put a return/quit 1) |
if you just want the function to return remove the /quit 1 | |
alemar 18-Jan-2011 [4172] | really nifty |
Maxim 18-Jan-2011 [4173] | /quit is a Refinement a special function datatype which can be used in functions to supply additional parameters or instructions to a function. |
alemar 18-Jan-2011 [4174x2] | ok i am beggining to love this language |
so everything aside i really got into the basics thank you fo that | |
Maxim 18-Jan-2011 [4176x2] | refinements is how REBOL gets away without any parens because the number of arguments is always known. |
no problem... its always fun to have new users. :-) | |
alemar 18-Jan-2011 [4178] | what do you mean always known |
Sunanda 18-Jan-2011 [4179] | Be careful......Max is feeding you the red pill. |
Maxim 18-Jan-2011 [4180x3] | ex: my-func [value /optional opt-value] [ probe value if optional [ probe opt-value ] ] my-func 33 my-func/option 22 "tadam" |
because you added the refinement, it knows to expect an additional argument. | |
oops... my-func: func [value /optional opt-value] [ | |
alemar 18-Jan-2011 [4183] | thnks guys really gr8 community unfortunately my timezone says:go to bed or don`t bother at all" :D so i will leave the pc now but i will leave the chat on if i think os something in my sleep |
Pekr 18-Jan-2011 [4184] | alemar - where are you from? |
alemar 18-Jan-2011 [4185x2] | bulgaria |
it`s barely 22:30 but i got a lot to do tommorow | |
Pekr 18-Jan-2011 [4187] | I am from Czech Republic .... |
alemar 18-Jan-2011 [4188] | :D |
Maxim 18-Jan-2011 [4189] | and when its needed, you can force input types: fixed a few typos... this should work right: my-func: func [value /optional opt-value [string!] ] [ probe value if optional [ print length? opt-value ] ] my-func 33 my-func/optional 22 "tadam" my-func/optional 22 44 |
alemar 18-Jan-2011 [4190x3] | the name did seem a bit slav... :D |
tnks pasin to my little vault.. | |
pastin | |
jack-ort 8-Apr-2011 [4193] | thinking of using objects for the first time, using them to capture clinical data for patients. Need to capture data by time; still just a fuzzy idea. I have read how you can extend an object by simply redefining it with new values, but I wonder if there is a way to REMOVE elements from an object? TIA! |
Henrik 8-Apr-2011 [4194] | In R2, you can do this: 1. get the body of the object as a block 2. find the word you want to remove 3. remove the word and its value coming right after 4. make a new object from the block |
jack-ort 8-Apr-2011 [4195] | ah! That makes sense! Thank you Henrik! It is good to be working (learning) REBOL again, knowing that help is so fast to find on AltMe. I notice you specified R2 - without asking for details, will this be different in R3? |
Henrik 8-Apr-2011 [4196] | In R3 you have more options for manipulating objects a little bit like series, without having to re-make the object, although I'm uncertain that you can remove elements from objects. But then you also have the map! datatype, which is more suitable for very quick adding and removing of key/value pairs. |
jack-ort 8-Apr-2011 [4197] | map! ?? so much to learn. Again, thank you! |
older newer | first last |