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 2005

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

Search the Archive

Re: Dynamically defined URL

  • To: mathgroup at
  • Subject: [mg60937] Re: Dynamically defined URL
  • From: Murray Eisenberg <murray at>
  • Date: Tue, 4 Oct 2005 01:25:02 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <001101c5c827$08b0a040$>
  • Reply-to: murray at
  • Sender: owner-wri-mathgroup at

Yes, that works perfectly.  Thank you!

Ingolf Dahl wrote:
> Hi Murray,
> You must specify ButtonEvaluator -> Automatic for the ButtonBox, otherwise
> the button is evaluated by the FrontEnd when it is pressed, and the FrontEnd
> does not know the value of ThisNBPath and cannot even do StringJoin. So this
> works:
> ThisNBPath= "";
>  filename="";
>  NotebookWrite[ InputNotebook[], Cell[ TextData[ ButtonBox[ "webmath",
> ButtonEvaluator->Automatic,
>  ButtonData:>
>  {( URL[ StringJoin["file:///", ThisNBPath, filename]]),None},
>  ButtonStyle->"Hyperlink"]], "Text"]]
> If you evaluate this, you will get a button which will send you to "My
> Computer" on a Windows PC. 
> If you then redefine "ThisNBPath" and "filename" to 
> ThisNBPath="E:/Documents/";
> filename="WebMath.htm"; 
> the same button should send you to your file.
> Best regards
> Ingolf Dahl
> Sweden
> -----Original Message-----
> From: Murray Eisenberg [mailto:murray at] 
To: mathgroup at
> Sent: 03 October 2005 10:06
> Subject: [mg60937] 
> I'm trying to build up a local file URL to be the value of ButtonData 
> for a ButtonBox.  (The file is in a subdirectory of the current 
> notebook's directory, and I want to be able to refer to the target file 
> no matter where I move the entire directory.)
> If I use an actual string as the argument in ButtonData:>{URL[...], 
> None}, as in the following expression of that cell, it works just fine:
> Cell[TextData[ButtonBox["webmath",
>    ButtonData:>{
>      URL[ "file:///E:/Documents/WebMath.htm""], None},
>    ButtonStyle->"Hyperlink"]], "Text"]
> However, if I try to build up the argument to URL in any way, even as in 
> the following version where I simply join strings, then Mathematica 
> reports a MathLink error occurred while receiving BoxData" after I 
> convertthe expression to an actual input cell and click the hyperlink:
> Cell[TextData[ButtonBox[webmath",
>    ButtonData:>{
>      URL[
>        StringJoin["file:///", "E:/Documents/", "WebMath.htm"]], None},
>    ButtonStyle->"Hyperlink"]], "Text"]
> What's wrong and how can it be fixed?
> Version: 5.2 for Microsoft Windows (June 20, 2005)
> (I actually want to do something more sophisticated, namely instead of 
> "E:/Documents/", use the value of a function ThisNBPath I've defined 
> that will return the path to the directory of the evaluation notebook.)

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: "meta-programming" ?
  • Next by Date: Re: Re: what is wrong with this plot?
  • Previous by thread: Re: Visualization site updates
  • Next by thread: Re: Dynamically defined URL