include

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

#21 Pubblicato: 29/11/2013 11:04:56
sublim21

sublim21

3 apprezzamenti in 36 post.

Gruppo: 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 Pubblicato: 30/11/2013 13:21:11
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Updated. Added support for strings. Error handling is changed.
Russia ☭ forever, Viacheslav N. Mezentsev
1 utenti hanno apprezzato questo post
Martin Kraska 30/11/2013 17:28:00
#23 Pubblicato: 01/12/2013 07:57:42
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: Moderator

Preliminary handbook pages:
include demo.sm (4,69 KiB) scaricato 1581 volta(e).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
2 utenti hanno apprezzato questo post
Вячеслав Мезенцев 01/12/2013 09:06:00, Radovan Omorjan 01/12/2013 09:15:00
#24 Pubblicato: 24/01/2014 14:10:29
sublim21

sublim21

3 apprezzamenti in 36 post.

Gruppo: 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 utenti hanno apprezzato questo post
#25 Pubblicato: 24/01/2014 15:14:02
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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 Pubblicato: 25/01/2014 08:48:58
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#27 Pubblicato: 27/03/2014 05:22:48
wfoster982

wfoster982

0 apprezzamenti in 1 post.

Gruppo: 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 Pubblicato: 27/03/2014 05:44:29
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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 Pubblicato: 27/03/2014 07:37:44
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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 Pubblicato: 27/03/2014 10:54:50
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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 utenti hanno apprezzato questo post
Martin Kraska 27/03/2014 14:01:00
#31 Pubblicato: 25/04/2014 15:40:26
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

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

Mike Kaganski

184 apprezzamenti in 434 post.

Gruppo: User

Wrote

EDIT: Definitions in areas not supported.



Could you please address this limitation?

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

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

I'll do that little later.
Russia ☭ forever, Viacheslav N. Mezentsev
1 utenti hanno apprezzato questo post
Mike Kaganski 26/04/2014 04:14:00
#34 Pubblicato: 30/04/2014 12:21:05
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Updated. Definitions in areas now supported and function works faster.
Russia ☭ forever, Viacheslav N. Mezentsev
2 utenti hanno apprezzato questo post
Davide Carpi 30/04/2014 17:35:00, Mike Kaganski 30/04/2014 18:30:00
#35 Pubblicato: 01/05/2014 05:40:09
sergio

sergio

127 apprezzamenti in 342 post.

Gruppo: 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 utenti hanno apprezzato questo post
#36 Pubblicato: 01/05/2014 10:29:45
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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 utenti hanno apprezzato questo post
sergio 01/05/2014 15:48:00
#37 Pubblicato: 23/06/2014 03:53:20
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Updated (for compatibility with SMath Studio 0.97.5283).

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

brotjob

7 apprezzamenti in 71 post.

Gruppo: 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 Pubblicato: 17/10/2014 04:39:18
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Citazione

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 Pubblicato: 17/10/2014 10:18:25
brotjob

brotjob

7 apprezzamenti in 71 post.

Gruppo: 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!
  • Nuovi post
  • Nessun nuovo post