• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp239
r3wp2252
total:2491

results window for this page: [start: 1501 end: 1600]

world-name: r3wp

Group: Core ... Discuss core issues [web-public]
Maxim:
17-May-2009
I'm having a problem with call.


when I use the /output/error and supply  strings , I get a strange 
error in the stdout holding string:

Unable to read from standard input: The handle is invalid.


the really strange one is that if I use /console, the expeted out 
is effectively printed out to the rebol console.... so the cmd does 
return data and rebol is able to handle it, but not within the /output/ 
refinement!


also, another call, using another command, works as expected... so 
I don't think I have a error in my code.

not that I have tried using /shell and it didn't help

has anyone seen /output and /console react this way?
Graham:
19-May-2009
page: read/custom [ scheme: 'http host: "twitter.com" target: "direct_messages/new.xml" 
user: "my-twitter-id" pass: "mypassword" ]  [ POST "text=This was 
also sent from a Rebol&user=synapse_emr" ]


This sends a private tweet to a user ... not clear from the API docs 
what the call is to just tweet ... anyone know?
Dockimbel:
27-May-2009
That's very possible, I use recursion only when the gain in code 
size or clarity looks obvious. Also, not having tail-call optimization 
doesn't push you much toward recursive approach in the general case.
BrianH:
27-May-2009
I use it for building or processing recursive data structures - it's 
faster for that, tail-call-optimized or not. I only switch to iteration 
and hacks if the data blows the stack, which is rare.
Steeve:
27-May-2009
faster, One call with parse
Steeve:
27-May-2009
meaning parameters are not stored in the call stack :)
BrianH:
27-May-2009
This is one aspect of the internals that I actually am aware of, 
since it affects contexts. It's true: REBOL implements its own stacks, 
and doesn't use the C stack to call REBOL functions, just natives.
BrianH:
27-May-2009
This is why the R3 host code is separate, and will be open-sourced. 
The host code is non-portable. The VM can call API functions provided 
by the host code. This would be necessary for a variety of reasons, 
not the least of which is that memory management, tasking, networking, 
any number of things are implemented by different platforms differently.
Graham:
7-Jun-2009
'call
amacleod:
7-Jun-2009
Got it..thanks Graham...


Here are three lines that adjust the time zone and time of the local 
computer after checking time with a server with a daytime server 
running:


call "RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z Eastern 
Standard Time"
a: to-date read daytime://myserver.com b: a/time
call rejoin ["time " b]
amacleod:
7-Jun-2009
also, change date:

call "date 6/7/2009"
Maxim:
16-Jun-2009
now that I think about it... its not loading the images, it was using 
make image which caused the memory leak... if you call 400MB a "leak".
Oldes:
16-Jun-2009
I use ImageMagick as well. It allows much more than pure Rebol. But 
of course I call it from Rebol:)
Janko:
30-Jun-2009
and they can get on and off work as they please :) .. I call this 
"casual workers system" :)
Graham:
1-Jul-2009
Doc wrote async-call which would also work .. except it locks up 
VID when I recently tested it.
Pekr:
16-Jul-2009
call/output does not work, when console is not being run? I tried 
to convert some character sets, prepared short script, and run it 
by double-clicking .r file. No result was shown and rebol process 
is hang in memory. It was enough to put one print statement so that 
console showed up, and it was OK then. But that is weird, I wanted 
it to run without REBOL console showing up ...
BrianH:
4-Aug-2009
You use that block as the spec block of your new function. Save a 
reference to the old, and then call it in your new function from 
your saved reference. Natives don't have body blocks.
Maxim:
17-Sep-2009
so I'll just call and use the result string!
Gregg:
9-Dec-2009
Steve, I always use CALL these days. Or Gabriele and Doc's async-call. 
By using system/options/boot, you can launch the interpreter you're 
running under.
Gabriele:
10-Dec-2009
Steve: call reduce [system/options/boot %myscript.r "argument1" "argument2"]
Gabriele:
10-Dec-2009
when you use file! call does a to-local-file automatically, and wraps 
it in quotes.
Graham:
10-Dec-2009
Launch is broken that's why Gabriele is suggesting using call instead
sqlab:
10-Dec-2009
I use call too in my scripts, but the question was for launch.)
Gabriele:
18-Dec-2009
i was just thinking again about the idea of IF (etc.) keeping a reference 
to the condition argument for you, that is, so that instead of writing:

    if x: select block value [do-something-with x]

you can write:

    if select block value [do-something-with it]


The reason people say it's not worth it is usually that of having 
to bind/copy the block - you don't want that in every IF call and 
probably not even in the ones where it would be useful (and, there's 
really no other name you could use for the function).
BrianH:
18-Dec-2009
Gabriele, it occurs to me that if IT was native it could look up 
the stack to get its value. I'll try writing a (security hole) REBOL 
version of the function later today - it would require debug privileges 
to run so that it can call the STACK function.
BrianH:
19-Dec-2009
IT would need to search up the stack to find the nearest appropriate 
function call frame - it doesn't just apply to the next call up.
Maxim:
14-Jan-2010
after a decade I still find new language tricks.  I call it the "temporary 
newbie moment" phenomenon... I've never had these moments in other 
languages.


its like finding a new trick to make your lego stuff stronger while 
having the same shape  ;-)
Maxim:
20-Jan-2010
I'd call the function include... and it could work on strings too, 
doing a find
BrianH:
21-Jan-2010
It just happens that that function value is assigned to that word. 
With the next call of the piped code it might be a different function.
BrianH:
7-Feb-2010
The new or changed mezzanines in R2 2.7.7+ that use the lit-word 
calling convention explicitly evaluate parens to be more like the 
R3 version of the functions. However, since the evaluation is explicit 
within the function rather than performed by DO at the call location, 
op! evaluation isn't triggered:
>> a (w) + 2
** Script Error: Cannot use add on paren! value
** Where: halt-view
** Near: a (w) + 2


Since the lit-word calling convention is only really appropriate 
for functions that act like syntax (like FOR), interactive functions 
that work on files (like CD) or functions that use word values as 
flags (like SECURE), they are never used with functions that take 
as arguments the types of values that are returned by op! expressions 
(numbers, binaries, true or false). So this is never an issue in 
practice, only in bad code that should never work.
BrianH:
23-Feb-2010
For instance, in R3 (can't check R2 right now on this computer) comparison 
is allowed to unset! and error! values can be done with operators 
if the unset/error value is on the left side of the operator, but 
not on the right. This is because operators redirect to actions, 
and action functions are different depending on their first argument 
(single-dispatch). The comparison actions for unset! and error! can 
compare to other values, but the comparson actions of other types 
don't support comparing to error/unset. The action! function that 
calls the action has a typespec for its first argument that doesn't 
allow error/unset, but the op! redirects to the internal action, 
not the action! function, and it works because it uses a DO trick 
instead of a standard function call.
BrianH:
23-Feb-2010
EMPTY? doesn't call TAIL?, they are the same function assigned to 
two different words :)
BrianH:
23-Feb-2010
Oh, it gets trickier (in theory - I've had to do a lot of scientific 
method on the internals, not decompiling). I think that DO does some 
of the function call work, and the function type itself does the 
rest through an internal action. DO handles the evaluation rules 
and builds the stack frame, then passes along that stack frame to 
the function dispatch action of the function type for it to redirect 
to the real code in a type-specific way.


Now it definitely works that way, the only question is whether the 
type-specific dispatch code is built into DO itself, accessed through 
the action dispatch mechanism, or action code called directly without 
going through the action dispatch mechanism. Only Carl or a decompiler 
could say for sure. But really, it doesn't matter because the behavior 
is the same in any case.
BrianH:
23-Feb-2010
Nope, at least not in R3. Natives can call actions, and even call 
function! functions too.
BrianH:
23-Feb-2010
Mezzanine functions called by native functions are generally called 
"intrinsics", and there are several of them. DO, MAKE module! or 
port!, and the startup code call intrinsics.
Henrik:
4-Mar-2010
R2 challenge:


Implement a debug-function that uses a call-stack. I made this context:

context [
	action-level: 0
	func-name: make block! []

 set 'hint func [str] [reform [action-level: action-level + 1 ":" 
 str]]

 set 'doing func [name] [print hint join "Doing " last append func-name 
 name]

 set 'done does [print join "Done with " first name: back tail func-name 
 remove name action-level: action-level - 1]
	set 'last-hint does [print mold func-name]
]

And I use it like this:

my-func: func [] [
	doing 'my-func
	...stuff...
	done
]


What would it take to build a function that does this automatically, 
like:

my-func: debug-func [] [
	... stuff ...
]


and also automatically catches all exits, returns and throws and 
allows the function to return a value?

As this is built into R3, this is only for R2.
Andreas:
1-Apr-2010
we could call it ..... self!
BrianH:
19-Apr-2010
I just mentioned it in the a98 call for fixes blog.
BrianH:
13-May-2010
Plus the stuff not covered by any of the RFCs at all, like file listing 
formats. There are Windows FTP servers that format their listings 
like DOS DIR listings, Unix servers that actually call ls, etc.
Pekr:
17-May-2010
If you would not use GUI, what exactly would be holding you back? 
You created even basic networking schemes? As for me, I miss fixed 
'call - it is still hugely crippled and absolutly useless ...
Terry:
17-May-2010
we can call the winner find-fastest
Graham:
8-Jun-2010
One of those annoyances ...

>> to-local-file %"/c/program files/rebol/rebol.exe"
== "c:\program files\rebol\rebol.exe"

>> rejoin [ "call " to-local-file %"/c/program files/rebol/rebol.exe" 
]
== "call c:\program files\rebol\rebol.exe"

>> quoted-to-local-file: func [ f ][ rejoin [ {"} to-local-file f 
{"}] ]

>> rejoin [ "call " quoted-to-local-file %"/c/program files/rebol/rebol.exe" 
]
== {call "c:\program files\rebol\rebol.exe"}
BrianH:
8-Jun-2010
CALL in R2 does the local file conversion though. Let me check whether 
it does escaping.
BrianH:
8-Jun-2010
>> call/console [%/C/WINDOWS/system32/cmd.exe "/c echo" %.]
C:\Program Files\REBOL\View
BrianH:
8-Jun-2010
CALL does the TO-LOCAL-FILE itself, and wraps with double quotes 
automatically.
Maxim:
8-Jun-2010
but only if you use block mode for CALL, Graham was using a string, 
which allows us to make sure things are formatted properly, cause 
sometimes, when specifying arguments, this crap gets very mystical. 
 :-)
BrianH:
8-Jun-2010
Yeah, and the R3 CALL doesn't do anything like that yet. Time to 
edit the host code?
Oldes:
9-Jun-2010
Graham, what about using REBOL words to do that job.. like:

>> rejoin [ "call " mold to-local-file %"/c/program files/rebol/rebol.exe" 
]
== {call "c:\program files\rebol\rebol.exe"}
Pekr:
10-Jun-2010
Understood. I thought about the back-up plan of how to make R3 usable 
- simply to get it at least on par with R2. Dunno if much is needed? 
Screw the console ... but at least - fixed call, dll interface, protocols 
(we have some base of your work), what else might be missing? DB 
protocols port?
Graham:
10-Jun-2010
but yes, all those other things such as fixed call, dll interface, 
and DB protocols ...
Maxim:
10-Jun-2010
it quits the wait []  call.

the same happens if you return true from the view wake-event.
Oldes:
14-Jun-2010
Graham, Gab.: you are right, never checked that MOLD works like that 
on longer strings. I will remember that now.

But anyway... when you need to do call on unknown files, you should 
use more soficticated way.
Using just:
	rejoin [{"} to-local-file file {"}]

I consider as as security thread and I would never used it like that. 
And it does not metter if using MOLD or not.
Oldes:
14-Jun-2010
One never knows:)
What about something like that:

>> file: {^" call ^"something else } rejoin [{call "} to-local-file 
file {"}]
== {call "" call "something else "}
Gabriele:
15-Jun-2010
Oldes, indeed, one should pass CALL a block and let it do the conversion 
(because it is platform dependent) - though right now I don't think 
it does much more than to-local-file and adding quotes.
Ladislav:
19-Jun-2010
What do you think about this:

>> even? 2.1
== true


As far as I am concerned, I would call it a bug, since 2.1 does not 
look like an integer multiple of 2.0 to me.
Sunanda:
5-Jul-2010
This is _a_ way in windows (but you need to be running in admin mode 
.... so not so usefu):
    capture-call: copy ""
    call/output/info "fsutil fsinfo drivetype e:" capture-call
    print capture-call
    == "e: - CD-ROM Drive^/"
Gregg:
6-Jul-2010
REBOL []

do %../library-dialect/lib-dialect.r

make-routines [
    lib %kernel32.dll
    def-rtn-type long
    ; returns available drive flags as a bitset (in a long)
    get-logical-drives "GetLogicalDrives"
    get-logical-drive-strings "GetLogicalDriveStringsA" [
        buff-len [integer!]
        buffer   [string!]
    ]
    get-drive-type [drive [string!]] "GetDriveTypeA"
]


drive-types: [
    Unknown     ; 0 We don't know what kind of drive it is
    NoRootDir   ; 1 Probably not a valid drive if there's no
                ;   root directory
    Removable   ; 2 It's a removable drive
    Fixed       ; 3 It's a fixed disk
    Remote      ; 4 It's out there on the network somewhere
    CDROM       ; 5 It's a CD ROM drive
    RAMDisk     ; 6 It's not a real drive, but a RAM drive.
]

drive-type?: func [drive /word /local res] [
    res: get-drive-type join first trim/with form drive "/" ":"
    either word [pick drive-types add res 1] [res]
]

get-drive-strings: func [
    /trim "Return only the drive letters, no extra chars"
    /local len buff res
][

    ; Call it once, with 0, to find out how much space we need in our 
    buffer
    len: get-logical-drive-strings 0 "^@"
    ; Init our buffer to the required length
    buff: head insert/dup copy "" #"^@" len
    ; Make the call for real, to get the data
    len: get-logical-drive-strings length? buff buff
    res: parse/all copy/part buff len "^@"
    if trim [foreach item res [clear at item 2]]
    res
]

;print enbase/base to binary! get-logical-drives 2
foreach id [a b "C" 'c "D" d: %E %F %/F] [
    print [mold :id tab drive-type? :id tab drive-type?/word :id]
]
print mold get-drive-strings
print mold get-drive-strings/trim
print read %/
Maxim:
8-Jul-2010
you can also make a function which call init , if its there.


new: func[class spec /local obj][obj: make class spec if function? 
get in obj 'init [obj/init]]
Maxim:
8-Jul-2010
yes, my above one-line constructor func scales very well, since you 
can call new on sub-objects too, and it will take care of any things 
like creating empty new blocks and formatted strings on the fly, 
within the init func.
Ladislav:
14-Jul-2010
serialized

 is an inadequate notion as well, would you call "0.10000000000000001" 
 "serialized"?
Gregg:
15-Aug-2010
My assumption--never assume, I know--was that 'c would always be 
re-bound before each call. I was looking at the action, not the context 
*in* the action.
Anton:
15-Aug-2010
You can call OPEN-WINDOW several times before DO-EVENTS, or add a 
button which calls it.
Anton:
15-Aug-2010
It's not brilliant; in each button action you have to call bind-funcs 
before calling any of the window functions (eg. hello).
Anton:
15-Aug-2010
If you don't like the idea of modifying all your functions, then 
it might be more convenient. Also, you might call bind-funcs just 
once, then call several of your functions afterwards without having 
to pass them anything.
Maxim:
24-Aug-2010
wow, this is so precise, I can time a single call to a native!  :-)
Maxim:
30-Aug-2010
i usually use a random string generated on app startup, the time 
and a random value at each call.  

purists will tell you not to use the system time for the random seed 
.  it creates a time frame of attack which vastly reduces the number 
of hits required for brute force attacks.  


use two independent system data values like disk free size, & a measured 
I/O divided by each other.   a single digit off generates a completely 
different seed, so its much better and cannot be guestimaged easily 
by the attacker.
Gregg:
18-Sep-2010
In any case, write up a proposal, and RT will make the call. It's 
always good to write things down so we don't forget.
Gregg:
21-Sep-2010
I wouldn't call it a gaping hole, I would call it "the intended design". 
:-)
Ladislav:
21-Sep-2010
you guys didn't solve the "how do we use an integer as a key instead 
of an index" - you *can* use integer as a key without using it as 
an index, if you like. Nevertheless, the path-access does not work 
like that. You should either get used to it, or use a different access 
method, that is all. Anyway, you have got no right to call it a "GAPING 
hole in the path evaluation", taking into account, that it is by 
design. The fact, that your design preferences differ is irrelevant.
Ladislav:
21-Sep-2010
It does in this case, your point is irrelevant, since it you are 
trying to call "a hole in the design" something, that provably *is 
the design*
Ladislav:
21-Sep-2010
Not being able to use my radio frequency tuner for TV broadcasting 
may be disliked by me, but I have no right to call such a property 
"a hole in the design" regardless how many other people would want 
to agree with me
Fork:
26-Sep-2010
This isn't a serious question.  Devil's advocacy, or what you might 
call it.  But given Rebol's insistence that "/only" is a somewhat 
opaque modifier speaking about whether the routine in question does 
its "extra" thing or not... wouldn't "unique/only" be a way of saying 
"sort the array in place only, don't do the make copy step"?
Nicolas:
26-Sep-2010
call %/d/something with (parentheses).mp3
Group: !RebGUI ... A lightweight alternative to VID [web-public]
Ashley:
3-Apr-2007
you will find it in the RebGUI directory on xpeers

 ... got it the first time, just making sure I was looking at the 
 most current version. FYI, tooltips had me baffled for a long time 
 (they worked for you, consumed tons of CPU for me) until I realized 
 they were only a problem with the new tab-panel implementation ... 
 which now stores all tabs in a pane and uses the show? attribute 
 to work out which one is visible or not (the original stored hidden 
 tabs in a data block). The fix was simple, change the tooltip code 
 to ignore faces with show?: false.

strip tree widget from drop-tree

 ... the tree widget I'm working on is similar to text-list but with 
 leading triangles (indented by level) that toggle between sideways 
 (close leaf) and down (open leaf). Not sure whether Cyphre's one 
 is based on the same [simple] concept.

Can we somehow align while you do RebGUI 2?

 ... as discussed previously (see post from 10-Mar), with the key 
 points being:


 1) Use (and possible extension) of global UI settings (colors, sizes, 
 effects, behaviors) in %rebgui-ctx.r

 2) Widgets should define a 'rebind func if they need to change a 
 statically bound UI setting (e.g. color)
	3) Use the new tab-panel widget

and a fourth:


 4) Layout uses 'tip (not 'tooltip) to specify the widget's tip string!


Note that the current build has had most widget-specific exceptions 
removed, especially from %rebgui-edit.r; and that /dialog (hence 
popup) code has been rewritten to support true modal dialogs (that 
can in turn call additional modal dialogs). The later improvements 
are courtesy of recent REBOL/VIew popup changes.
Gregg:
5-Apr-2007
I spent a lot of time working on that kind of thing for VB, and also 
used some commercial VBX/OCX packages that included them. Our target 
audience was data entry operators in call centers and, while this 
is what the internal analysts and user contacts said was what they 
wanted, the actual users hated it; it just got in their way. Asking 
around informally, I found that most users didn't care for them, 
while techies thought it was a great idea.
Robert:
6-Apr-2007
actions: We have added a RESET-ACTION. With this I can call something 
like my-form-gui/reset and it will reset all contained widgets to 
some default values. IMO a must have and keeps default values etc. 
near the widget, the source of information.
Ashley:
7-Apr-2007
OK, so the problem is with popups that call popups. When the second 
requestor (font or color) is called does it *initially* appear behind 
the calling requestor, or are you saying that clicking on the calling 
reqestor *allows* the calling requestor to come to the foreground 
and obscure the second popup? (This later behaviour is what occurs 
on Win & Mac).


Secondly, is the second popup modal (i.e. after it appears can you 
still interact with the first popup)? On Win & Mac the popup is truly 
modal (apart from the windowing issue, which I think can be solved 
by use of the 'parent option).
Pekr:
10-Apr-2007
would anyone agree to make following the default rebgui coloring/look? 
Basically to achieve this it is very easy:

1) set 'over to sky
2) change rounding to 1
3) set window color to wather
4) set effect to: gradient 1x1 white water

http://www.xidys.com/new-rebgui-default-look.jpg

I would call it "white water skin" :-)
Ashley:
19-Apr-2007
Worthy addition, although I'd call it /caret and the following line 
should suffice:

	insert at face/text face/caret form text


Not that 'at treats values less than 0 as head and values greater 
than length of string as tail.
Graham:
24-Apr-2007
This is going to be tricky.  Have to create some intermediate function 
to then call the appropriate function ( normal control or shifted 
)
Terry:
22-May-2007
If you happen to have some X10 stuff lying around, you can control 
your appliances with RASH too.. 

Add this to codes.txt .. change the path to your x10comm.exe 


q [fp "kettle on" 20][call "c:\x10\x10comm.exe a1 on" speakout "Kettle 
has been activated" closed]

q [fp "kettle off" 20][call "c:\x10\x10comm.exe a1 off"  speakout 
"Kettle disengaged" closed]


text-to-speech while  flipping on the kettle from Rebol.. serious 
cool factor.
btiffin:
24-Sep-2007
Sorry, don't call show with select-tab
Ashley:
6-Oct-2007
Depends, you can call action functions directly, as in:

	s: button "Save" [...]
	button "Do A then save" [... s/action/on-click s]
	button "Do B then save" [... s/action/on-click s]
Ashley:
25-Dec-2007
The X-Internet bit did get me thinking again about RebGUI server 
applications. Here's my basic thoughts.


We create a server-side RebGUI engine (branded as, say, "RebGUI Server") 
which accepts events other than mouse movements from a RebGUI client. 
The server is responsible for generating displays (as a face object) 
and "running" the app, whilst the client merely displays the faces 
it receives and sends events back.


Is there any value in this idea? (and, "so and so already does this 
so why bother" is a fair call).
Reichart:
1-Jan-2008
Vertical tabs - What are anyone's thoughts on vertical tabs?  They 
look cool, and I can see their use, but they strike me as...well...annoying, 
similar to my issue with Rotary (spinner).  Rotating or obscuring 
information just seems not worth it.

Here is an image of vertical tabs 
http://en.wikipedia.org/wiki/Image:Vertical_tabs_sample.png


Coloured tabs - As to colouring tabs, interesting.  I'm a big opponent 
of colours generally.  One of the most common requests we get on 
our Calendar is to be able to colour meetings.  We ARE indeed going 
to allow this, but I think it is better to keep things neutral.  
On the Mac, meetings are "categorized" into things like Work and 
Personal, each of which are given colour.  This works well in "personal 
calendar systems", but this breaks down very quickly when working 
in a "collaborative calendar system".  

Who gets to decide the colour of something?

What is "something"?  As in, is it by project, by who is in it? By 
what it is (a meeting, a flight, a memo, a call, or other things 
people can put on a calendar now).

All very tricky.
Ashley:
16-Mar-2008
Certainly possible (creating an image of a display is trivial), but 
how would it be used / specified in practice, and what would we call 
this new widget? Perhaps a grouping widget?

	fan data [
		display "A" [...]
		display "B" [...]
		display "C" [...]
		...
	]


which would create a series of clickable display icons ... click 
the icon and that display comes to the foreground. Is that sort of 
what we are talking about?
btiffin:
17-Mar-2008
I tried once.  But it was more an exercise in linking RebGUI menu 
Find/Replace to area ... too many hacks to keep caret in synch, so 
instead of tarnish Dobeash with my lousy code ... I just didn't. 
  But a quick RebGUI display of an area isn't too hard to pull off, 
but you need to rely on the built in key handlers.  Sadly Find/Replace 
is not in the list, but you do get a spell checker 'for free'.  ;) 
  In Ashley's defence, it is not the design intent of RebGUI to be 
an editor.


I've not tried, but Anton has been pumping out a new editor ... may 
conflict less than  editor  dunno, but I kinda doubt it will work 
without the same types of problems.

Alternative is to use CALL and launch an external editor.
shadwolf:
29-Aug-2008
ana  button call for anamonitor wich helps me to debugging and no 
my list-view don't works anymore with recent rebgi version (it was 
done with rebgui 0.36 ... )
Claude:
6-Oct-2008
REBOL[]


rebgui-build: %./rebgui-116/
rebdb-build:  %./RebDB-203/


#include %/home/ramcla/Documents/rebol/rebol-linux-sdk-276/source/gfx-colors.r

#include %/home/ramcla/Documents/rebol/rebol-linux-sdk-276/source/gfx-funcs.r
#include join rebgui-build %rebgui.r
#include join rebdb-build %db.r

do  join rebgui-build %rebgui.r
do  join rebdb-build %db.r

to-amount-text: func[
	data
	/local
	d
][
	d: to-string to-money (to-decimal data)

 return either d/1 = #"-" [join "-" (skip d index? find d #"$")][(skip 
 d index? find d #"$")]
]

table-exist?: func [
	table [string!]	
	/local
	w
][
	w: to-word table
	either error? err: try [db-describe :w][
		disarm err
		return false
	][
		return true
	]
]

create-table: func [
	table [string!]	
	/local
	w
	tables
][
	tables: [

  t_joueurs [id nom prenom date_naissance adresse code-postal commune 
  pays]
		t_periodes [id nom date-debut date-fin status]
		t_jeux [id period_id date lieu]
		t_resultats [jeux_id personne_id manche_1 manche_2 manche_3]

  t_resultat_historique [jeux_id personne_id manche_1 manche_2 manche_3]
	]
	
	w: to-word table
	db-create :w (select tables w)
]


create-db: func [
	/local
	table
][
	if not table-exist? table: "t_joueurs" [create-table table]
	if not table-exist? table: "t_periodes"  [create-table table]
	if not table-exist? table: "t_jeux"     [create-table table]

 if not table-exist? table: "t_resultats"     [create-table table]

 if not table-exist? table: "t_resultat_historique"     [create-table 
 table]
]

create-db

;print screen avec F3
ctx-rebgui/on-fkey/f3: make function! [face event] [
    save/png %screen.png to image! face
    browse %screen.png ; or call %screen.png
]


words: copy []

;	clear words in global context

query/clear system/words

;	show splash screen

splash join rebgui-build "images/logo.png"

;	compose pie-chart data

pie-data: compose [
	"Red" red 1
	"Red-Green" (red + green) 1
	"Green" green 1
	"Green-Blue" (green + blue) 1
	"Blue" blue 1
	"Blue-Red" (blue + red) 1
]



;	wrap display in a func so it can be called by request-ui


display/close rejoin ["Carte (build#" ctx-rebgui/build ")"] [
	

 ;	button "Configure Look & Feel" 50 [if request-ui [unview/all show-tour]]
	
	tight
	after 1
	menu #LW data [
		"Maintenance" [
			"Bienvenue"	[panel-master/select-tab 1]
			"Joueurs" 	[table_joueur 'rsh panel-master/select-tab 2]
			"Periodes" 	[panel-master/select-tab 3]
			"Jeux"		[panel-master/select-tab 4]
		]
		"Option" [
			"Quit"		[quit]
			"Print Screen"  [alert "coucou"]
		]
	]
	
	panel-master: tab-panel options [no-tabs] #LVHW data  [			
		"Bienvenue" [
			
			title-group %./images/setup.png data  "bienvenue" "toto"	
		]
		"Joueurs" [
			label "nom : "
			ask_nom: field 50 
			label "prénom :"
			ask_prenom: field 50
			button "Trouver"
			return
			maintenance_table_joueurs: table 200x50 #LW options [

				"id"                  left     .1
				"nom"                 left     .3
				"prenom"              left     .3
				"date de naissance"   center   .3				
			] data [] [table_joueur 'rtv]

			return
			label "ID :"  35 
			m_joueur_id: field  50 options[info] 
			return
			label "Nom :"  35
			m_joueur_nom: field  50
			label "Prénom :"  35
			m_joueur_prenom: field 
			return 
			label "Date de Naissance :"  35
			m_joueur_date_naissance: field  43 tip "coucou" on-unfocus [
				use[d][
					d: copy face/text
					either empty? d[
						set-text m_joueur_age ""
					][
					 	either error? err: try [to-date d][
							disarm err
							set-color face red
						][
							set-color face CTX-REBGUI/COLORS/page
							d: to-date d
							set-text m_joueur_age (now/year - d/year )
							set-text face to-date d
						]
					]
				]
				true
			]
			arrow [
				use[d][
					if not none? d: request-date[
						set-text m_joueur_date_naissance d
						set-text m_joueur_age (now/year - d/year)
					]
				]
			]
			label "Age :"  35 
			m_joueur_age: field  50 options [info]
			return
			label "Adresse :"  35 
			m_joueur_adresse: area  100x20 [print coucou]
			return
			label "Code Postal :"  35 
			m_joueur_code-postal: field  50
			label "Commune :"  35 
			m_joueur_commune: field 50 
			return
			label "Pays :"  35 
			m_joueur_pays: field 50
			return
			button "Ajouter" [table_joueur 'add]
			button "Refresh" [table_joueur 'rsh]
			button "Update" [table_joueur 'upd]
			button "Supprimer" [table_joueur 'rmv]
		]

		"periodes"[text "lolo"
		]
	
	"jeux"[
text "lolo"]
	] 
	
	message-area: area #LW "" 10x-1	

][question "Vraiement ?"]



table_joueur: func [
	act [word!]
][
	switch act[
		clr[
			clear maintenance_table_joueurs/data
			maintenance_table_joueurs/redraw
		]
		rsh[
			table_joueur 'clr

   insert tail maintenance_table_joueurs/data copy (db-select [id nom 
   prenom date_naissance ] t_joueurs)
			maintenance_table_joueurs/redraw
			probe 	maintenance_table_joueurs/rows
		]
		cmt[
			db-commit t_joueurs
			table_joueur 'rsh
		]
		rmv [
			probe compose[id = (to-integer m_joueur_id/text)]

   db-delete/where t_joueurs compose[id = (to-integer m_joueur_id/text)]
			table_joueur 'cmt
		]		
		add [
			db-insert t_joueurs 
			compose[
				next 
				(m_joueur_nom/text)
				(m_joueur_prenom/text)
				(to-date m_joueur_date_naissance/text)
				(m_joueur_adresse/text)
				(m_joueur_code-postal/text)
				(m_joueur_commune/text)
				(m_joueur_pays/text)
			]
			table_joueur 'cmt
		]
		upd [
			db-update/where t_joueurs 
			[nom prenom date_naissance adresse code-postal commune pays]
			compose [
				(m_joueur_nom/text)
				(m_joueur_prenom/text)
				(to-date m_joueur_date_naissance/text)
				(m_joueur_adresse/text)
				(m_joueur_code-postal/text)
				(m_joueur_commune/text) 
				(m_joueur_pays/text)
			]
			compose[id = (to-integer m_joueur_id/text)]
			table_joueur 'cmt
		]
		rtv[

   foreach [id nom prenom date_naissance adresse code-postal commune 
   pays] db-select/where * t_joueurs compose[id = (first maintenance_table_joueurs/selected)] 
   [
				probe maintenance_table_joueurs/selected
				set-text m_joueur_id id 
				set-text m_joueur_nom nom
				set-text m_joueur_prenom prenom
				set-text m_joueur_date_naissance date_naissance
				set-text m_joueur_age (now/year - date_naissance/year)
				set-text m_joueur_adresse adresse
				set-text m_joueur_code-postal code-postal
				set-text m_joueur_commune commune
				set-text m_joueur_pays pays								
			]
		]
	]
]



do-events
Claude:
9-Oct-2008
;print screen avec F3
ctx-rebgui/on-fkey/f3: make function! [face event] [
    save/png %screen.png to image! face
    browse %screen.png ; or call %screen.png
]
Ashley:
6-Dec-2008
Shouldn't be ... both display and layout just generate a bunch of 
view faces at the end of the day. If it's really an issue you can 
always call system/words/layout from within RebGUI for those layouts 
that must be VID generated.
DideC:
22-Jan-2009
In VID you can handle F keys by window with the event handler of 
the window. Hope that what you call a screen is a window :-\
Graham:
14-Apr-2009
This isn't strictly a Rebgui question ... but here goes.  I want 
to double click on a word and perform an action.  That action involves 
interacting with some gui elements on the current screen.  Now, there 
is a function 'hilight-text inside the rebgui 'edit object which 
is inside the rebgui-ctx context.  So, I can hook in there with my 
dbl-click function.  But how to make it call my function which is 
defined for each window?
Graham:
27-Apr-2009
Perhaps view needs a way to call a callback after it has substantiated 
the new window ...
Ashley:
21-Jun-2009
Uploaded build 120 which addresses the stack-overflow issue (and 
as a by-product drastically cuts the number of calls to next-field/back-field 
when tabbing) ... please test.


I'll also echo Graham's call for issue tracker submissions, as I'm 
now prioritzing fixes based on what's in there.
marek:
8-Sep-2009
More discoveries. Set-text by indirect reference doesn't work when 
field is disabled, but still works by direct call.

[p1: panel data [f1: field disable] button [set-text p1/pane/1 "1"] 
button [set-text f1 "2"]]
It did work ok before 200.
Pekr:
14-Oct-2009
As append-widget removal was oversimplification imo, especially for 
the widget authors, I created short script, which kind of automates 
the process ....

1) Save the script, e.g. make.r, into the RebGUI root dir

2) create one file, called %my-widget-list.r, containing unnamed 
block, containing file-names. Your widgets can be placed anywhere

3) create backup of %rebgui-widgets.r, call it %rebgui-widgets.old.r, 
in order to be able to easily "remove"  widgets by commenting them 
out in file 2)

Here's the script:
REBOL []

;--- to enable removal of unwanted own widgets, create
;--- copy of rebgui-widgets.r into rebgui-widgets.old.r

;--- remember to do so, when official distro release contains new 
widgets!
if exists? %rebgui-widgets.old.r [
  write %rebgui-widgets.r read %rebgui-widgets.old.r
]

;--- load list of widgets you want to include
;--- file containing un-named block of list of files to include
widgets-to-include: load %my-widget-list.r

template: "^-#include %widgets/^/"

;--- read RebGUI widget list (%rebgui-widgets.r)
tmp: read %rebgui-widgets.r

widget-buffer: copy "^/"

foreach widget-filepath widgets-to-include [ 

   widget: last split-path widget-filepath

   ;--- copy widget to the widget-directory
   write join %widgets/ widget read widget-filepath
  
   ;--- build string containing widget names you want to add ...

   ;--- but only when not already on the list - prevent duplicate entries
   if not found? find tmp widget [

        append widget-buffer (head insert find/tail copy template "/" widget)
   ]

]

;--- append to RebGUI widget-list (%rebgui-widgets.r)
change back back tail tmp (append widget-buffer "]")
write %rebgui-widgets.r tmp

;--- rebuild RebGUI distribution ...
call "create-distribution.r"
Graham:
27-Sep-2010
If you have something like this

b: button "text" on-click [ print face/text ]

you can't call the button action like this

b/action/on-click b


because the on-click action refers to 'face, and 'face is not passed 
when called this way.

What's the appropriate workround apart from using named faces ?

eg. on-click [ print b/text ]
Group: !REBOL3-OLD1 ... [web-public]
Steeve:
25-Apr-2009
further...

Take the implementation of modules and protect stuffs, I agree it 
may be (maybe) deeply modify the core and it's why it's must be done 
now, accordingly Carl and BrianH.
But for a user concern, it has a very low priority.

It's only of interest for those who want to create new commercial 
applications with R3, in few years....

But we will not develop new applications, if some important things 
that were  working in R2 are not working anymore in R3.
It's what i call high priority, NO REGRESSION allowed.
BrianH:
27-Apr-2009
For that matter, half of DO is mezzanine, or rather "intrinsic" - 
what we call REBOL code called internally by native code.
1501 / 249112345...1415[16] 1718...2122232425