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

[REBOL] Re: Rebol view fields are caching entries - HELP

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