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

World: r3wp

[Dialects] Questions about how to create dialects

Janko
3-Mar-2009
[338]
yes, I saw this in Chris's  validation lib " Defining a good dialect 
(simple, short, efficient) isn't an easy task. Chris did some work 
about such form validation dialect in QM. See http://www.rebol.org/documentation.r?script=filtered-import.r
" (on this url)
Henrik
3-Mar-2009
[339x2]
I think I get it. You can't use the set-word directly, as it's used 
to store the current location in the parsed block.
you can always check for any set-word!, but I don't know how you 
would check for a specific set-word!.
Janko
3-Mar-2009
[341x2]
from his dialect: 

name: string! is not within ["Carl"]
age: integer! is between [18 65]
start-date: date! is after 30-April-2007
yes, basically in this case I am not looking for specific set-word 
but taking it as value .. I will try that
kib2
3-Mar-2009
[343]
I'm just starting to play with dialects : it's really a pleasure 
to play with.
Henrik
3-Mar-2009
[344]
set key set-word! (key: to-word key)

is how he does it.
Janko
3-Mar-2009
[345x2]
aha this words yes

>> a: [ id: ]
== [id:]
>> parse a [ set ttt set-word! ( print ttt ) ]
id
== true
:) thanks a lot
Henrik
3-Mar-2009
[347]
a variant on that would be:

parse a [ttt: set-word! (print ttt/1)]
Janko
3-Mar-2009
[348x2]
you solved my problem and it looks much better in Chris's style.. 
thanks to both

this is now:
	id: required and integer

 name: optional "janko" check ( either current == "janko" [ "can't 
 be janko" ] [ none ] )
	vatnum: optional "11ss" and int
	website: optional "123" and int do ( current: current + 1000 )
	phone: optional "NO" calc ( join "oh-" current )
	adress: optional ""

this was before:

	id required and integer .

 name optional "janko" check ( either current == "janko" [ "can't 
 be janko" ] [ none ] ) .
	vatnum optional "11ss" and int .
	website optional "123" and int do ( current: current + 1000 ) .
	phone optional "NO" calc ( join "oh-" current ) .
	adress optional "" .
kib2: yes, and they are technically very easy to make... I always 
thought it's soma magical process :)
Henrik
3-Mar-2009
[350]
Start layering multiple dialects and then you'll see some real power 
:-)
Janko
3-Mar-2009
[351]
I am still at mostly basic dialecting rules, but even this is very 
interesting and a lot can be made
Oldes
3-Mar-2009
[352]
I'm still waiting who will be the first to write Rebol like interpreter 
as a dialect:)
Janko
3-Mar-2009
[353x2]
has anyone made a dialect that would make some basic or typical sqlite 
? (so I won't be reinventing if not necesarry)
Oldes: making something like pypy in rebol rebreb maybe would probably 
not take so many years :)
Henrik
3-Mar-2009
[355]
Last year I created a small database which I wanted to talk to via 
a dialect. So I created a builder dialect that would build the database 
command dialect in two sets, one for server side for query handling 
and one for client side for response handling, so 3 dialects.

Then I would build client- and server-apps using a make-file like 
dialect which preprocesses and builds apps and uploads them to specific 
locations. 4 dialects. Great amount of control. Very little code.
Janko
3-Mar-2009
[356x2]
( pypy is python interpreter in python )
Henrik: very interesting
btiffin
3-Mar-2009
[358]
Janko; you may know this; dobeash.com has RebDB as well as a SQLite 
driver.   RebGUI with RebDB ...  livin'   :)
Janko
3-Mar-2009
[359]
btiffin :)  yes I use their sqlite driver and it works great , haven't 
tried rebdb or regbui yet
Chris
4-Mar-2009
[360]
Though not included in the rebol.org submission (it's in QM), I actually 
have two data matching dialects that use the same validation vocabulary 
(in both cases, set-words are the anchor to each rule).


 import [this "1"] [this: integer! is 1] ; import extracts name/value 
 pairs

 match [1][this: integer! | decimal! is 1] ; match evaluates a free-form 
 dialect


Both have different basic expressions, yet use exactly the same validation 
code.
MaxV
24-Aug-2009
[361]
VID:   How I can change button color? I tried:
view layout [ a: button red [  a/color: 0.0.0
        show a]
    ]

but nothing happens....
Pekr
24-Aug-2009
[362x2]
yeah, typical problem ....
IIRC, button colors are being held elsewhere. I don't remember if 
there were introduced accessor functions for them, or not ... let 
me see ...
Sunanda
24-Aug-2009
[364]
Color in a button is a graduated effect.

Take  a look at:
    a/effect
and then try changing it something like:
    a/effect/3: 0.0.0

(It ought to be easier!)
MaxV
24-Aug-2009
[365]
Thank you, I'll try and let you now!
Cheers!
Henrik
24-Aug-2009
[366]
yes, it ought to be easier. the color of the button is a hardwired 
effect that is calculated upon initialization of the button. when 
initialized, it can't be changed easily without knowing the source 
code for the button style.
Pekr
24-Aug-2009
[367x2]
>> view layout [b: button "OK" red [probe b/effect]]
[gradient 0x-1 255.32.32 223.0.0]


I think that you might be able to change those tuple values, but 
will it work with gradient easily? :-)
>> view layout [b: btn "OK" red [probe b/effect]]
[colorize 255.0.0 128 extend 14]
Henrik
24-Aug-2009
[369]
you need to check feel/redraw to make sure the effect is not overwritten 
by it
MaxV
24-Aug-2009
[370]
If I put 
b/effect: [ gradient  0x-1  0.255.0 0.255.0]
??
Pekr
24-Aug-2009
[371x3]
MaxV - to study it further, you can type following in console - print 
mold get-style 'button
Should work, remember to call show b in you code ...
also remember, there are two button versions - button, and btn - 
slightly different. You might also be interested to look into RebGUI 
VID alternative ...
MaxV
24-Aug-2009
[374]
Yes, yes. 

I'm trying to write a italian guide to Rebol, but now it's coming 
R3, and VID will be changed significantly., so I use Rebol just for 
the programs I need. 

I think that Rebol is what a programmer really needs, but finding 
guides about it is so difficult...
Pekr
24-Aug-2009
[375x2]
>> view layout [b: button "OK" red [probe reduce [b/color b/font/colors 
b/effect]]]

[255.0.0 [255.255.255 255.180.75] [gradient 0x-1 255.32.32 223.0.0]]
yes, R2 was kind of rather badly documented. And VID2 is really not 
that easy to hack, extend, beyond what it does. In the past I was 
reluctant to use RebGUI, because it looked rather unatractive, but 
that is not case anymore ....
MaxV
24-Aug-2009
[377]
Yes, I was confused by b/color
Pekr
24-Aug-2009
[378]
hmm, seems b/color is the red color. b/font colors is font colors 
- normal and over, b/effect - dunno ...
MaxV
24-Aug-2009
[379]
well b/color after initialization is ignored, so I have to change 
effect
Pekr
24-Aug-2009
[380x7]
this is the button's init function part - it looks if you have image 
for button, and if not, then:

            if not any [effect effects] [
                either color [
                    effects: reduce [

                        reduce ['gradient 0x1 color + 32 color - 32]
                        either all [block? colors colors/2] [

                            reduce ['gradient 0x-1 colors/2 + 32 color/2 - 32]
                        ] [

                            reduce ['gradient 0x-1 color + 32 color - 32]
                        ]
                    ]
                ] [
                    effects: [
                        [gradient 0x1 66.120.192 44.80.132]
                        [gradient 0x-1 66.120.192 44.80.132]
                    ]
                ]
either color

  means, if you have submitted a color facet in VID level ... e.g. 
  button red
I was not succesfull changing only 'effect. You have to change b/effects 
block, because of following engage/redraw code imo:

if face/effects [face/effect: pick face/effects not state]
>> view layout [b: button "OK" [probe reduce [b/color b/font/colors 
b/effect b/effects]]]
[44.80.132 [255.255.255 255.180.75]
    [gradient 0x-1 66.120.192 44.80.132] [
        [gradient 0x1 66.120.192 44.80.132]
        [gradient 0x-1 66.120.192 44.80.132]
    ]
]
If you change only b/effect, it will be rewritten by redraw imo ....
view layout [b: button "OK" red [b/effects/1: [gradient 0x1 100.100.100 
120.120.120]]]
From there on, you can work out your final solution imo ...
MaxV
24-Aug-2009
[387]
Yess!  Effect is the color of the button pushed, effects normal button 
state.
Thank you