World: r4wp
[Rebol School] REBOL School
older newer | first last |
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. |
GiuseppeC 10-May-2012 [278x2] | Henrik: With your permission I write your text to my blog. Also I'll study it later |
A question: I create a layout wiich has two button. I whish to add more buttons dynamically updating the layout. How could I do this ? | |
Henrik 10-May-2012 [280x2] | GiuseppeC: Go ahead. |
You can do this by adding the buttons to a panel and update the contents of this panel. view/new layout [p: panel 500x500 []] ; start with an empty panel. note that VID does not support scrolling panels out-of-the-box. For this you need the VID Extension Kit. append p/pane make get-style 'button [] ; you will need to adjust for offset here, otherwise the new phase will be placed on top of the old one. do in last p/pane 'init ; you will need to initialize the face, which is the FACE/INIT block that resides in the face style definition. once the init block has been run, the face will set itself up and then you can show it show p This is just a simple version of what can be done. To clear it again: clear p show p If you want to do more than this, I think you need to use the VID Extension Kit, because you will be spending a lot of time managing scrollbars and panels. It has styles that are meant for this purpose. | |
GiuseppeC 10-May-2012 [282] | Thanks Henrik, I'll do one things at time. This is starting to be difficult. |
Henrik 10-May-2012 [283] | You might now begin to experience the VID learning curve turning into a wall. Suddenly you need to know a lot about its internals to do fairly trivial things. |
Endo 10-May-2012 [284x2] | I wrote another simple example as a one-liner, not useful in a real-world app. but gives an idea: view f: layout/size [btn "add" [append f/pane layout/tight/offset [backcolor random white btn random "abcdef"] 50x50 + random 300x300 show f]] 400x400 |
It actually adds new faces to the main face's pane, not the new styles. So, not a useful example. ;no need to backcolor.. shorter: view f: layout/size [btn "add" [append f/pane layout/tight/offset [btn random "abcdef"] 50x50 + random 300x300 show f]] 400x400 | |
Endo 14-May-2012 [286] | how to use trim/auto? it says "auto indents relative to first line" but; >> print trim/auto ajoin [tab tab "test" newline "line 2"] test ;no indentation? line 2 ;no indentation? |
ChristianE 14-May-2012 [287x2] | It removes as much whitespace from consecutive lines as it removes from the first: >> print trim/auto ajoin [tab tab "test" newline tab tab tab "line 2"] test line 2 |
To be precise: It removes up to as much whitespace. | |
Endo 14-May-2012 [289] | I see, thank you. So it actually does not auto indent relative to the first line: >> print trim/auto ajoin [tab " test" newline tab tab "line 2" newline tab "line 3"] test line 2 line 3 |
ChristianE 14-May-2012 [290x5] | If it's inserting whitespace according to the first line I'm afraid there isn't such functionality available out-of-the-box. And if there was, TRIM wouldn't probably be a good name for it, then ;-) |
Anyways, I'll have a go with: | |
indent: funct [string [string!]] [ whitespace: charset "^- " indention: line-start: content: none parse/all string [ copy indention any whitespace any [thru "^/" line-start: any whitespace content: (insert remove/part line-start content indention) :content] ] string ] | |
>> print indent ajoin [tab " test" newline tab tab "line 2" newline tab "line 3"] test line 2 line 3 | |
Or what else is it what you're wanting to do? | |
Endo 14-May-2012 [295x2] | hah! I wrote something similar: indent: func [s /local x] [parse/all s [x: (insert x "^-") any [thru newline x: (insert x "^-")]] s] |
It's simple but it solves my issue. | |
JohnM 14-May-2012 [297x2] | Hello, all. I am new to REBOL4 and while having followed Lava to REBOL and looked through tutorials every year once a year for more than 10 years I have only recently began making an actual REBOL script. |
I hope it is not rude to leave a question here as opposed to be here for the disucssion live, ala IRC. Please forgive me if so, and if so I will ask again when others are present. I will break down my script into smaller part questions as time goes on. First thing, I am under the impression that if I can generate a random number between 1 and 1 billion and assign this result to an aribtray variable word like so token: random/secure 1000000000 I want to email my newly generated random number to someone. So I thought of this: send [person-:-example-:-com] "Thank you. Your number is token." One second later I realized that will just the send the actial word token, not the number the variabkle word token represents. Is the above a correct way to generate a random number? How do I insert that random number into the body of the text of an email to send someone? (send [person-:-example-:-com] "Thank you. Your number is [token]" maybe?) Thanks for your help in advance, apologies for any breach of rules or etiquette. etiquetteetiquette | |
older newer | first last |