include files @ startup - Messages
I was wondering if it is possible to auto load (a) file(s) with custom functions/constants @ start up of SM so to avoid having to write include statements every time.
Thanks very much in advance.
You can edit the bat file with a notepad to change the dafault paths and filenames. You can create several batch scripts to start different templates.
SMath Template 1.zip (499 B) downloaded 35 time(s).
Each function c/w applicable parameters/constants.
Once in blank document front ended of include,
call any indexed parametric function, plug new parameters/constants.
That's the way I fit model function to data sets.
WroteI was wondering if it is possible to auto load (a) file(s) with custom functions/constants @ start up of SM ...
One approach would be to create a 'template' file, where you get in the habit of opening it up as your first document of the day:
WroteCreate an empty file with your template settings and set it as readonly, when you try to save Smath will ask you a new name.
Another technique would be to save your functions within a snippet file. While these functions are not loaded into SMath by default, you can access/insert the 'snippet' from the dynamic assistant to quickly insert these functions into your current worksheet (unlike include, a snippet will not reference the current version: it is not dynamic/relative and needs to be updated by a sheet to sheet basis where it was utilized if it comes time to update the functions in your snippet file)
FORUM: https://en.smath.com/forum/yaf_postsm3975_Snippet-Decriptions.aspx#post3975
Wrote... the "snipped" is like any other SMath file, but if you save it in the "snippet" folder you can insert into your existing worksheet via Snippet Manager (as collapsed area or not). Therefore, just make the *.sm file and pay attention on File=>Properties. There are two options "Summary" and "File [attributes]". What you put in the Summary - Title that will show as a snippet title ( I suppose that you did not put anything there and that is way the snippet description is the same as your file name - with *.sm added). What you put in the File attributes - Snippet shortcut - that name will appear in the Dynamic [Assistance[ (in order to insert in via Dynamic Assistance, if you like).
I did develop a solution to this dilemma, but it does not apply to functions: only numerical constants
Modify SMath "Entries" directly:
Since the XML files within this folder are system files, do not modify 「Constants.xml」 or 「Units.xml」 if you do not have the confidence to do so. With that being said, we do not need to edit these files; ANY xml file in the "entries" folder will be loaded upon startup, so just create a new XML file that matches the same scheme as 「Constants.xml」; but make sure not to redefine any constant/unit as that will be invalid, SMath will fail to startup (no error message will be provided, it will just fail to get past the loading SMath image.)
For example, copy and paste the following into Notepad, save it as an XML file in the folder: 「C:\Program Files (x86)\SMath Studio\entries\」
<?xml version="1.0" encoding="utf-8"?>
<entries lang:default="eng" xmlns="http://smath.info/schemas/entries/1.0" xmlns:lang="http://smath.info/schemas/entries/1.0">
<constants>
<!-- AWC Manual; Table M5.4-1 Average Specific Gravity and Weight Factor -->
<property dimension="613"><!-- in terms of [unitless] -->
<add factor="0.50" title="Density of Douglas Fir-Larch" >
<synonym name="SG.douglas fir-larch" />
</add>
<add factor="0.42" title="Density of Spruce-Pine-Fir (North)" >
<synonym name="SG.spruce-pine-fir SG.SPF" />
</add>
</property>
<add factor="0.00002304" connection="1/K" title="Coefficient of Expansion (Aluminum, Wrought); AISC 13th Edition - Table 17-11; ΔL=L₀*ΔT*(α)" ><!-- in terms of [1/Δ°C] -->
<synonym name="α.Aluminum˸ Wrought" />
</add>
<add factor="0.0000117" connection="1/K" title="Coefficient of Expansion (Mild Steel); AISC 13th Edition - Table 17-11; ΔL=L₀*ΔT*(α)" ><!-- in terms of [1/Δ°C] -->
<synonym name="α.Steel˸ Mild" />
</add>
</constants>
</entries>
The code/xml file above will generate (2) unitless variables that reference the correct 'dimension' property contained in 「Units.xml」, as well as (2) constants that manually map the connection to a respective unit (i.e. "1/K" for Coefficient of Expansion).
If SMath fails to start, there is an error in your XML file; correct the file until SMath is able to load. (Of course, you can always restore the contents of 'entries' to contain only the initial (2) files: 「Constants.xml」 or 「Units.xml」 to restore SMath capabilities.) Once implemented, you will notice these options in your dropdown. Other worksheets referencing this values will also reflect the real-time value as currently defined in the XML file (dynamic, not static).
I do have a similar technique for string/matrix constants, but it is more involved. However, I have yet to figure out how to trick SMath to consider a functions as a unit/constant.
May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
WroteI was wondering if it is possible to auto load (a) file(s) with custom functions/constants @ start up of SM so to avoid having to write include statements every time.
All my Smath 4500 documents reside in a unique Directory.
If I open GenfitAlgoIncludeTestUpdated
@ the top of the document there is include("GenfitAlgoInclude.sm")
At this point, the working document runs top to bottom,
fitting 7 data sets. Worked perfectly 6 months for the Originator.
As you download both in the same Download Directory,
simply open GenfitAlgoIncludeTestUpdated the working document.
Genfit Algo Include.sm (36 KiB) downloaded 29 time(s).
Genfit Algo Include Test UpDated.sm (138 KiB) downloaded 38 time(s).
Simply collect all your functions, all parametric of constants/parameters
Call the indexed one(s) of your choice ... update parameters/constants.
-
New Posts
-
No New Posts