Hot answers tagged

24

Fixes by Mathematica version. Note that unfixed bugs may apply to earlier versions as well; e.g. TableAlignments -> Left not working also applies to version 7. Version 10.1 Fix syntax highlighting in Trace: Unprotect[Trace]; SyntaxInformation[Trace] = {"ArgumentsPattern" -> {_, _., OptionsPattern[]}}; Protect[Trace]; Fix Incompatibility of Row ...


24

Typically, Mathematica contacts the license server every 2 minutes. If you have a license which supports a very large number of processes, that interval can grow (to help MathLM to scale better). It will never be more than 30 minutes. If three consecutive license checks fail, then Mathematica will instead revalidate the entire license file on what would ...


19

Maybe NotebookDynamicExpression is what you are looking for: SetOptions[EvaluationNotebook[], NotebookDynamicExpression :> Refresh[ SetDirectory[NotebookDirectory[]]; nbs = {"one.nb", "two.nb", "three.nb"}; For[i = 1, i <= Length[nbs], i++, Block[{nb = NotebookOpen[NotebookDirectory[] <> nbs[[i]]]}, FrontEndTokenExecute[nb, ...


14

There are two typical locations where a user can add an init.m file to be loaded at run-time: $BaseDirectory and $UserBaseDirectory. $BaseDirectory is useful for installation wide customizations that apply to all users while $UserBaseDirectory is used for a specific users customizations. So, anything in $UserBaseDirectory is loaded after the files found in ...


14

The only solution I have found is to delete the contents of the directory given by: FileNameJoin[{$UserBaseDirectory, "Paclets"}] More specifically it appears to be sufficient to delete a single file: FileNameJoin[{$UserBaseDirectory, "Paclets", "Configuration", "pacletSiteData_10.pmd2"}] To prevent Mathematica freezing on the next start-up I need to ...


13

You can use the global AutoOpenNotebooks setting to give a list of notebooks that must be opened on startup. The default path where it looks for these notebooks is $UserBasedirectory/SystemFiles/FrontEnd/TextResources. Now every time you open Mathematica, that notebook will be opened (in my case, tile.nb).


12

I don't know anything about mathStatica, so I can't comment on specifically what it's doing. But I can comment on the various moving parts of the system. The init.m file is created by the paclet manager. It must be that the mathStatica palette is part of a paclet which is under active management by the paclet manager. The paclet manager, as part of its ...


12

I think I found it but I'd be more than happy to look at other alternatives if any provided: Shift + Ctrl + O to open Options > Notebook options > Evaluation options > Global preferences from the drop down menu at the top Change InitializationCellEvaluation to True and InitializationCellWarning to False The next time the .nb file is launched, the ...


11

Here is one that came from a Wolfram employee so it should be safe to add in version 9: FindInstance returns Indeterminate in version 9, but not in 8


11

This is possible, at least in version 7, but as rcollyer supposed there is a Global security option which cannot be set from within the Notebook (automatically, that is). First change the Global option: SetOptions[$FrontEnd, GlobalInitializationCellWarning -> False ] Then in the Notebook you need to evaluate: SetOptions[EvaluationNotebook[], ...


11

To long for a comment: I think there are multiple typos (I hope) in docs for Get. This will work Get["Test`", Path -> {NotebookDirectory[]}] even without SetDirectory and this will work automatically too: SetDirectory @ NotebookDirectory[]; << Test` So the difference is in ` More accurate in description is tutorial/FilesForPackages ...


9

Cause The problem is due to a bug involving Catch and init.m that occurs in (at least) Mathematica versions 7, 8 and 9. It has been reported to Wolfram Support and they have acknowledged it as a bug. At time of writing, WRI has offered neither diagnosis nor workaround for this problem. Reproduction Steps and Analysis To reproduce the issue, place the ...


8

Here's a patch from Adam Strzebonski of Wolfram, which fixes a bug in RootReduce in 9.0.1. ToNumberField won't recognize Root as explicit algebraic number


8

I think that Mike has a point: it is always good to start with something simple. Here is a very simple example which shows the main problem you have: the Initialization-code is evaluated only after the body of the DynamicModule has been evaluated. This might be surprising considering its name but I think is in agreement with the documentation, which is ...


8

One way to go about this is read in the file names - this way you don't have to explicitly check to see if they exist. path = SystemDialogInput["Directory", NotebookDirectory[]]; fileNames = FileNames["*.txt", path]; allFiles = Table[Import[fileNames[[num]]], {num, 1, Length[fileNames]}]; This reads the names of all files (in the specified path ...


8

I think it is more convenient to use NotebookEvaluate. We can do NotebookEvaluate[filename, EvaluationElements-> "InitializationCell"] Confusing here may be that this has the same result as NotebookEvaluate[filename, EvaluationElements -> Automatic] Even though if we simply do NotebookEvaluate[filename] all the cells get evaluated.


8

mathStatica does not alter, nor seek to alter, the MenuSortingValue. In fact, mathStatica does not alter or seek to alter, in any way, how or where the mathStatica palette is listed in the palette menu... this is left entirely to default Mathematica behaviour. The reason the mathStatica palette appears out of alphabetical order in the Palettes menu seems to ...


8

As J.M. pointed out, this can be achieved by using an init.m file. init.m files are loaded on startup. The documentation can be found here. To load the VectorAnalysis package on each startup, you can write the init file using Export. The snippet below will append a Needs["VectorAnalysis`"] to the kernel init.m file: initFileName = ...


8

The error is due to the issue being fixed on the server, which involves removing the CloudObject-10.3.760 paclet so it is no longer downloadable. Evaluate first PacletSiteUpdate /@ PacletSites[] and then PacletUpdate["CloudObject"] I have also updated the original answer to include this step.


7

You possibly want to create one or more packages. Packages are special code files with extension .m or .wl, which load as code packaged (hence the name "package") in one or more namespaces. Mathematica has built-in support creating, managing, and loading packages. A good place to start learning how to organize Mathematica code follow this link


6

Take a look at: Programmatically quitting the FrontEnd or running without one? I asked some similar questions and the answers have some good strategies to do this although most of them as workarounds outside of the Mathematica front end. A simple but key thing, adding NotebookSave[] to the end of your initializations cell can avoid some of the ...


6

A bit of an extended comment, but using a package makes all the sense in the world for a situation like you describe. You can see a specific example at this earlier question: What is a good coding style for setting and changing application level constants? In the above answer, a package provides a way to supply constants to any other notebooks. While ...


6

I'm questioning AND answering this because I was looking for a feature like this for a while and now stumbled across FrontEndToken["EvaluateInitialization"] which does exactly what I wanted. Here is the code to make it work: filename = SystemDialogInput["FileOpen"]; nb = NotebookOpen[filename]; FrontEndExecute[FrontEndToken[nb, "EvaluateInitialization"]]; ...


5

This has to do with the Notebook's default context setting in the evaluation menu. If it isn't set to Global`, the definitions made in init.m are not seen. As rm-rf says, a good way to put custom definitions in the init.m would be to use Begin and End to create an Init` context and append that context to the context path so that the definitions are ...


5

According to the documentation, To suppress the loading of kernel initialization files, use the kernel command-line option -noinit. To specify another file to be used for kernel initialization in addition to init.m, use the kernel command-line option -initfile file, where file is the additional initialization file.


4

I think that the reason is that -- depending on the format -- Import does either use external programs, java libraries via JLink or the frontend for imports of most "nontrivial" formats. Only some -- mainly simple ascii or plain binary -- formats and of course mathematicas own syntax are directly "imported" with pure kernel functionality. As you correctly ...


4

This has to do with the order in which the arguments of Animate are executed. Let's see if we can determine that: ClearAll[eval, low, hi, init, x]; i = 1; Animate[ eval[If[i > 10, 10, i++]] = x, {x, low[i++] = x; 0, hi[i++] = x; 1}, Initialization :> (init[i++] = x;), AnimationRunning -> False ] Information /@ {low, hi, init, ...


3

This is too long for a comment. I don't really have time to pull this code apart but if the objective is to learn DynamicModule wouldn't a simpler piece of code be a better start? If you look at what variables have been created after the first ENTER this is a small sample of what you get I think it would be best to pull your code apart and figure out why ...


3

It's probably a good idea to look at this question more more information about writing CDF-happy notebooks. In brief, Initialization cells won't function properly in the CDF format. For example if we have the following initialization cell: a = 1; And subsequent cell that is not an initialization cell Manipulate[b + x, {x, 1, 10, 1}] Manipulate[a + x, ...


3

On Mathematica 7 (at least) DeclarePackage doesn't work first time on this Curl example: DeclarePackage["VectorAnalysis`", {"Div", "Grad", "Curl"}] v := {3 Xx^2 + 2 Yy + (a - 3 b) Zz, (b - 7 a) Xx - 5 Yy - Zz, 2 Xx + c a Yy + 7 Zz} Curl[v] {0, 0, 0} But strangely when v is defined again and run it works: v := {3 Xx^2 + 2 Yy + (a - 3 b) ...



Only top voted, non community-wiki answers of a minimum length are eligible