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.

SteveT
21-Jan-2008
[1210x2]
Yes, on a particular field I want to control what the user can and 
can't enter
On one field I want to trap and convert any chars to uppercase, but 
also stopthe user from antering more than say 5 chars !
Anton
21-Jan-2008
[1212x2]
either 5 > length? face/text [
	; allow event to pass through
][
	exit ; too many chars ! don't allow it !
]
or combining filter with length check:
if any [
	not find "0123...89" event/key
	5 <= length? face/text
][
	exit
]
SteveT
21-Jan-2008
[1214x2]
Yeah I was trying to approach it with ( if chars < 6 allow it ) which 
got me in a mess.
I'm sorry for all these questions - It sounds like I want you to 
do my work for me! I don't maind having to figure some things out 
myself . But I was asked to present waht I found difficult from a 
newbie point of view.
Henrik
21-Jan-2008
[1216]
you're lucky to have us around, otherwise some of this would take 
a long time to figure out. I was frustrated for a long time about 
many of these things.
SteveT
21-Jan-2008
[1217]
Very True, hopefully I will be able give back - in time
Henrik
21-Jan-2008
[1218]
particularly bindings can be baffling, because it looks like function 
names are pulled out of thin air. :-)
SteveT
21-Jan-2008
[1219x3]
Yes, I'm starting to understnad dialects and domains. Bindings I'm 
clue-less (LOL)
Yes on Antons one liner with the three filed and overriding the tab 
to filed three the 'bind' is alien to me!
field !
Henrik
21-Jan-2008
[1222x2]
bindings are actually simply tieing a word to a list of words (a 
context), which is an object. outside the context, the word has no 
meaning, yet it can appear anywhere in code
I believe this is how local words work in a function definition. 
the words don't work outside the function, because they are bound 
to its context.
SteveT
21-Jan-2008
[1224]
Right one of the fundamentals of Rebol is that Word behaviour can 
change or is set by what contaxt it's in ?
Henrik
21-Jan-2008
[1225x3]
yes, by using the BIND function, you can bind a word to one or more 
contexts simultaneously.
yet it can appear anywhere in code

 <--- actually that's a bit wrong. if the word is not defined for 
 a particular context, then of course it's useless there. but if you 
 use the word in the right context, for example inside an object in 
 which it was originally created, then it will have meaning.
you can study this by creating objects with words in them and try 
to bind them to different contexts (other objects).
SteveT
21-Jan-2008
[1228x2]
I understand that. Are contexts just what I would call an object?
Ah! you just answered that  ;-)
Henrik
21-Jan-2008
[1230x4]
yes. try:
make object! []

and context []

and see what's returned
or more revealing:

>> source context

context: func [

    "Defines a unique (underived) object." 

    blk [block!] "Object variables and values."

][

    make object! blk

]
it's all just a big re-dress of objects. :-)
SteveT
21-Jan-2008
[1234]
Think I get it - It's the object oriented side of Rebol - you could 
say that bind is a sort of inheritance ?
Henrik
21-Jan-2008
[1235]
more like membership. there is no real inheritance in Rebol.
SteveT
21-Jan-2008
[1236x2]
Yes, MS always partly implemented OO in VS. they didn't think there 
users could handle them !  Java is more of a full OO implementation 
but I find you end up having to override most objects and that's 
not good for code re-use.
OO is ok but it doesn't always fit the real world (or programming 
productivity). that's why I think OO Databases have never really 
been adopted! they fit models but not the real world (Where the customer 
say's Ahh! didn't we mention that !! (LOL).
Anton
21-Jan-2008
[1238x5]
This should be instructive. Type this into the console a line at 
a time:
o1: context [my-word: "hello"]
o2: context [my-word: "there"]
o3: make object! [my-word: "SteveT"]
code: []
append code in o1 'my-word
append code in o2 'my-word
append code bind [my-word] o3
print code
I first show two different ways of creating an object, and then I 
show two different ways of getting a word in an object.
SteveT
21-Jan-2008
[1243]
I got a halt-view near my-word?
Anton
21-Jan-2008
[1244x3]
Show me the code and resulting error.
Maybe you missed one of the single-quotes before a 'my-word (which 
makes it a lit-word!)
eg.  in o1 'my-word   ; <-- don't miss the '
SteveT
21-Jan-2008
[1247]
o1: context [mu-word: "hello"]
>> o2: context [my-word: "there"]
>> o3: make object! [my-word: "SteveT"]
>> code: []
== []
>> append code in o1 'my-word
== [none]
>> append code in o2 'my-word
== [none my-word]
>> append code bind [my-word] o3
== [none my-word my-word]
>> print code
none there SteveT

Yep think so that 's what i got now
Anton
21-Jan-2008
[1248]
first line says "mu-word" :)
SteveT
21-Jan-2008
[1249]
Dohhh! it's this eclectic keyboard lol
Anton
21-Jan-2008
[1250x6]
'my-word is therefore not in o1 and so:    in o1 'my-word  == none
:)
first o1
first o2
Lists the words in each object, if you don't believe what IN is telling 
you.
Or of course you can use HELP or ?.
? o1
? o2
SteveT
21-Jan-2008
[1256]
Think I understand that
Anton
21-Jan-2008
[1257]
Each word carries its binding with it. ie. a reference to an object. 
(or no object if it is unbound).
SteveT
21-Jan-2008
[1258]
Can you get problems if an  object gets bound to itself?
Anton
21-Jan-2008
[1259]
An object is a container of word -> value pairs. When you ask for 
a word's value, the word's binding is checked to get the object.