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

World: r3wp

[View] discuss view related issues

Graham
8-Jul-2007
[7077x2]
and when you detect the disk, then bring up the main gui
I mean system tray
Pekr
8-Jul-2007
[7079]
Graham - I used one trick, I defined new style in VID, called init, 
set rate to 1and defined engage block. After first call, I removed 
timer, but it worked in a bit weird way. In my copy routine I used 
little wait, but it did not work properly ...
btiffin
8-Jul-2007
[7080]
Pekr;  did you show the face after changing the rate?  I got caught 
up by that one recently, the timer fires at old rate until show was 
called.  It is documented, but who reads those.  :)
Pekr
8-Jul-2007
[7081]
yes, I used show ...
btiffin
8-Jul-2007
[7082]
Thought so...wanted to mention it...just in case.
Pekr
8-Jul-2007
[7083x2]
but it is possible my code could be messed-up ....
I really miss delayed after-init method in VID. 'do nor parens can 
make it, as those are executed during layout evaluation, not after 
'view is called ...
Gabriele
8-Jul-2007
[7085x2]
petr, while you are busy copying, you are not handling events, so 
no do-events there. you can call wait 0 every iteration if you want 
to respond to events while copying.
delayed after init is the same as doing something AFTER view/new
btiffin
8-Jul-2007
[7087]
And just think...everything is about to change and we get a whole 
new can of worms to dig through.  The one comment Carl made about 
'hard-won knowledge' has me a litlle, umm, exitedly anxious for the 
docs.
Gabriele
8-Jul-2007
[7088]
hmm, don't see much change in a case like this, you still do the 
layout, view/no-wait it (new ref name instead of /new), and do the 
copy. maybe, you'll want to copy in a bg task, but that's another 
story.
btiffin
8-Jul-2007
[7089]
Excitedly anxious for docs...   But, take your time.  "when do we 
get it, when do we..."  :)
Pekr
8-Jul-2007
[7090x2]
Gabriele, I do following:

copy-dir: func [from to][recursive copying function here]
copy-screen: layout [layout of screen code here]

forever [ if new drive is detected and contains particular directory, 
view copy-screen, which should start copy-dir function]


.... somehow can't get it working properly. View/new can't help me 
here imo ....
Gabriele - how could I do it with view/new? I can't start copying 
after it, because I want to update screen. I can show some elements, 
but e.g. buttons will not be active, unless do-events is being run. 
That is why I complicated my script by implementing "delayed" copying 
= view copy-screen, there is an 'init style with rate 1 and engage 
defined. I check if it is a first run, and if so, I set rate to none, 
call show, and that is the place from  where I call my copy-dir function 
.....
Gabriele
8-Jul-2007
[7092x3]
petr, if copy is running, events are not processed, no matter how 
many do-events you put there
you have to do view/new, then inside copy-dir you need to call wait 
0 every now and then (eg. every file you copy) if you need your buttons 
to work.
even if you call copy-dir from engage, events are not processed while 
inside copy-dir unless you call wait
Pekr
8-Jul-2007
[7095]
ah, so wait 0 causes processing of events?
Gabriele
9-Jul-2007
[7096]
those that are pending, yes. you can wait a little more to allow 
more to be processed, if you don't care about slowing down your copy.
amacleod
9-Jul-2007
[7097]
How are you detecting the the disk being inserted. Are you accessing 
the os. Also, would this work for flash disks?
Pekr
9-Jul-2007
[7098x3]
yes, it works ...
it is very simple principle ... well, it is not even a detection. 
When my script runs in the background, it does:

root: %/
drives: read root

later on, I simply check:

forever [
  wait interval
    foreach disk difference read root drives [
    ]
]
... and difference on block will throw you new disk ....
amacleod
9-Jul-2007
[7101]
That seems simple. I wanted to create an auto cd burner. That routine 
would help!
Pekr
9-Jul-2007
[7102]
can I somehow have layout defined in the manner, that I can:


1) reinitialise it (I can imagine something like store-screen: [copy-dir-screen: 
layout []] do store-screen

2) how can I "unset" it, "uload" it, whatever, to be able to reset 
all its words?
ICarii
9-Jul-2007
[7103]
like this?
window: func [param1 param2 param3 ..][
	layout compose/deep [btn "Exit" [unview face/parent-face]
]
Pekr
10-Jul-2007
[7104x2]
Thanks, that might work, but not sure it is what I want. Maybe I 
don't need it, so here come further questions:

- I want to run infinite loop script
- I want small screen to be displayed during copy

- I want to keep memory low, so I want to "unload" all screen related 
objects from memory


Now - is that possible? With above wrapping function, by calling 
it, I can get new/fresh layout, so variables being reinitialised. 
But when the copying is done, can I remove objects defined by layout 
from memory? Unsetting 'window will just unset the function, but 
I am not sure it following would help?

window: does [copy-screen: center face layout []]
forever [
view/new window
copy-dir
unview copy-screen

unset 'copy-screen (and other VID defined words referring to styles)
recycle
]

?
hmm, above does not free any significant memory ....
btiffin
11-Jul-2007
[7106x2]
Pekr;  This is in free-mem.r from the library by DocKimbel and Shadwolf...I 
haven't played with it, and I don't know if it's any better than 
unset with newer REBOLs
; the free mem function
free-mem: func ['word] [set :word make none! recycle]
unset in 2.7.5.4.2 frees memory,  1.3.2.4.2 unset does not but make 
none! 0 does lower system/stats on a recycle.   I think make none! 
2000'000'000 will work too, but that seems kinda funky.  :)
Pekr
17-Jul-2007
[7108]
What would be the best strategy to take, to achieve following? Imagine 
app with say 20 forms. It is insane and unnecessary to keep everything 
in memory. We should have even option to prevent tabs from doing 
so.


So I am thinking of a method to load/unload screens (forms), but 
freeing a memory. Of course you want to remember the state of widgets. 
So - can I somehow save the form, state of its widgets, unload it 
from memory, and load and reinitialise it at will?
Graham
17-Jul-2007
[7109]
memory is cheap
Pekr
17-Jul-2007
[7110x4]
:-)
That might be a solution :-)
what I am asking for though, is kind of cocneptual aproach to the 
topic, if you would think memory constrained environments for e.g. 
Just curious, what the possible aproach could be ....
other than that, I do agree with your argument :-)
Graham
17-Jul-2007
[7114x2]
how about defining the layouts and widget variables inside a function?
I do that a lot
ICarii
17-Jul-2007
[7116]
Pekr: i normally create view objects by using a func - but GC doesnt 
handle things very well with multiple calls to the same func :(
Graham
17-Jul-2007
[7117]
If you're memory constrained, I wouldn't use VID!
Pekr
17-Jul-2007
[7118x2]
That is my question in Core group - does function call, once finished, 
discard its context? If not, you will not save memory either. You 
would have to unset your func, recycle, and define it later once 
again ...
Graham - I am curious what will happen after R3 release. Theoretically, 
we should get VID more memory savy. I wonder if there will still 
be place for RebGUI (my opinion is - why not, right?)
Gregg
17-Jul-2007
[7120]
If you are *really* constrained, create your UI with draw commands 
and manage events and everything yourself. Of course, you may end 
up with so much more code that it's a moot point, so it depends on 
what constraints you have. 


It reminds me of when VB1 came out, and people tried to use thousands 
of text boxes to create spreadsheets, which was slow, resource hungry, 
and limited in size, because you could only create so many windows. 
The common question was "How does Excel do it then?", and the answer 
was that Excel (v3 at the time I thnk) created only 3 (or so) actual 
GDI windows, everything else was rendered, and interaction handled, 
dynamically
BrianH
17-Jul-2007
[7121]
If you are really, really constrained, use a wrapper around the native 
GUI controls for your platform, carefully. Only cell phones and other 
embedded platforms are that constrained though.
Pekr
17-Jul-2007
[7122]
Thanks for your input guys. I am not constrained that much. Our kiosk 
PCs do have 256MB of memory, being older PCs, some Duron 1.2 or so, 
WinXP. It runs presentation in full mode, local Apache based. Plenty 
of photos, simply kiosk presenation, not ordinary web pages. Dunno 
how IE is memory hungry. My script, which will run in background, 
easily eats some 39MB memory. I did some unsets, recycles, so while 
in wait mode, script goes down to some 24MB. It is that I was just 
curious how to aproach that ...
Gregg
17-Jul-2007
[7123]
Carl once said "View is miserly, saving pennies, while VID is like 
the government, spending millions".
Ingo
23-Jul-2007
[7124]
Hi, I'm trying to visualize data I get from a network port within 
a view window. IIRC using wait within a view handler is greatly discouraged 
(and my first tests seem to show it: the window is updated for the 
first info, but the updates stop after the second, or so. )
So, how do I connect to a tcp port from within /View?
ICarii
23-Jul-2007
[7125]
depending on your display needs you could set a rate in a view face 
for interval polling and catch the 'time event under engage - the 
application could then check a data pool/dump area that is being 
generated in a forever loop or something similar by a tcp watcher
Ingo
23-Jul-2007
[7126]
Hi ICarii ... what do you mean? Having 2 rebol instances, one that 
listens on tcp and creates a file, which is then read by the other, 
and used for display?