r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

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!
Henrik
8-Apr-2011
[4198]
http://www.rebol.com/r3/docs/datatypes/map.html


I see it has not yet been documented. I seem to remember that it 
was, but I might be wrong.
BrianH
8-Apr-2011
[4199x2]
You won't be able to remove elements from an object even in R3, because 
it would break binding. But you can create a new object without the 
field, or use a map!, just as Henrik says. Note that you can also 
TRIM objects in R3, which will make a new object based on the old 
one with unset fields and fields set to none not included in the 
new object.
>> trim context [a: 1 b: none]
== make object! [
    a: 1
]
>> trim context [a: 1 b: 2 unset 'b]
== make object! [
    a: 1
]
Henrik
8-Apr-2011
[4201]
interesting
jack-ort
11-Apr-2011
[4202]
BrianH said: "But you can create a new object without the field,...."

Sorry to be especially dense, but do you mean create the new object 
from scratch, or based on the old object?  I've seen the examples 
to create new from old and also adding fields, or resetting the value 
of an existing field, but never excluding old fields.


I look forward to more documentation on "map!"; maybe I should move 
to R3.  Last I checked, there was no GUI in R3, even the Windows 
version, despite what the download page says?


One last newbie question for the day - will there be a 64-bit REBOL? 
 I'm thinking my data could get rather large before too long.  Thanks 
to all of you!
Ladislav
11-Apr-2011
[4203x2]
Sorry to be especially dense, but do you mean create the new object 
from scratch, or based on the old object?
 - specially in this case he means the above example
Last I checked, there was no GUI in R3, even the Windows version, 
despite what the download page says?

 there is R3-GUI, which can be downloaded. check the announcements, 
 etc. A new version will be published this week
jack-ort
11-Apr-2011
[4205]
Hello Ladislav!  That is great news regarding R3-GUI!


Re. BrianH's examples, I read those as specific to the R3 TRIM function, 
so I assumed his other comment referred to some alternative approach. 
 Obviously I have much to learn.  Thank you!
Ladislav
11-Apr-2011
[4206]
Alternative approach is certainly possible, but the usage of the 
TRIM function looks quite comfortable, I guess.
jack-ort
11-Apr-2011
[4207]
But only in R3, correct?
Ladislav
11-Apr-2011
[4208x3]
Certainly not, this approach (not using the Trim function, though, 
can be emulated in R2
It is possible to define a REBOL function doing that
For example, using the approach Henrik outlined above.
BrianH
11-Apr-2011
[4211x2]
I meant creating a new object from scratch, not based on a direct 
prototype.

For example:
>> x: make object! [a: 1 b: 2 c: 3]
== make object! [
    a: 1
    b: 2
    c: 3
]

>> y: make x [d: 4]  ; creating based on a direct prototype:
== make object! [
    a: 1
    b: 2
    c: 3
    d: 4
]


>> z: make object! head remove/part find body-of x 'b 2  ; making 
based on the body of x, but not directly on x
== make object! [
    a: 1
    c: 3
]
Those will work in R2 as well, and the latter (z) is how you can 
make new objects based on old objects, but with removed fields. You 
can't make an object with fewer fields by direct prototyping, and 
you can't remove fields from existing objects.