Jose's Blog

14.01.2021

Setting up Maple for startup code and for saving all data of the worksheet.

Filed under: Computer Math,Programming — Tags: — admin @ 15:53

This is about setting up maple so that:

  1. You can load your libraries from a customized location.
  2. You don’t have to execute the whole worksheet to get an old computed result.

I only know this for Windows, for linux this should be the same but probably easier. I had some problems in Maple for Windows because it changed the way it processes the .ini file without correctly documenting it. They kept an old documentation of the .ini file but the location of the .ini file should be corrected:

https://www.maplesoft.com/support/help/Maple/view.aspx?path=libname
https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet/reference/initialization

In the past, in Windows, .ini was saved in %APPDATA%/Maple/<version>/maple.ini . This file still exist for newer maple version but it is not the same initialization file of the past (where you can write a startup code). The newer versions of Maple (I believe > version 16) uses this .ini file for the UI and not for startup code. However (undocumented) Maple will read another .ini file for startup, which unfortunately is also called maple.ini but located somewhere else. The startup code maple.ini file is now located in %USERPROFILE% (e.g. C:\Users\Jose). If this directory has no maple.ini, I suggest to create one.

Now if you want to have a startup code that:

  1. uses a customized location (for the sake of simplicity we want them to be in C:\my_libs) for libraries, put this in the init file:
    libname:="C:\\my_libs",libname:
    savelibname:="C:\\my_libs":
    
  2.  provides a procedure that saves all user variables from a worksheet (this is useful if you have something that computes for ages and whenever you open maple again you want to have the results). Put this in the maple.ini file:
    SaveAll := proc( fileName :: string )
    subs(_NAMES = anames(':-user'), proc() save _NAMES, fileName end proc)()
    end proc:
    

So now whenever I do some heavy computation in a worksheet before closing the worksheet I always type something like

SaveAll("C:/temp/maple.m");

And now when I open the worksheet again and I don’t want to re-execute the computation but still have the same variables I type
read("C:/temp/maple.m");

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress