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

World: r4wp

[Rebol School] REBOL School

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.
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.