Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg60942] Re: Dynamically defined URL
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Tue, 4 Oct 2005 04:16:44 -0400 (EDT)
  • Reply-to: <ingolf.dahl at telia.com>
  • Sender: owner-wri-mathgroup at wolfram.com

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 math.umass.edu] 
To: mathgroup at smc.vnet.net
Subject: [mg60942] 

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 math.umass.edu
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: mole units
  • Next by Date: Re: String to list
  • Previous by thread: Re: Dynamically defined URL
  • Next by thread: Re: Import-Function buggy in Version 5.2 ?