include files @ startup

include files @ startup - Сообщения

#1 Опубликовано: 10.05.2023 17:44:05
charlamb

charlamb

1 сообщений из 16 понравились пользователям.

Группа: User

Hi,

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.
#2 Опубликовано: 11.05.2023 07:32:22
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

You can't. But you can always make a template and run a copy on startup.

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 Б) скачан 38 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
#3 Опубликовано: 11.05.2023 09:23:52
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

You can write a single include with all functions collected.
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.
#4 Опубликовано: 12.05.2023 13:02:25
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 сообщений из 164 понравились пользователям.

Группа: User

Greetings,

Wrote

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:

FORUM: https://en.smath.com/forum/yaf_postsm75364_Standard-templates.aspx#post75364
Wrote

Create 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)

WIKI: https://en.smath.com/wiki/Snippets.ashx
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:
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\」
<?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. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#5 Опубликовано: 13.05.2023 16:13:35
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

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.


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 КиБ) скачан 29 раз(а).
Genfit Algo Include Test UpDated.sm (138 КиБ) скачан 39 раз(а).

Simply collect all your functions, all parametric of constants/parameters
Call the indexed one(s) of your choice ... update parameters/constants.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений