Rank: Advanced Member Groups: Registered
Joined: 11/01/2018(UTC) Posts: 134 Location: Wisconsin Was thanked: 62 time(s) in 39 post(s)
|
Greetings, Originally Posted by: charlamb I 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: 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) WIKI: https://en.smath.com/wiki/Snippets.ashxFORUM: https://en.smath.com/for...ecriptions.aspx#post3975Originally Posted by: omorr ... 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: You have a file in your SMath install folder: 「C:\Program Files (x86)\SMath Studio\entries\Constants.xml」; if you look into it, this is where your gravitational constant is defined. I would advise you create your numerical constants in a similar fashion. 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\」 Code:<?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>
As a crash course: factor is the numerical value, connection is unit, title is the description, and name is the constant/variable name within the sheet itself. NOTE: you can have several aliases for the same value, just separate each alias within the 'name' field by a space. Also, there are special characters like 「(」 and 「.」; you may need to experiment with your naming convention to get the variables to display correctly. Also note that this will create constants, so they will behave like units: they use the ' as the first character, and they show up as 'blue' text (not the black text of a variable). 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. ᵂᴵ |
|