1
$\begingroup$

Consider the following simple front-end code:

cdflocation = 
  CurrentValue[
   EvaluationNotebook, {TaggingRules, 
    "cdfpath"}];(* load any previously used file path *)

CreatePalette[{
  TextCell["\n1. Choose any file for analysis?", Bold, Blue, 16],

  Row[{FileNameSetter[Dynamic[cdflocation]], Spacer[20], 
    Dynamic[cdflocation]
    }],

  Button["Go!",
   If[Head[cdflocation] === Symbol,
    Print["not ready"],
    (Print["tag should update now"];
     CurrentValue[EvaluationNotebook, {TaggingRules, "cdfpath"}] = 
      cdflocation)]](* trouble spot here *)

  }]

I want to using the TaggingRules functionality to store file pathways with a notebook.

When the user selects a new file with the Browse button, and then selects the Go button, I would like the tag to be updated so users can load the notebook into a fresh kernel/session and always have the most recently selected file pathway available.

While I can manually reset the tag, it seems the code marked (* trouble spot here *) does nothing.

Questions:

A. Any idea why my approach is not working?

B. Any thoughts on a cleaner solution?

$\endgroup$
1
  • $\begingroup$ @Kuba Tired eyes. Yes, your observation about [] after EvaluationNotebook is certainly appreciated. That explains why the notebook kept "beeping" at me. Unfortunately, the primary issue still remains. $\endgroup$
    – Todd Allen
    May 2, 2015 at 21:42

1 Answer 1

1
$\begingroup$

EvaluationNotebook gives the palette Notebook itself; try using InputNotebook instead:

CreatePalette[{TextCell["\n1. Choose any file for analysis?", Bold, Blue, 16], 
  Row[{FileNameSetter[Dynamic[cdflocation]], Spacer[20], Dynamic[cdflocation]}], 
  Button["Go!", 
   If[Head[cdflocation] === Symbol, Print["not ready"], (Print["tag should update now"];
     CurrentValue[InputNotebook[], {TaggingRules, "cdfpath"}] = cdflocation)]]
$\endgroup$
2
  • $\begingroup$ Problem solved. I don't know what I would do without StackExchange and the kind folks that share their expertise and time. Thank you! $\endgroup$
    – Todd Allen
    May 7, 2015 at 1:05
  • $\begingroup$ @Todd I'm glad I could help. :-) $\endgroup$
    – Mr.Wizard
    May 7, 2015 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.