Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Rebol view fields are caching entries - HELP

 [1/6] from: yvan_iigs:gmx at: 12-Nov-2006 16:45


Hello together, I think I'm turning in circles. I want to open a layout with a field where I can enter a filename and a button 'Edit' to open the file with the filename I entered and allowing me to edit it. The editing stuff works more or less, but I have a very strange problem. To explain it I created to very crude functions with just enough code to show you the problem. The functions: select-file: a layout with a field where I can enter the filename. A default value of none is used. A button 'EDIT' which by pressing it would call a function 'edit-file' with the filename I entered or doing nothing if the default value of none is still in it. A button 'CANCEL' which just quits the function edit-file: Would do the editing stuff, but as this is not the problem I just entered dummy code, Okay, what is the problem. -Start "select-file" for the first time -> a view opens with a filename in the field of "none" as expected. -Now enter dada as filename and press EDIT -> works as expected -Now, start "select-file" a second time -> a view opens with a filename in the field of 'dada' instead of 'none' ,and this is very disturbing, unexpected stuff. I tried many things, clearing strings, enabling trace, jumping out of the window, but I am not able to find the reason of this problem. what I want is that every time I start this function the default value of 'none appears in the field. Who can help me please. Cheers Yvan PS: The code: file 'createfile.r' REBOL [title: "Creates File"] select-file: func ["enter name manually and then edit"] [ view layout [ text "filename" filename: field "none" button "Edit" [ if/else NOT (filename/text = "none") [ unview edit-file filename/text ] [ view layout [ text "No filename selected" button "OK" [unview] ] ] ] button "CANCEL" [unview] ] ] edit-file: func [ filen ] [ print "Will do some editing stuff" ] Mit freundlichen Gr=FCssen Yvan=

 [2/6] from: rebol::ccsducto::com::ar at: 12-Nov-2006 16:37


Hi Yvan, A blind hit, the spec of layout is a block (a serie), then if you use view layout copy [specs] instead of view layout [specs] every time you call the function a clean layout specs is used César

 [3/6] from: ryan:practicalproductivity at: 12-Nov-2006 13:56


Hi Ivan, the problem is with the following line: filename: field "none" View itself does not actually cache the value, what isgoing on is the string "none" does not change to a new string, so it keeps the last value. In other words, layout sets the fields internal string to be the exact string which you wrote as "none". Basically all series values are pointers, even when they are not assigned words. The "fix" is quite simple though, its simply to copy that string with each call of the function, like so: filename: field (copy "none") Now you will have a fresh new string each time. --Ryan Yvan wrote: Hello together, I think I'm turning in circles. I want to open a layout with a field where I can enter a filename and a button 'Edit' to open the file with the filename I entered and allowing m= e to edit it. The editing stuff works more or less, but I have a very strange problem. To explain it I created to very crude functions with just enough code to show you the problem. The functions: select-file: a layout with a field where I can enter the filename. A default value of none is used. A button 'EDIT' which by pressing it would call a function 'edit-file' wi= th the filename I entered or doing nothing if the default value of none is still in it. A button 'CANCEL' which just quits the function edit-file: Would do the editingstuff, but as this is not the problem I just entered= dummy code, Okay, what is the problem. -Start "select-file" for the first time -> a view opens with a filename in the field of "none" as expected. -Now enter dada as filename and press EDIT -> works as expected -Now, start "select-file" a second time -> a view opens with a filename in the field of 'dada' instead of'none' ,and this is very disturbing, unexpected stuff. I tried many things,clearing strings, enabling trace, jumping out of the= window, but I amnot able to find the reason of this problem. = what I want is that every time I start this function the default value of= 'none appears in the field. Who can help me please. Cheers Yvan PS: The code: file 'createfile.r' REBOL [title: "Creates File"] select-file: func ["enter name manually and then edit"] [ view layout = [ text "filename" filename: field "none" button Edit = [ if/else NOT (filename/text = "none") [ unview edit-file filename/text ] [ view layout = [ text "No filename selected" button "OK" [unview] ] ] ] button "CANCEL" [unview] ] ] edit-file: func [ filen ] [ print"Will do some editing stuff" ] = Mit freundlichen Gr=FCssen Yvan -- Ryan S. Cole Software Engineering Director Practical Productivity Solutions www.practicalproductivity.com[1] Tel: 707-274-8226 --- Links --- 1 http://www.practicalproductivity.com

 [4/6] from: lmecir:mbox:vol:cz at: 12-Nov-2006 23:50


Yvan napsal(a):
> Hello together, > I think I'm turning in circles.
<<quoted lines omitted: 69>>
> Mit freundlichen Gr=FCssen > Yvan
I suppose this may be what you want: REBOL [title: "Creates File"] select-file: func [ "enter name manually and then edit" /local no-filename ] [ no-filename: copy "none" view layout blk: [ text "filename" filename: field no-filename button "Edit" [ either filename/text <> "none" [ unview edit-file filename/text ] [ view layout [ text "No filename selected" button "OK" [unview] ] ] ] button "CANCEL" [unview] ] ] edit-file: func [ filen ] [ print "Will do some editing stuff" ]

 [5/6] from: anton::wilddsl::net::au at: 13-Nov-2006 10:20


Just a quick comment. I don't think you realise yet that you don't want to use the string "none" as a default value yet. What if you wanted to edit a file with filename %none for instance ? I suggest to just see if the filename field is empty, like this: if not empty? filename-fld/text [ edit-file to-file filename-fld/text ] Anton.

 [6/6] from: yvan_iigs::gmx::net at: 15-Nov-2006 19:58


Hello Ryan, great thanks, this works. On 12.11.2006, you wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted