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

World: r4wp

[Rebol School] REBOL School

Henrik
6-May-2012
[204x2]
First, assign words to your texts:

view layout [
	t1: h2
	t2: h2
]

Then create a function to update the content:

update-texts: func [tt1 tt2] [
	t1/text: tt1 ; not sure that SET-FACE works here.
	t2/text: tt2
	show [t1 t2]
]

Then use the function where you need it.
You may need to give both faces an initial width, otherwise the text 
won't fit.
Endo
7-May-2012
[206]
Or give a name to your window:
view lay: layout [...]

and call "show lay" when you make changes. This will refresh the 
whole widgets in the window.

It's better to refresh what you've updated, not the whole window, 
as it is much more slower. But when you are testing it is easier.
Henrik
7-May-2012
[207]
This is only partly true.


It is in fact faster to SHOW the whole window, rather than calling 
SHOW multiple times for single elements, when there are sufficiently 
many elements in the window. Still, SHOW also depends on the size 
of the area to display, so if you have, say 10 fields, wrap them 
in a PANEL style and then perform the SHOW on the PANEL instead of 
the whole window or the individual fields.
Endo
7-May-2012
[208]
That's right. What I meant was SHOWing the whole window when you 
need to refresh one element, is slower. Otherwise it depends on how 
many items refreshed/updated etc.

It is easier to SHOW the whole window for beginners because they 
usually forget to SHOW the item they've updated.
GiuseppeC
7-May-2012
[209x2]
Isn't in VID a god text viewever with scrollers ? Text List does 
not work here. It show only the first line of text.
*good
james_nak
7-May-2012
[211]
Giuseppe, if it is textviewers that you are looking for, you may 
want to see Henrik's Vid Extention Kit.  http://www.hmkdesign.dk/project.rsp?id=vid-ext-kit&page=info
because if you are going to do anything slightly more complex than 
VID "text-list"  you will find data-list much more powerful. BTW, 
what are you supplying as data in your text-list?
Gregg
7-May-2012
[212]
The LIST style is very flexible for read-only displays, but more 
work.
Arnold
7-May-2012
[213]
nearly 11000 lines, almost replacing VID
Henrik
7-May-2012
[214]
The number of lines may go up or down at times. There is a lot of 
experimental code and some dead code in it.
GiuseppeC
7-May-2012
[215]
I am supplying text coming from a web page which has been de-markupped.
Arnold
7-May-2012
[216]
Just make sure you never get paid per line of code
Henrik
7-May-2012
[217]
Never made a dime on it.
Arnold
7-May-2012
[218]
Not many people can make a living programming REBOL. That's for the 
Chit chat section
GiuseppeC
7-May-2012
[219x2]
Henrik, just looking to your code:
t1/text: tt1

I read it: assign to the object member T1/ text the new value ?

Where is this documented ? I whish to learn more.
Henrik
7-May-2012
[221x2]
A face is an object, so this is no different than saying:

a: make object! [text: "foo"]

a/text: "boo"
A problem with VID is that there is not a true standard way to set 
texts in various styles, so each style may either use /TEXT (which 
is IMHO the wrong way) or SET-FACE (which IMHO is the right way).
GiuseppeC
7-May-2012
[223]
An what about updating an image ?
Henrik
7-May-2012
[224]
Then you access /IMAGE.
GiuseppeC
7-May-2012
[225]
I acutually use:
image to-image load news/immagine
Henrik
7-May-2012
[226x2]
The dialect way and setting it outside the dialect is different. 
I prefer never to use the dialect to set face data, other than button 
names and fixed labels, as they don't change anyway.
The VID Extension Kit mostly solves this by not needing to know the 
quirks of each face. You just use SET-FACE consistently.
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.