include

include - include() function allow you to include simple definitions from other documents. - Messages

#21 Posted: 11/29/2013 11:04:56 AM
sublim21

sublim21

3 likes in 36 posts.

Group: User

Hey All,

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
#22 Posted: 11/30/2013 1:21:11 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated. Added support for strings. Error handling is changed.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Martin Kraska 11/30/2013 5:28:00 PM
#23 Posted: 12/1/2013 7:57:42 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Preliminary handbook pages:
include demo.sm (4 KiB) downloaded 107 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 users liked this post
Вячеслав Мезенцев 12/1/2013 9:06:00 AM, Radovan Omorjan 12/1/2013 9:15:00 AM
#24 Posted: 1/24/2014 2:10:29 PM
sublim21

sublim21

3 likes in 36 posts.

Group: User

There appears to be severe degradation on the time it takes to include a smath file, if that smath file contains a variable that is a string of length greater than 16.

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
1 users liked this post
#25 Posted: 1/24/2014 3:14:02 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Thank you, Pete. I'll check this.

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.
Russia ☭ forever, Viacheslav N. Mezentsev
#26 Posted: 1/25/2014 8:48:58 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Files 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).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#27 Posted: 3/27/2014 5:22:48 AM
wfoster982

wfoster982

0 likes in 1 posts.

Group: User

I'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!!!


#28 Posted: 3/27/2014 5:44:29 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

I'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.
Russia ☭ forever, Viacheslav N. Mezentsev
#29 Posted: 3/27/2014 7:37:44 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated. Try this [MATH]LL.g:eval(LL.g)[/MATH] before [MATH]LL.g*1/{25*psf}[/MATH].
Russia ☭ forever, Viacheslav N. Mezentsev
#30 Posted: 3/27/2014 10:54:50 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Files 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.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Martin Kraska 3/27/2014 2:01:00 PM
#31 Posted: 4/25/2014 3:40:26 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated. Added support for names which start with ` symbol (Linq).
Russia ☭ forever, Viacheslav N. Mezentsev
#32 Posted: 4/25/2014 5:43:28 PM
Mike Kaganski

Mike Kaganski

184 likes in 434 posts.

Group: User

Wrote

EDIT: Definitions in areas not supported.



Could you please address this limitation?

Thank you!
С уважением, Михаил Каганский
#33 Posted: 4/25/2014 5:58:04 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

I'll do that little later.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Mike Kaganski 4/26/2014 4:14:00 AM
#34 Posted: 4/30/2014 12:21:05 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated. Definitions in areas now supported and function works faster.
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
Davide Carpi 4/30/2014 5:35:00 PM, Mike Kaganski 4/30/2014 6:30:00 PM
#35 Posted: 5/1/2014 5:40:09 AM
sergio

sergio

115 likes in 329 posts.

Group: User

"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
1 users liked this post
#36 Posted: 5/1/2014 10:29:45 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

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.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
sergio 5/1/2014 3:48:00 PM
#37 Posted: 6/23/2014 3:53:20 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated (for compatibility with SMath Studio 0.97.5283).

UnitInfo.GetCurrentUnitName() changed to UnitsManager.GetCurrentUnitName().
Russia ☭ forever, Viacheslav N. Mezentsev
#38 Posted: 10/17/2014 4:04:31 AM
brotjob

brotjob

7 likes in 71 posts.

Group: User

A lot of discussion has taken place here so I post my bug report here too. Or shall I use the bugtracker system instead?

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
include.png
#39 Posted: 10/17/2014 4:39:18 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Quote

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.
2014-10-17 14-36-06 Скриншот экрана.png
Russia ☭ forever, Viacheslav N. Mezentsev
#40 Posted: 10/17/2014 10:18:25 AM
brotjob

brotjob

7 likes in 71 posts.

Group: User

This is a very elegant way for the above example. Thanks for showing me this. In cases where you have complex conditions and you want to define many variables in if statements it would not work. Also it does not work for loops for, while. That's why I will ask Andrey to implement this.

see feature request To implement an include() function able to handle dynamic definitions. Please vote!
  • New Posts New Posts
  • No New Posts No New Posts