include - include() function allow you to include simple definitions from other documents. - Сообщения
Thanks for responding. I think i found the error.
The include function appears not to work, if the document it's running in is NOT SAVED.
once the document is saved, then the include extension works.
I'm going to keep playing with the include function (i've been waiting for smath to have this ability for a long long time).
Will report back with any errors.
Thanks!
-Pete
Lets say I had two smath files as such
smathToInclude.sm
{
a:="some string of some length"
}
smathFile
{
include(smathToInclude.sm)
}
as the length of the string a increases so does the time it takes to include the file.
To test this, I created the following file.
smathFile
{
for b:=1 to 20 //do this 20 times to get a true sense of the include function time
c:=include(smathToInclude.sm)
}
And i changed the length of variable a to the following lengths, and got the following times
strlen TimeToInclude
10-.07
11-.07
12-.075
13-.085
14-.09
15-.095
16-.11
17-.169
20-.451
21-.74
22-1.16
23-1.851
24-2.841
25-4.519
30-49.0
It appears that string lengths above 16 chars is where the time to include shoots off the map - which makes me think the error has to be 16 bit representation.
Just letting you guys know,
-Pete
This behavior may be due to using a regular expression search. I am using a string representation of expressions to make some changes. Search using regular expressions can lead to such delays. It will take time for profiling the code.
How about adapted versions of include() either with a second argument or (more convenient in the dynamic assistant) a special name like include("name.sm","examples" ) or example("name.sm" ) or include_example("name.sm" ) or whatever seems to be convenient?
Then we could use the extensions manager for distribution and download of such files. Would also be nice to have a mechanism to include the complete contents of extensions/snippets or whatever dedicated directory by default (source lib plugin).
But, when I include a file that has an expression with units, the defined object does not
manipulate the units correctly.
For instance -
LL.g=20*'lbf/{'ft^2}
LL.g*1/{25*'psf}=0.017*{'lbf*'m*'s^2}/{'ft^2*'kg}
When I multiply LLg times 1/25 psf; the result should be a unitless amount. It is coming up with
a mixed unit that cannot be manipulated or dealt with.
Can you help with this?
Great Program!!!
WroteI'm not sure if I am using "include" correctly.
But, when I include a file that has an expression with units, the defined object does not
manipulate the units correctly.
For instance -
LL.g=20*'lbf/{'ft^2}
LL.g*1/{25*'psf}=0.017*{'lbf*'m*'s^2}/{'ft^2*'kg}
When I multiply LLg times 1/25 psf; the result should be a unitless amount. It is coming up with
a mixed unit that cannot be manipulated or dealt with.
Can you help with this?
Great Program!!!
Without using the include() function you get the same result?
EDIT: I have reproduced the problem. I can't advise something for now.
WroteFiles to be used by include() do not typically reside in the document directory where they are used but at some central repository in a given installation. Candidates for such repositories might be the extensions/snippets or extensions/example directories in the settings directory as found by SettingsDirectory().
How about adapted versions of include() either with a second argument or (more convenient in the dynamic assistant) a special name like include("name.sm","examples" ) or example("name.sm" ) or include_example("name.sm" ) or whatever seems to be convenient?
Then we could use the extensions manager for distribution and download of such files. Would also be nice to have a mechanism to include the complete contents of extensions/snippets or whatever dedicated directory by default (source lib plugin).
Updated. Now file is searched for in two stages (if absolute path not used):
1. In the folder: /extensions/
2. In the document directory folder.
So, if you want to include some example sheet you need to use this: include( "examples\example1.sm" ) =
EDIT: Definitions in areas not supported.
WroteEDIT: Definitions in areas not supported.
Could you please address this limitation?
Thank you!
However I have seen in previous posts that Radovan had reported the problem to the name variables, and Martin has posted an example that uses a comma for decimals.
someone confirm?
sergio
Wrote"includes" do not work correctly if you use the comma for decimals and the "dot" to denote the subscript in the variables.
However I have seen in previous posts that Radovan had reported the problem to the name variables, and Martin has posted an example that uses a comma for decimals.
someone confirm?
sergio
Updated. My fault. The algorithm was changed and I forgot about it.
UnitInfo.GetCurrentUnitName() changed to UnitsManager.GetCurrentUnitName().
ЦитатаInclude does not work for variables defined in programming environment like if or for, see the example below, bread is not accessible in testmaster.sm
You can do this like on the picture below.
include() works with static global definitions (:=) only (static defs you can read directly from the sm-file, but for dynamic you must evaluate it first). I can't do that you want because this is too complicated. You may ask Andrey to add include() function in SMath Studio. He can do that.
see feature request To implement an include() function able to handle dynamic definitions. Please vote!
-
Новые сообщения
-
Нет новых сообщений