Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

redefining a variable value

  • To: mathgroup at
  • Subject: [mg48071] redefining a variable value
  • From: barrena at (Manuel Barrena)
  • Date: Tue, 11 May 2004 05:19:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

I have a button to read an input cell given by a user. This is the

          Editable->False], GridBox[{
        Editable->False]}]], "Input",
  CellTags->"Data entry"]

  The user just write an integer value in the placeholder. 
But now, in order to
  process the user input, the value of "answer" must be not a list
  but the single integer value. So I need to redefine "answer" to  be
  answer = First[First[answer]]. Of course I do not want to write
inside the button function:
  "answer = First[First[answer]]", 
because I want to generalize
  the button to do the same under different variable names (such
  as "answer", "answer1", "answer2",...), so that I have to select
  the variable name (in this particular case "answer"), then to
  read it, then to paste it, and finally to assign the new value
  (First[First[answer]]). By doing so, the variable "answer" can be
  processed by another notebook to do the right calculation.
  This is the goal. 
Let me explain how I try to reach it and what is the problem I face.

I try the following: 
NotebookFind[thisnb, "Data entry",All, CellTags];
Set[in, NotebookRead[thisnb]]; (*I need to capture the input cell as
it is *)
SelectionEvaluate[thisnb, All]; 
SelectionMove[thisnb, Previous,CellContents]; 
SelectionMove[thisnb, All, Word]; (*Trying to copy the variable name*)

Now, var contains the word "answer", but it is not editable. For
example, if I write:

SelectionMove[thisnb, After, Notebook];
NotebookWrite[thisnb, resp, All];

I get op = {Editable -> False}, but now if I do:
SetOptions[NotebookSelection[thisnb], Editable -> True];
I get an error ("You tried to edit inside a subexpression that cannot
be edited,
because it is a fixed special form.")

My proposal to change the value of the variable answer was finally to
something similar to : 
NotebookApply[thisnb, "First[First[\[SelectionPlaceholder]]]"];
after selecting the last variable name inside a notebook sentence as
answer = answer, but I see that this way is not the proper one.

I have two questions:
1. How could I change the option Editable -> False inside the
2. What is the best way to redefine the value of the variable "answer"
in the previous example?

Thank you very much.

Manuel Barrena.

  • Prev by Date: Re: Mandelbrot Set & Mathematica
  • Next by Date: Re: FindRoot and NDSolve
  • Previous by thread: nonlinear theory of elasticity question using Mathematica
  • Next by thread: Re: FindRoot and NDSolve