(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 37723, 764]*) (*NotebookOutlinePosition[ 38379, 787]*) (* CellTagsIndexPosition[ 38335, 783]*) (*WindowFrame->Normal*) Notebook[{ Cell[GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg05eMG@2l_;`0jn_[0>c/k031`L407QhN0000000L71`0QXJ60<[:bP3[jn/0gmoO0:^[ Z`1ADE420000000;06UYJ@3GemL0e=CD055AD@0000009BDU030080oooo00<0Hf=S0000002n_[h00`3oool01@0K6a/0O7al 0?ooo`3oool0WinO00<0000000<0QHF50?ooo`3oool00`3oool01P1IFET0F5QH0?ooo`3oool0/K6a 075aL@80oooo00<0h^;R01XJ6P1mOGd01@3oool01`1iNGT0>3Ph0?ooo`3oool0X:2P00000024Q8@0 0`3oool00`1SHf<01@D50;fm_@040?ooo`030=cLg00G5aL0m?Cd00@0oooo00<0nMOM0=L7;P3E02@0 1@3F02L01@3E0240f0/`0=L4:`3F02H0eP0W0080e`@Z00@0e`D/0=H1:03F02L0eP0W0P3G12X30=H0 9`090=D08@3H2c00e`@[0=H09P3F02L0e`L]0=D08P3G0bX0eP3P0oOgm0?ooo`3oool0alO7 09BDU037alL0=3@d09bLW0020?ooo`030>KViP2FUYH0^[Zj0080oooo00<0oOgm024Q8@1gMgL00P3o ool00`1EEED0H61P0?ooo`020?ooo`030?Shn00J6QX0N7Qh0080oooo00D0Z:RX01`L700L71`00000 07moO`020?ooo`050<30`01KFe/0GemO01XJ6P1NGUh00P3oool01`3Jf]X0k>c/0?ooo`3_knl0@d=3 00000021PH400P3oool01@30`<00Fe]K065QH@0V9RH0@T920080oooo00<0T92@034a<@3kno/00`3o ool04@1FEUH0GemO0?ooo`3oool0o_kn0;6a/@2HV9P0_Kfm01hN7P3/k>`0oooo0?[jnP1iNGT0FEUI 071?E@3A0R40eP0V00@0eP0W00`0e@0O0>=CK@3d^L@0fado0=D08`3D01d0iF1g0>ELM@3/QYP0fQTl 0=D08`3D01d20>IQN@0I0=@07@3F02L0e@0O0>=CK@3d^L@0fado0=D08`3D01d0jG>80>f>X03aZKL0 fADi0=D08`3E0200gRi>0?Fob@3YN8d0eP8T0=H09P3E0200gBm?0?G0bP3^UJH0ePDW0=H09@090=H0 9`0F0=H09@3G0bX0kYFU0=XH>`3E02<0eP0W0=D08@3M;dl0jWjB0=D08P3F02H0eP0W0=@07@3TFG80 iEae0=@07P3F02L0e00O0>AJL`3c]l80i5Yc0=@07`@0eP0W00<0/@0P000000000000oP0000000`0? 3`l000000000003J00000000200000003`2>SXh0oooo0?ooo`34a<@02`/;0000000<30`08R8R0>CT i03oool0o?cl04aCT0?oo o`3bl_80oooo0?Shn00J6QX0N7Qh0P3oool01@3inOT0k^k^0>7Qh@000000Ng]k0080oooo00D0k^k^ 0=;BdP35aLD00000061PH0050?ooo`040=?Cd`0d=3@000000820P080oooo00D0k^k^0=;BdP34a<@0 000004E5A@020?ooo`080:6QX@32`/80oooo0>c/k03kno/0oooo06EUI@2h^;P20?ooo`0<09:BTP00 0000000001XJ6P0F5QH0kno_0?ooo`3no_h0f][J0=;BdP24AE40`00E103F02L03@3F02@0e`d`0?G4 c@3O=eH0e@4T0=H09`3D01/0ifb20?6Y]P3d_LL0fQPk0=D08`3D01`00P3YL8H06@3D01`0eP0T0=L= <03eaAJL`3ieM`0lkG10=L4:@3F02D0e00L0>b8VP3_UjL0mKo90=TC =`3E02<0e00L0>fAXP3XLHL0l:Bb0>51G`3D01l02@3F02L05P3F02D0e`^1 U@3D01l40=H09`030;408000000000000?h0000000<03`l?000000000000fP00000000P0000000@0 Vi^K0?ooo`3oool0YJFU0`0000001@0@4100l?3`0?ooo`3jn_X03Ph02[Zj/0moOg0?oo o`3Zj^X04aS0?gm o@3oool0JFUY0IWO`3e`l`0m/SA0=TE>@3E02<0 e00L0080j6j301T0e00L0=D08`3I4cL0ml[B0=P=YmT@3D01`0 eP0V0=@07P3^UJH0jWfA0>MXOP3G22d0e@0U0=@07P3_VZX0he=]0>jFYP3SCf/0e00N00T0eP0W01H0 eP0U0=L1:03aY[@0fQ/n0=D08`3F02@0f0/`0?:/^@3b[k/0i5E_0=@07P3E0240gS1@0?>g`@3d^lD0 fQLl0=D08`3D01/0iEYd0?_Xk03UFg@0e00K103F02L00`2a020000000000003n0000000300l?3`00 000000000=X0000000080000000905IFEP3oool0oooo0?KfmP1eMGD0ATI608Z:RP0g=cL0^KVi0080 oooo00@0bl_;05YJFP2:RXX0n?Sh0P3oool00`0i>CT0M7Ad0?ooo`020?ooo`070?;blP0l?3`0a/K6 0?ooo`3hn?P06QXJ07QhN0020?ooo`050;Ng]`14A4@0ADE500X:2P1mOGd00P3oool01@2d];@0>c/k 03/k>`000000HV9R0080oooo00<0/[:b01hN7P3Shn<00P3oool01@0e=CD0M7Ad0?ooo`3oool0];Bd 0080>c/k00<00P8204I6AP3oool00`3oool01P1OGel0SHf=0?ooo`3oool0FEUI0861P@80oooo00d0 g]kN05YJFP1;Bd/0TY:B01lO7`3/k>`0oooo0?[jnP1OGel0>SXj04/]<`3=01/0eP0V00<0eP0W00d0 eP0V0=D18@3ZNi00lk>n0=TF>@3E02<0e00L0>M]P`3WJX40kiVX0=XL?`3E02<0e00L0080j6n401T0 e00L0=H09P3E0B40jW^@0?>c_P3I5ST0e@0S0=H0903G12X0n=3G0>AJM03D01`0eP0W0=@07@3RBfL0 mlWA0>YhS@3F0RD0eP0V0=@07P3QAV<0mlWB0?:_^`3H3S00e@0T00T0eP0W01H0e@0S0=XH?03fbM80 fQPk0=D08`3F02D0eP@W0>j@X@3c]l80gRi>0=D08@3E02<0fQTk0?:^^`3aYK<0e``^0=D0903D01`0 i5Uc0?O@f03TFG<0e00L103F02L00`2a020000000000003n0000000300l?3`00000000000=X00000 00080000000300H61P2k^k/0oooo00@0oooo00<08bSX04U9 B@1bLW800P3oool01@3^k^h0d];B0=CDe00_;bl0FUYJ0080oooo00L0mOGe0>KViP3oool0oooo0>7Q h@0=3@d0NWYj0080oooo00D0kno_0=;BdP3De=@0c/k03oool0o_kn0=_Kf`3AdM40f;Fl0=L5 ;03E02@40=H09`040=H09@3F02L0gS9A0=P:<080eP0U00H0fADh0=XF>@3K7T00e`D[0=H09P3F02D2 0=XE>@070=H09@3F02L0eP0U0=H09`3N0=XH?03E02<:0=H09`0:0=H09@3H3340gS1@ 0=L3:P3F02H0eP0W0=D08`3I53P0gBU:0=D08`80eP0W00X0e@0T0=`RA03J6ch0e@0T0=H09`3F02H0 e`@[0=dZB`3G12/0eP0V103F02L00`2a020000000000003n0000000300l?3`00000000000=X00000 00090000000;01`0UiNG00T92@000000NGUi0?gmo@3lo?`0`L7100d=3@030`<0f][J0?gmo@3emOD0410@07al O03oool0oOgm00<0oooo00@0BTY:06UYJ@3moOd0oOgm0`3oool0100b[ZjP02 0?gmo@80oooo00L0n=?J0=P1:03D01l0eP0Q0=L08`3G0280e@0R0080e`0R00`0e00I0=D0803G0280 e@0R0=D07P3F01h0e`0J0=P07`3G0280e@0R0=D07P3G01h20=D08P0?0=P08@3G0240eP0J0=D0803E 0280e`0R0=L08`3E01/0e@0O0=P08P3H0240e@0R0=D08@3D01X0e@0N0080e`0R00T0e@0R0=D08@3F 01P0e`0L0=D08P3H0240f00P0=L08P3E02800P3F02820=D08P80f00P00T0f00Q0=D0803D01T0e`0Q 0=H08P3E0280f00R0=H07`3F01X00P3E0280103H0240e`0S0=H06P3G01/30=D08P060=H0803D01X0 e@0P0=P08@3H0200f00Q0P3E02800`2b01`000000000003n0000000300l?3`00000000000=X00000 000;0000000<04E5A@2c/k<0_[jn071`L0061PH08R8R05IFEP1]KFd0K6a/05UIF@1=CDd09BDU0P00 00004`0n?Sh0SHf=0;jn_P2DU9@0>3Ph000000010@40>c/k09ZJVP2OWil0H61P01`L701`L700XZ:R 0:2PX02FUYH0N7Qh07IfMP1lO7`00P2PX:006`2NWYh0HF5Q09FEU@1_Kfl0MWIf0::RXP2CTi<0L71` 0451@@0_;bl03@d=000000051@D0MWIf0::RXP2?Shl0?clo04a1HL02X:401G>d00MeIK07=CF01PADT0Le=H07IIGP1F:340=@D<04dP:01eFEh0 M5QM04DL900e1@h0KdiD07MGG@1F=cd0DRP_07IHG@0307EDFP0/06I9CP1OA4P0MUEK079>E00f31<0 BB0W07ELH@1C9Bd0<`/B06]9C`1fEE/0L51F07EDF@1fEE/0Kd]B02l<4P0Z2@h0DBD]07IIGP1fEEX0 F3m306i?E01gEU/0HDA903D53P1;7RH0MEUN07IIGP1F:340=@D=02h83`1D5B00PeUQ08iVK@1_CeD0 KTmD07IEFP1dEe`0?A`R02X93@0o7B<0MEQM07IEFP1G?T;o00000040000000<03`l?000000000000 fP00000000/0000000H0N7Qh0?gmo@3moOd0]kNg0000002c/`00000000000000 000ag]k@3moOd0lo?c018B4P38b3P00<0oooo00@0o_kn0>_[j`2VYZH0 6QXJ0P0000002P18B4P0o_kn0?gmo@3YjNT000000492@P3lo?`0oooo0>o_k`0820P2000000030;no _`3oool0oooo0080C4a<103oool01P3moOd0fMWI07EeM@00000030`<0>k^kP80oOgm0P3oool08P39 bl/0KWEc0:ji]`2V];401PD505ADE02__;X0HV9R0000002LZ:H0[kZh0828Q`29TY00[kZh0:>]Z`17 BDP0S@2_^[P0Yk6`05QNG@2W/K00[kZh06E/JP000000:b/[0:jj^02_^kT0>SXj0000002? VYP0[kZh06ieL`0m@3l20:nj^080/;^i0180VZBR05eSHP2_^[P0[;Ne01LH600m@3l0[kZh07MnO@00 0000Qi2>0:nj^02=UY@0OXF40:nj^02Z]K<0AdY9030bSX0WJJU0:nj^02`^kT0Z[Fc08F=R`80[kZh00<0HFMV 02`^;P1NHf800P2_^[P00`1UK6/000000000003n0000000300l?3`00000000000=X00000000:0000 000700D51@3Fe]H0oooo0?ooo`3/k>`051@D0;Ng]`020?ooo`050?KfmP0X:2P0000000h>3P3De=@0 0`3oool02P3bl_80oooo0?ooo`3oool0FUYJ00@4103`l?00oooo0>SXj02:RXX20?ooo`030CT0?ooo`3no_h0lO7a00<0oooo00@0bSX0N7Qh0?ooo`020?ooo`0405mOG`00000000000;Rh^080oooo0P1EEED2 0?ooo`030?Win@3dm?@0oooo0080oooo01@0KFe]00820P3`l?00oooo0?knoP3SP2b/[80MgMg03dm?@H0/[:b0240Xj>S02DU 9@2XZ:P0/[:b08>3P`00000051@D0:b/[02b/[80FU]K0000001bLW80/[:b09>CT`0_;bl0[jn_0;:b /P2VYZH0QhN707emO@0j>SX0[Jf]0;:b/P1=CDd0FEUI0;:b/P2_[jl0:b/[07UiN@2b/[80S8b<034a <@2`/;001@2b/[80302][Jd092@T08J6QP2b/[80Z:RX00P92@0A4Q80[:b/0;:b/P1oOgl04aT Y080/[:b00@0[Zj^0:n_[`1VIVH0U9BD1P2b/[800`19BDT000000000003n0000000300l?3`000000 00000=X00000000:0000000703dm?@3no_h0oooo0?ooo`3moOd0E5AD0=cLg0030?ooo`0308Z:RP00 0000KVi^0080oooo00@0i>CT04Y:BP0_;bl0ZJVY0P3oool01@3:b/X04ac/k03oool0oOgm0080 oooo00@0l?3`0410@0000000PH610P3oool02P2e]KD0@41003lo?`0Q8B40kNg]0?ooo`3inOT0BTY: 05UIF@3_knl20?ooo`0303hn?P071`L0i>CT00<0oooo00<0Ng]k0:6QX@3oool00P3oool01035aLD0 0@410000002h^;P20?ooo`80EEEE0P3oool00`31`L40c/ 0?ooo`3kno/0P82006QXJ00_;bl020P80:2PX02b/[80Jf][08B4Q0020;:b/P0@06UYJ@23Ph<0/[:b 07inOP0410@0T92@0;:b/P2][Jd0LG5a0:ZZZP2b/[80Rh^;00P8202IVIT0/[:b09bLW0800`<30180 WIfM0;:b/P2CTi<0GUiN096AT@2b/[80YZJV02DU9@2VYZH0/[:b09BDU018B4P0@T9200P8202>SXh0 /[:b07YjNP1gMgL20;:b/P0F07MgM`1dM7@0/[:b09>CT`020P80OWin0;:b/P2a/K40MgMg0:6QX@2b /[80WinO00@4101`L700/[:b0;2`/00S8b<00@4109ZJVP2b/[80U9BD03Ti>@80/[:b00D0UiNG02XZ :P0[:b/0<30`05EEE@020;:b/P0508>3P`2>SXh0/[:b0;6a/@0[:b/0o`0000010000000300l?3`00 000000000=X00000000:0000000=0:RXZ03oool0i>CT0k^kP0P8200jn_[0?oo o`3no_h0oOgm0?ooo`3moOd0_Kfm01DE5@1jNWX00P3oool02P2GUiL000000000000<30`0lO7a0?oo o`3hn?P07QhN0000002j^[X20?ooo`0?06m_K`1JFUX0oooo0?KfmP2l_;`0oooo0@3Xj>P40?ooo`0K08F5Q@000000Lg=c0;:b/P2JVYX0YJFU0:n_[`2XZ:P0YJFU09>C T`2b/[80P82000000012@T80/[:b0:n_[`0g=cL0WYjN0;:b/P1^KVh0000008:2PP2b/[80[:b/01300D0/[:b00<0[jn_034a<@2@T900102b/[805@0J6QX0FEUI0;:b/P2UYJD0VYZJ0:n_ [`2XZ:P0ZZZZ08n?S`2b/[80Ti>C0000000];Bd0/[:b0;6a/@16ATH0QhN70;:b/P24Q8@0000005UI F@020;:b/P0903/k>`000000Ph>30;:b/P2SXj<0BDU90;2`/02b/[80KFe]00<0000000P04A4A0:>S X`2b/[80Hf=S069RHP2b/[80Z:RX00l?3ol000000@0000000`0?3`l000000000003J000000002@00 00001@0F5QH0k^k^0?ooo`2ZZZX0MGEe00<0oooo00H0Shn?08Z:RP3oool0o_kn03Xj>P1kNg/20?oo o`040=3@d00O7al02`/;08:2PP80oooo00L0g=cL01TI6@3/k>`0oooo0>o_k`0c7Qh@02 0?ooo`0605=CD`2a/K40oooo0>?Sh`1ADE40no_k0P3oool01`35aLD0HV9R0?ooo`3oool0PH610000 002g]kL00P3oool205EEE@80oooo00l0^KVi00`<301]KFd0o_kn0?ooo`3Kfm/08B4Q0>_[j`3oool0 o?cl0:BTY02DU9@0ATI600000010@4000`2b/[800`2@T900KVi^0;:b/P020;:b/P0D0820P0000000 1@D509FEU@2b/[80Q8B40:FUY@2b/[80D51@00820P1YJFT0/[:b0;6a/@0bC00<30`000000Q8B40;:b/P2;Rh/0W9bL0;:b/P1SHf<00`<304=3 @`2a/K40/[:b05QHF0020P80JFUY0;:b/P2^[Zh0@41009jNWP2b/[80VIVI01TI6@0000008B4Q0000 001IFET0/[:b0:6QX@28R8P0/[:b08Z:RP010@40o`0000010000000300l?3`00000000000=X00000 00090000000605eMG@3oool0oooo0820P00/;2`0o_kn0P3oool01`1HF5P0E5AD0?ooo`3oool0YZJV 01`L703bl_800P3oool00`3Vi^H0c/k>0?ooo`020?ooo`0708R8R0051@D0kno_0?ooo`3emOD0MgMg 0=GEe@020?ooo`05065QH@1_Kfl0oooo0?ooo`2LW9`00P0000001P0?3`l0l?3`0?ooo`3moOd0d=3@ 0>g]k@80oooo00L0fm_K03De=@3alO40oooo0;jn_P0>3Ph0hN7Q0080oooo00L0V9RH020P803inOT0 oooo0=oOg`0<30`0/k>c0080oooo0P1EEED20?ooo`030>k^kP3@d=00oooo0080oooo00/0RXZ:00<3 0`3_knl0oooo0?_kn`29RHT0Lg=c059BDP0000004Q8B0:JVYP020;:b/P030820P00S8b<0[Jf]0080 /[:b00@0P820000000000000B4Q80`2b/[80102`/;00?Cdm07MgM`2IVIT20;:b/P0;09ZJVP1aLG40 Fe]K0;:b/P2_[jl0;bl_02@T902][Jd0/[:b05ADE01LG5`00P2b/[801@1YJFT0D51@03Hf=P061PH0 V9RH0080/[:b00<0UYJF01TI6@2SXj<00P2b/[80102CTi<01@D50000000d=3@40;:b/P0804E5A@1J FUX0TI6A0;6a/@2b/[80XZ:R07emO@1fMWH20;:b/P0>0410@01ADE40/[:b0;:b/P2MWId0O7al0:2P X00E5AD03Ph>0:FUY@2b/[80/K6a0;:b/P1]KFgo00000080000000<03`l?000000000000fP000000 00P0000000L020P80=?Cd`3oool0oooo05YJFP010@40jNWY0080oooo00P0;Bd]02HV9P3oool0oooo 0?knoP0N7Qh0Fe]K0?7al@D0oooo00@0/;2`010@400;2`/0no_k1@3oool00`3Cdm<04Q8B0820P002 0?ooo`050:>SX`0000000000010@403kno/01@3oool00`3Lg=`0?clo092@T0020?ooo`0309NGU`00 0000[jn_0080oooo00<0K6a/0000003Ogml00P3oool0101LG5`0/k>c0?ooo`3oool205UIF@H0oooo 00@0];Bd01LG5`0:2PX0no_k103oool01038bSX`061PH00P8209JFUP2g]kL0^[Zj04=3@`00000000<30`0000002`/;0:ZZZP<0]KFe00D0^;Rh 08>3P`000000000003`l?0020820P00604aCT`20P8008B4Q0000000E5AD0Ng]k07moO`1n OWh09bLWo`0000020000000300/;2`00000000000=X00000001X0000000301hN7P0?3`l03`l?0?l0 3`l?@@0?3`l00`0N7Qh000000000003J00000000o`00003o000008X00000003o00000?l00000RP00 00000?l00000o`00002:00000000\ \>"], "Text", ShowCellBracket->False, CellMargins->{{0, 0}, {0, 0}}, Evaluatable->False, CellFrameMargins->4, ImageSize->{648, 25}, ImageMargins->{{0, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, Background->GrayLevel[0]], Cell[CellGroupData[{ Cell["\<\ Programming the Front End\ \>", "Title"], Cell[TextData[{ "From a tutorial given at the 1998 Worldwide ", StyleBox["Mathematica", FontSlant->"Italic"], " Conference by John M. Novak" }], "Subsubtitle"], Cell[TextData[{ "The following a specific examples of front end programming that I used to \ emphasize the general concepts given in my introduction. While there is not a \ detailed explanatory gloss for the following code, it may still prove useful \ to someone familiar with general ", StyleBox["Mathematica", FontSlant->"Italic"], " programming concepts who wants specific examples of programming with the \ front end." }], "Text"], Cell["\<\ These examples were put together for the conference, so the code sometimes \ skips error checking and boundary case handling in the interests of clarity. \ For example, the 'Information Buttons' example does not correctly handle all \ cases, such as those where there is no matching symbol. However, the sense of \ the code should be reasonably clear.\ \>", "Text"], Cell[CellGroupData[{ Cell["Information Buttons", "Section"], Cell["\<\ The 'Information Buttons' example hooks into a typesetting rule that catches \ the ?symbol syntax, and assembles a palette in the case where there are \ multiple matching symbols. It also attaches a button to usage messages that \ hyperlinks to the help browser.\ \>", "Text"], Cell["\<\ The code is written to work via a call to 'UsageGrid'; only at the last step \ is this hooked into a typesetting rule. 'Names' is used to determine the \ matching symbols.\ \>", "Text"], Cell[BoxData[ \(UsageGrid[s_String]\ := \[IndentingNewLine]Module[ {matchnames\ = \ Names[s]}, \[IndentingNewLine]If[ TrueQ[Length[matchnames]\ > \ 1], \[IndentingNewLine]writegrid[ matchnames], \[IndentingNewLine]doinformation\ @@ \ matchnames\[IndentingNewLine]]\[IndentingNewLine]]\)], "InputOnly"], Cell["\<\ In the case of multiple matching names, write out a cell containing a grid of \ buttons that call the function that writes the individual usage messages.\ \>", "Text"], Cell[BoxData[ \(writegrid[names_]\ := \n CellPrint[ Cell[BoxData[\[IndentingNewLine]GridBox[ makegrid[names] /. \n\t {"\<\>"\ \[RuleDelayed] \ ButtonBox["\<\>", \ ButtonFunction\ \[RuleDelayed] \ Null, \ Active\ \[Rule] \ False], \[IndentingNewLine]s_String\ \[RuleDelayed] \ ButtonBox[s, ButtonFunction\ \[RuleDelayed] \ \((doinformation[First[#]] &)\), ButtonEvaluator\ \[Rule] \ Automatic]}, \[IndentingNewLine]RowSpacings\ \[Rule] \ 0, \[IndentingNewLine]ColumnSpacings\ \[Rule] \ 0, \[IndentingNewLine]ColumnsEqual\ \[Rule] \ True\[IndentingNewLine]]], \n"\", \n Active\ \[Rule] \ True, \n CellMargins\ \[Rule] \ {{4, \ Inherited}, {Inherited, Inherited}}, \n ShowCellLabel \[Rule] False\n]]\)], "InputOnly"], Cell["\<\ Construct a grid from a list. The factor of '9' is something of an \ empirically determined magic number specific to the default font family and \ size of an output cell. The list of names gets padded with a list of empty \ elements of appropriate size to create a hopefully nice square array.\ \>", "Text"], Cell[BoxData[ \(makegrid[names : {__String}]\ := \n Module[{width, \ extra}, \[IndentingNewLine]width\ = First[WindowSize /. Options[SelectedNotebook[], WindowSize]]; \[IndentingNewLine]width\ = \ Floor[\((width/9)\)/Max[Map[StringLength, \ names]]] /. \((0\ \ \[Rule] \ 1)\); \[IndentingNewLine]extra\ = \ \ \(If[#\ === \ 0, \ #, \ width\ \ - \ #] &\)[\[IndentingNewLine]Mod[Length[names], \ width]]; \[IndentingNewLine]Partition[\[IndentingNewLine]Join[ names, \ Table["\<\>", \ {extra}]], \[IndentingNewLine]width\[IndentingNewLine]]\ \[IndentingNewLine]]\)], "InputOnly"], Cell["\<\ This writes out the cell with the usage message and an attached button to the \ help browser if the symbol is in the System` context.\ \>", "Text"], Cell[BoxData[ \(doinformation[name_String]\ := \[IndentingNewLine]Module[ {mess\ = \ ToExpression[name\ <> \ "\<::usage\>"]}, \[IndentingNewLine]If[ Head[mess]\ === \ String, \[IndentingNewLine]CellPrint[\[IndentingNewLine]Cell[ TextData[ {mess, "\< \>", \[IndentingNewLine]If[ Context[name]\ === \ "\", \[IndentingNewLine]ButtonBox[ "\", \[IndentingNewLine]ButtonStyle\ \[Rule] \ "\", \[IndentingNewLine]ButtonData\ \[Rule] name, \[IndentingNewLine]Active\ \[Rule] \ True]]\[IndentingNewLine]}], "\"]\[IndentingNewLine]], \[IndentingNewLine]CellPrint[ Cell[BoxData[ MakeBoxes[ Definition[ name]]], \[IndentingNewLine]"\"]]\ \[IndentingNewLine]]\[IndentingNewLine]]\)], "InputOnly"], Cell["\<\ Here is the rule that attaches this function to a typesetting rule.\ \>", "Text"], Cell[BoxData[ \(MakeExpression[RowBox[{"\", s__String}], StandardForm]\ := \n\t HoldComplete[UsageGrid[StringJoin[s]]]\)], "InputOnly"], Cell["Here's an example of its use:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?*Factor*\)\)], "Input"], Cell[BoxData[GridBox[{ { ButtonBox["DampingFactor", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["Factor", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["FactorComplete", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["Factorial", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["Factorial2", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["FactorInteger", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["FactorList", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["FactorSquareFree", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["FactorSquareFreeList", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["FactorTerms", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["FactorTermsList", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["NProductExtraFactors", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["NProductFactors", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["TrigFactor", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic]}, { ButtonBox["TrigFactorList", ButtonFunction:>(doinformation[ First[ #]]&), ButtonEvaluator->Automatic], ButtonBox["", ButtonFunction:>Null, Active->False]} }, RowSpacings->0, ColumnSpacings->0, ColumnsEqual->True]], "Output", CellMargins->{{4, Inherited}, {Inherited, Inherited}}, Active->True, ShowCellLabel->False], Cell[TextData[{ "FactorInteger[n] gives a list of the prime factors of the integer n, \ together with their exponents.", " ", ButtonBox["Reference Guide", ButtonData:>"FactorInteger", Active->True, ButtonStyle->"RefGuideLink"] }], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Front End Dialogs", "Section"], Cell["Examples of simple 'dialog box'-like windows.", "Text"], Cell[CellGroupData[{ Cell["Kernel Invoked Evaluation", "Subsection"], Cell[TextData[{ "This one is modeled after the kernel function 'Input'; it is invoked by a \ kernel evaluation, and returns the result to the kernel. Unfortunately, in \ the current version of ", StyleBox["Mathematica", FontSlant->"Italic"], ", there isn't a nice event model, so this consists of a somewhat kludgy \ busy loop that continually checks the status of the 'dialog' notebook window. \ This will change in a future version of ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[BoxData[ \(TypesetInput[theprompt_: "\<\>"]\ := \[IndentingNewLine]Module[ {thenb, \ result}, \[IndentingNewLine]thenb\ = \ openTheDialog[ theprompt]; \[IndentingNewLine]While[\[IndentingNewLine]Options[ thenb, \ Visible]\ === \ {Visible\ \[Rule] \ True}, \[IndentingNewLine]Do[Null, \ {250}]]; \[IndentingNewLine]NotebookFind[thenb, \ "\", All, \ CellTags]; \[IndentingNewLine]result\ = \ NotebookRead[thenb]; \[IndentingNewLine]NotebookClose[ thenb]; \[IndentingNewLine]MakeExpression[ result\[LeftDoubleBracket]1, 1\[RightDoubleBracket]]\[IndentingNewLine]]\)], "InputOnly"], Cell["Here's the part that opens the window.", "Text"], Cell[BoxData[ \(\(openTheDialog[theprompt_]\ := \ \[IndentingNewLine]NotebookPut[\[IndentingNewLine]Notebook[ {\[IndentingNewLine]Cell[\[IndentingNewLine]Switch[ Head[theprompt], \[IndentingNewLine]String, \ TextData[theprompt], \[IndentingNewLine]BoxData\ | \ TextData, \ theprompt, \[IndentingNewLine]_, BoxData[\ ToBoxes[\ theprompt]]], \[IndentingNewLine]"\", \ \[IndentingNewLine]Editable\ \[Rule] \ False], \[IndentingNewLine]Cell[ BoxData["\<\>"], "\", \[IndentingNewLine]CellFrame\ \[Rule] \ True, Evaluatable\ \[Rule] \ False, \ ShowCellTags\ \[Rule] \ False, CellTags\ \[Rule] \ "\", CellMargins\ \[Rule] \ {{10, 10}, {4, 4}}, Deletable\ \[Rule] \ False], \[IndentingNewLine]Cell[ BoxData[ ButtonBox[ "\", \[IndentingNewLine]ButtonFunction\ \[RuleDelayed] \[IndentingNewLine]SetOptions[ ButtonNotebook[], Visible\ \[Rule] \ False], \ \[IndentingNewLine]ButtonFrame\ \[Rule] \ "\"]], \ \[IndentingNewLine]"\", \ \[IndentingNewLine]Editable\ \[Rule] \ False, \[IndentingNewLine]Active\ \[Rule] \ True, TextAlignment\ \[Rule] \ Center, CellMargins\ \[Rule] \ {{10, 10}, {200, 2}}]}, \[IndentingNewLine]ShowCellBracket \[Rule] False, \[IndentingNewLine]WindowFrame\ \[Rule] \ "\", \[IndentingNewLine]WindowFloating\ \[Rule] \ False, \[IndentingNewLine]WindowSize\ \[Rule] \ {300, \ 150}, \[IndentingNewLine]WindowFrameElements\ \[Rule] \ {}, \[IndentingNewLine]WindowElements\ \[Rule] \ {"\"}]];\)\)], "InputOnly"] }, Open ]], Cell[CellGroupData[{ Cell["FrontEnd Invoked Evaluation", "Subsection"], Cell["\<\ This code creates a window that can stand alone, and be saved and reopened as \ a functioning dialog. The resulting dialog will invoke a particular kernel \ evaluation when you click the OK button.\ \>", "Text"], Cell[BoxData[ \(NotebookPut\ @\[IndentingNewLine]Notebook[ {\[IndentingNewLine]Cell[TextData["\"], \ "\"], \[IndentingNewLine]Cell[ BoxData["\<\>"], \[IndentingNewLine]CellFrame \[Rule] True, \[IndentingNewLine]CellTags \[Rule] {"\"}], \[IndentingNewLine]Cell[ BoxData[ButtonBox[ "\", \[IndentingNewLine]ButtonFunction \[RuleDelayed] \ \((NotebookWrite[ First[\[IndentingNewLine]Select[Notebooks[], \((# =!= ButtonNotebook[]\ && \ Options[#, WindowClickSelect]\ =!= {WindowClickSelect\ \[Rule] \ False})\) &]], \[IndentingNewLine]NotebookFind[ ButtonNotebook[], "\", All, CellTags]; \[IndentingNewLine]BoxData[\ \[IndentingNewLine]MakeBoxes @@ {\(\((#^2)\) &\)\ @@ \ MakeExpression[ \(NotebookRead[ ButtonNotebook[]]\)\[LeftDoubleBracket]1, 1\[RightDoubleBracket]]}]]; \ \[IndentingNewLine]NotebookClose[ButtonNotebook[], \ Interactive\ \[Rule] \ False])\), \[IndentingNewLine]ButtonEvaluator\ \[Rule] \ Automatic, \ Active \[Rule] True]]]}, \[IndentingNewLine]WindowSize \[Rule] {300, 150}, \ WindowFrame \[Rule] "\", WindowFrameElements \[Rule] {"\"}, WindowElements \[Rule] {}]\)], "InputOnly"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Polyhedron Explorer", "Section"], Cell[TextData[{ "Polyhedron Explorer is a demonstration palette that is included with the ", StyleBox["Mathematica", FontSlant->"Italic"], " distribution. Embedded within it are some interesting examples of ", StyleBox["Mathematica", FontSlant->"Italic"], " programming. To see the palette in action, click ", ButtonBox["here", ButtonData:>{ FrontEnd`FileName[ {$TopDirectory, "Documentation", "English", "GettingStarted", "Demos", "Palettes", "PolyhedronExplorer.nb"}], None}, ButtonStyle->"Hyperlink"], "." }], "Text"], Cell["\<\ Since much of the code is embedded in button functions in the cells, here's a \ glance at what some of it looks like. Beware that this code won't do much out \ of the context of the explorer.\ \>", "Text"], Cell[TextData[{ "Recall that this code was embedded in buttons; it isn't in the form of \ function definitions as above. Also, this code was first written with an \ early version of ", StyleBox["Mathematica", FontSlant->"Italic"], " V3; today, I would probably save state in the notebook itself, by way of \ the TaggingRules option, rather than using global variables in the kernel as \ the following code does." }], "Text"], Cell[CellGroupData[{ Cell["Create a Shape", "Subsubsection"], Cell["\<\ Note that much of the following is involved with setting up and retrieving \ the state of the system. The core is really in the code that updates the \ graphic cell (in red, below); though you should also pay attention to the line that precedes it, which \ locates the graphics cell by way of its cell tag.\ \>", "Text"], Cell[BoxData[ RowBox[{"(", RowBox[{ \(Needs["\"]\), ";", \(If[Head[$TheCurrentViewPoint[ButtonNotebook[]]] === $TheCurrentViewPoint, $TheCurrentViewPoint[ButtonNotebook[]] = First[Options[Graphics3D, ViewPoint]]]\), ";", \($TheCurrentCode[ButtonNotebook[]] = Release[Hold[Graphics3D[#]] /. \[InvisibleSpace]{Hold \[Rule] Hold, s_Symbol \[RuleDelayed] ToString[s]}]\), ";", \($TheCurrentGraphic[ButtonNotebook[]] = Show[Graphics3D[#], Boxed \[Rule] False, PlotRange \[Rule] All, $TheCurrentViewPoint[ButtonNotebook[]], DisplayFunction \[Rule] Identity]\), ";", \(NotebookFind[ButtonNotebook[], "\", All, CellTags]\), ";", \(SelectionMove[ButtonNotebook[], All, CellContents]\), ";", "\[IndentingNewLine]", StyleBox[ \(NotebookWrite[ButtonNotebook[], Cell[GraphicsData["\", DisplayString[ Insert[Graphics[$TheCurrentGraphic[ButtonNotebook[]]], {PlotRange \[Rule] All, AspectRatio \[Rule] Automatic}, \(-1\)]]], "\", PageWidth \[Rule] \[Infinity], CellFrame \[Rule] {{16, Inherited}, {Inherited, Inherited}}, CellMargins \[Rule] {{Inherited, Inherited}, {0, Inherited}}, ImageSize \[Rule] {250, 250}, ImageMargins \[Rule] {{75, 0}, {0, 2}}, ImageRegion \[Rule] {{0, 1}, {0, 1}}, CellTags \[Rule] "\"]]\), FontColor->RGBColor[1, 0, 0]], ";", \(SelectionMove[ButtonNotebook[], Before, Notebook] &\)}], ")"}]], "InputOnly"] }, Open ]], Cell[CellGroupData[{ Cell["Paste the Graphic", "Subsubsection"], Cell["\<\ This code was chosen as an example of the use of front end tokens. Its \ purpose was to take the graphic from the explorer and put a copy of it in a \ working notebook. The Select clause attempts to determine which notebook is \ the topmost notebook suitable for a paste. Next, the graphic is located in \ the explorer, copied, and pasted into the working notebook (I've put this \ part in red). Finally, some attributes are changed in the pasted cell and the \ graphic is rerendered, for a cleaner presentation.\ \>", "Text"], Cell[BoxData[ RowBox[{"(", RowBox[{ \(nb = Select[Notebooks[], #1 =!= ButtonNotebook[] && And @@ \(({WindowClickSelect, \(\(\[InvisibleSpace]\)\(! WindowFloating\)\), \(\(\[InvisibleSpace]\)\(! Active\)\)} /. \[InvisibleSpace]Options[#1, {WindowClickSelect, WindowFloating, Active}])\) &]\), ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{\(nb =!= {}\), ",", "\[IndentingNewLine]", RowBox[{\(nb = First[nb]\), ";", "\[IndentingNewLine]", StyleBox[ \(NotebookFind[ButtonNotebook[], "\", All, CellTags]\), FontColor->RGBColor[1, 0, 0]], StyleBox[";", FontColor->RGBColor[1, 0, 0]], StyleBox[ \(FrontEndExecute[ {FrontEnd`FrontEndToken[ButtonNotebook[], "\"]}]\), FontColor->RGBColor[1, 0, 0]], StyleBox[";", FontColor->RGBColor[1, 0, 0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[1, 0, 0]], StyleBox[ \(FrontEndExecute[ {FrontEnd`FrontEndToken[nb, "\", All]}]\), FontColor->RGBColor[1, 0, 0]], StyleBox[";", FontColor->RGBColor[1, 0, 0]], "\[IndentingNewLine]", \(SelectionMove[nb, All, Cell]\), ";", "\[IndentingNewLine]", \(SetOptions[NotebookSelection[nb], Background \[Rule] Inherited, CellMargins \[Rule] Inherited, CellFrame \[Rule] False]\), ";", "\[IndentingNewLine]", \(FrontEndExecute[ {FrontEnd`FrontEndToken[nb, "\"]}]\)}]}], "]"}], ";", "\[IndentingNewLine]", \(SelectionMove[nb, After, Cell]\)}], ")"}]], "InputOnly"] }, Open ]] }, Closed]] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowSize->{496, 599}, WindowMargins->{{Automatic, 135}, {Automatic, 23}} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1717, 49, 15041, 192, 33, 14818, 184, "GraphicsData", "Bitmap", "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[16783, 245, 50, 3, 150, "Title"], Cell[16836, 250, 169, 5, 71, "Subsubtitle"], Cell[17008, 257, 444, 9, 109, "Text"], Cell[17455, 268, 375, 6, 90, "Text"], Cell[CellGroupData[{ Cell[17855, 278, 38, 0, 53, "Section"], Cell[17896, 280, 286, 5, 71, "Text"], Cell[18185, 287, 195, 4, 52, "Text"], Cell[18383, 293, 359, 6, 146, "InputOnly"], Cell[18745, 301, 177, 3, 52, "Text"], Cell[18925, 306, 1106, 22, 366, "InputOnly"], Cell[20034, 330, 317, 5, 90, "Text"], Cell[20354, 337, 727, 13, 306, "InputOnly"], Cell[21084, 352, 157, 3, 52, "Text"], Cell[21244, 357, 1082, 21, 326, "InputOnly"], Cell[22329, 380, 91, 2, 33, "Text"], Cell[22423, 384, 150, 2, 46, "InputOnly"], Cell[22576, 388, 45, 0, 33, "Text"], Cell[CellGroupData[{ Cell[22646, 392, 46, 1, 30, "Input"], Cell[22695, 395, 2692, 78, 145, "Output"], Cell[25390, 475, 258, 8, 63, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[25697, 489, 36, 0, 33, "Section"], Cell[25736, 491, 61, 0, 33, "Text"], Cell[CellGroupData[{ Cell[25822, 495, 47, 0, 47, "Subsection"], Cell[25872, 497, 519, 12, 109, "Text"], Cell[26394, 511, 735, 13, 226, "InputOnly"], Cell[27132, 526, 54, 0, 33, "Text"], Cell[27189, 528, 2141, 36, 566, "InputOnly"] }, Open ]], Cell[CellGroupData[{ Cell[29367, 569, 49, 0, 47, "Subsection"], Cell[29419, 571, 221, 4, 71, "Text"], Cell[29643, 577, 1761, 30, 466, "InputOnly"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[31453, 613, 38, 0, 33, "Section"], Cell[31494, 615, 575, 16, 71, "Text"], Cell[32072, 633, 215, 4, 71, "Text"], Cell[32290, 639, 434, 9, 90, "Text"], Cell[CellGroupData[{ Cell[32749, 652, 39, 0, 43, "Subsubsection"], Cell[32791, 654, 330, 6, 90, "Text"], Cell[33124, 662, 1827, 35, 546, "InputOnly"] }, Open ]], Cell[CellGroupData[{ Cell[34988, 702, 42, 0, 43, "Subsubsection"], Cell[35033, 704, 536, 8, 128, "Text"], Cell[35572, 714, 2111, 45, 406, "InputOnly"] }, Open ]] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)