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

World: r4wp

[Rebol School] REBOL School

GiuseppeC
7-May-2012
[228]
Henrik, I am experimenting with your code.

Here is  my code:

view layout [
	testo-id: h2 
]

update-window: func [ttesto-id] [
	testo-id/text: to-string ttesto-id
	show [testo-id]
]

I have the following error:

Error: Invalid path value: text
james_nak
7-May-2012
[229]
update-window: func [ttesto-id] [
	testo-id/text: to-string ttesto-id
	show testo-id
]

view layout [
	testo-id: h2 "hello" []
	button {test} [update-window {world}]
]
GiuseppeC
7-May-2012
[230]
James, I'll try it tomorrow. Too late for my mind. Thank you.
Henrik
7-May-2012
[231]
Remove the argument to FUNC in the UPDATE-WINDOW function, and it 
should work
Endo
8-May-2012
[232]
NOW returns current datetime and GMT. If I changed my GMT settings 
REBOL doesn't reflect the new settings.

Is there anything I can do to get new GMT settings? Otherwise long-running 
tasks cannot get the correct GMT. Any idea?
BrianH
8-May-2012
[233x5]
I think you mean time zone, Endo. GMT is one of the time zones, mostly 
the same as UTC.
If you are running your app on a system that might switch time zones, 
it's best to keep track of time internally in the UTC zone (+0:00). 
This is a little different for R3 and R2.


R3: Use now/utc to get the UTC version of a datetime, or for a stored 
datetime d use d/utc. It does the math for you.


R2: Whenever you get the time, subtract the zone offset from the 
datetime, like this:
>> d: now
== 8-May-2012/11:36:01-5:00
>> d: d - d/zone
== 8-May-2012/16:36:01-5:00
>> d/zone: none
== none
>> d
== 8-May-2012/16:36:01
If you need to recreate local time, add back the local time zone 
offset, like this:
>> d: d + now/zone
== 8-May-2012/11:36:01
>> d/zone: now/zone
== -5:00
>> d
== 8-May-2012/11:36:01-5:00
These should probably be wrapped into TO-UTC-DATE and TO-LOCAL-DATE 
functions, so the R3 vs. R2 differences can be resolved.
Keep in mind that your time zone can change for daylight savings 
time, if your region does that. You don't necessarily have to move 
to change time zones.
Endo
8-May-2012
[238]
Thank you BrianH.

My question is, REBOL process (console or encapped app.) doesn't 
automatically detect of the time zone settings change of the PC.
>> now/zone
== 3:00

>> ;I changed my local time zone to +2 GMT or it changed automatically
>> now/zone
== 3:00


Is there a way to "refresh" zone in NOW, without closing and reopening 
the app.

Let's say I get the Windows time zone using a Win32 API. Then something 
like
>> now/zone: 2:00
== 2:00
>> now
== 8-May-2012/23:45:16+3:00 ;doesn't work
Gregg
8-May-2012
[239]
There is no way to force a refesh AFAIK. I think this may be part 
of the IOS issue with DST changing all files to red.
GiuseppeC
8-May-2012
[240]
Hi, I need again your help:
I have an invalid image in my database.
I update images inside my window and I use this code:

	if not error? [to-image load news/immagine] [
		immagine/image: to-image load news/immagine
	]

I have tried this code too:

	if not error? [picture: to-image load news/immagine] [
		immagine/image: to-image load news/immagine
	]
However I get the following error:

Script Error: Invalid argument: make image! [170x78 #{
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFF...
** Where: to-image
** Near: to image! :value

The error is generated from the block following the IF

Why I am not able to catch the wrong image ?
Endo
8-May-2012
[241]
There should be TRY:
if error? try [...]
GiuseppeC
8-May-2012
[242x2]
Thanks I am starting to forgive the basics of REBOL
* forget
Endo
8-May-2012
[244]
by the way, LOAD will detect if the argument is an image. So there 
may no need TO-IMAGE.


unless attempt [immagine/image: load news/immagine] [immagine/image: 
load-image %default.png]
GiuseppeC
8-May-2012
[245x2]
I have had an error previously. Now it seems to work.
Thanks
Now I have another problem: I have a "description" text field I get 
from internet and it is "untagged".  The field is very long.

When I update the field with an empty string in VID I get strange 
characters.
Endo
8-May-2012
[247]
Hmm.. LOAD might load the file even if it is not an image. So you 
may need to TO-IMAGE, or check the datatype after loading:
attempt [img: load %file if image! = type? img [...]]
GiuseppeC
8-May-2012
[248]
It seemd that when the size of the text returns to 0 the text area 
is not correctly updated and some characthers are being taken from 
memory.
Endo
8-May-2012
[249]
strange characters

: You need to set /line-list of your VID widget to show it correctly.
GiuseppeC
8-May-2012
[250]
Line-list ? What is it ?
Endo
8-May-2012
[251x3]
layout [x: text "test"]
;update x/text with a long text
x/line-list: none
show x
it is a internal field to store text in VID widgets (its about word 
wrap I think)
Here is some info:
http://www.rebol.com/docs/view-face-object.html


A block that holds text line information. This block is created, 
updated, and used by the system to optimize the updating of text. 
When you modify large areas of text (greater than 200 characters) 
you should set this variable to zero to force the system to recompute 
the positions of all lines. If you do not, you may see garbage characters 
appearing within the text.
GiuseppeC
8-May-2012
[254x2]
Not enough memory !
Something wrong here.
Endo
8-May-2012
[256]
Try to WRITE to a file the text you read from the web, it might be 
VERY long?
GiuseppeC
8-May-2012
[257x3]
I have restarted REBOL. The error has gone
However I use RebDB to retrieve the text and it returns an empty 
string
When I update the widget with the empty string weird characters appear 
!
Endo
8-May-2012
[260]
Its better to set line-list to none for every update.
GiuseppeC
8-May-2012
[261]
When I update the widget with the empty string weird characters appear 
!
Endo
8-May-2012
[262]
Garbage chars may appear if you don't. Read the above note.

Either way, you set some long text, or clear it when there was some 
long text.
GiuseppeC
8-May-2012
[263x2]
Tomoorw I'll try. Thanks for your help. Now it is time to go to BED
Ciao !
Endo
8-May-2012
[265]
For me too :) Bye!
Endo
9-May-2012
[266]
What does PATH function?
BrianH
9-May-2012
[267]
It's internal, exported as a side effect of it being an action, used 
as part of path evaluation. Don't use it.
GiuseppeC
9-May-2012
[268]
Next level !

Any suggestion about creating a dynamic built GUI ? I whish to create 
a GUI from a Block of data, each data is a button and each button 
has an action attached to it.
Could you please point me to some code to analize?
Thanks in advance
james_nak
9-May-2012
[269]
Giuseppe, you can experiment by creating your gui code as a block 
and then "do" it. Then view it.
a: [layout [button "hi" [print "hello"]]]
b: do a
view b
Gregg
9-May-2012
[270]
http://onlamp.com/pub/a/onlamp/2003/10/30/rebol.html
Endo
9-May-2012
[271]
BrianH: Thanks for the info. It corrupts when I try it on objects. 
And wierd effects on blocks.. I've added "unset 'path" to my rebol.r 
file, so I won't be confused anymore.
BrianH
10-May-2012
[272]
Let us know whether you find that it's safe to unset 'path and reuse 
it for other stuff. There's no reason to think that the action! mechanism 
would call the function through its name (that's more of an R3 intrinsics 
thing), but any unpredictable behavior you find would be good to 
know.
GiuseppeC
10-May-2012
[273]
Gregg, a little difficult for me but I'll try to lear.
Gregg
10-May-2012
[274]
Keep asking questions Giuseppe. Dynamic GUIs is a big subject, so 
if you ask more specific questions, that makes it easier to craft 
small answers and examples.
Henrik
10-May-2012
[275]
Perhaps it helps to learn about the mechanisms: There are several 
ways to generate a dynamic UI:


The LAYOUT function works by creating an object tree, a tree of faces 
that are simply ordinary objects. When passing this to the VIEW function, 
a layout is displayed. The layout function is part of VID and is 
as such a high level function. VIEW is a low level function to interpret 
the face tree.


The face tree consists of objects that contain other objects through 
the FACE/PANE word. If the FACE/PANE contains an object, that object 
is a single face, that is displayed inside the parent face. If the 
PANE contains a block, that block may contain multiple objects that 
are simply multiple faces. As such, a typical window is a face with 
a FACE/PANE that is a block that contains other objects.


Graphically, the face is represented by a region on the screen that 
has the size and offset, possibly an effect, such as coloring, blur 
or mirroring or a text attached to it, and image or other faces that 
are only visible inside that region.

A window is also a face.


To navigate to the parent face from a face, use the FACE&/PARENT-FACE 
word. Note that FACE/PARENT-FACE is many times not set by VID, which 
is sometimes problematic.


You can manipulate the face tree by adding removing objects dynamically 
and calling the SHOW function. You can also change values in existing 
face objects in the tree, such as for resizing or moving the faces 
and then calling SHOW again. You can also build a face tree entirely 
by hand, and this is usually the starting point for different layout 
engines, such as RebGUI, that simply build face trees in their own 
way.


The prototype face is FACE, which is a minimum requirement face for 
the View engine. The prototype face for a VID face, which contains 
a few more words, is SYSTEM/VIEW/VID/VID-FACE, which is the minimum 
requirement face for VID.


One condition for the face tree is to not use the same object in 
multiple locations. The VIEW or SHOW function will return an error 
if that is the case.


A simpler way is also to generate a new face tree every time you 
want to change the layout. Although this is slightly more computationally 
heavy, it allows you to manipulate the block that was passed to the 
LAYOUT function instead of manipulating the face tree directly. This 
technique is best used, when the face tree changes dramatically by 
each manipulation.


Another important concept is the DRAW engine which is a separate 
entity in REBOL2. It can be called to draw on an image bitmap, using 
the DRAW function or as in effect for a face object, by adding a 
parameter in the VID dialect block or by changing the FACE/EFFECT 
word. DRAW is used by calling a dialect. if you just want to use 
fields, buttons and simple user interface designs, you may not need 
to use DRAW.
Gregg
10-May-2012
[276]
Very nice Henrik.
Henrik
10-May-2012
[277]
I should add that it is possible for FACE/PANE also to be a function. 
This makes the face into an iterated face, where using a loop, you 
can "stamp" the face in various positions during a single SHOW, making 
it possible to use one face  with different texts, sizes and offsets 
to produce a grid or a table.