1 страниц (17 вхождений)
Tip on editing multiline functions - Сообщения
#1 Опубликовано: 16.01.2011 15:21:21
I create a lot of multiline functions. But SMath does not yet have the ability to insert or delete lines from the function. As my functions evolve I have to add lines of code between lines. I've found the easiest way to do this is to edit the SMath sm file.

To add a line of code simply expand the bottom of the LINE, where LINE is the SMath multiline command. A blank line will be inserted as reprented by the blackened box. Save the SMath file.

Open the SMath file with your text editor. Locate the blank line# and move it up.



Now you can insert the new code line.

Adding lines is easy. Any number of lines can be added. Deleting lines is a bit more complicated. First delete the line in the multiline function. Save the SMath file. Open the file in your text editor and locate the# and delete it. The next thing you have to do is adjust the number of arguments for each SMath function.


Determining the number of places the number of arguments needs to be adjusted gets tricky. But I've found it saves me a lot of time rather than moving every line up or down.
This is not something for the weak of heart. I've crashed SMath a few times by not adjusting the number of arguments properly but ultimately I've been able to achieve what I want. Just be careful and do it on a backup not the original, in case you have to go back to a file that works.
PS. It just struck me of an easier way to delete lines.
Delete the commands in the line you want to delete. Add a new line at the bottom. Edit the SMath file and move the# to the other #

Edit SMath file move#

To other#

In SMath simply collapse the LINE to remove the deleted lines. This way let SMath adjust the argument count.


To add a line of code simply expand the bottom of the LINE, where LINE is the SMath multiline command. A blank line will be inserted as reprented by the blackened box. Save the SMath file.

Open the SMath file with your text editor. Locate the blank line



Now you can insert the new code line.

Adding lines is easy. Any number of lines can be added. Deleting lines is a bit more complicated. First delete the line in the multiline function. Save the SMath file. Open the file in your text editor and locate the


Determining the number of places the number of arguments needs to be adjusted gets tricky. But I've found it saves me a lot of time rather than moving every line up or down.
This is not something for the weak of heart. I've crashed SMath a few times by not adjusting the number of arguments properly but ultimately I've been able to achieve what I want. Just be careful and do it on a backup not the original, in case you have to go back to a file that works.
PS. It just struck me of an easier way to delete lines.
Delete the commands in the line you want to delete. Add a new line at the bottom. Edit the SMath file and move the

Edit SMath file move

To other

In SMath simply collapse the LINE to remove the deleted lines. This way let SMath adjust the argument count.

Ed
1 пользователям понравился этот пост
Radovan Omorjan 16.01.2011 16:04:00
#2 Опубликовано: 16.01.2011 16:14:19
Hello Ed,
Thank you for this detailed explanation of SMath file editing
It would be very welcome to have the Insert/Delete inside line environment, besides expanding/collapsing. However, for the simple editing you can just do this moving, inserting, deleting lines by cat/paste from the multiline functions to the empty part of the worksheet, and after that pasting back into the appropriate placeholders. The method you explained might be very useful if you have to move many expressions at the same time, or insert empty placeholders in the middle of a more complicated multiline function.
Regards,
Radovan
P.S. It crossed my mind that inserting rows and columns in a matrix could be done this way as well
Thank you for this detailed explanation of SMath file editing

It would be very welcome to have the Insert/Delete inside line environment, besides expanding/collapsing. However, for the simple editing you can just do this moving, inserting, deleting lines by cat/paste from the multiline functions to the empty part of the worksheet, and after that pasting back into the appropriate placeholders. The method you explained might be very useful if you have to move many expressions at the same time, or insert empty placeholders in the middle of a more complicated multiline function.
Regards,
Radovan
P.S. It crossed my mind that inserting rows and columns in a matrix could be done this way as well
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Опубликовано: 17.01.2011 22:22:56
Radovan,
Your right. For small multiline functions add a new line at the bottom and move everything down. This will open up a new line some where in between. Or delete a line and move everything up.
But for long multiline functions this gets tedious. Editing the SMath file is easier.
Your right this technique can also be used for matrices. I didn't post an example but it looks similar. Adding/deleting rows is easy because the blank cells are directly next to each other. But you do have to be careful and know the number of elements per row. You have to move it up or down a multiple of the number of element per row. Moving a column gets a bit more complicated because the blank cells are seperated by the number of columns. But if your careful it can be done.
Thanks for the advise.
Ed
Your right. For small multiline functions add a new line at the bottom and move everything down. This will open up a new line some where in between. Or delete a line and move everything up.
But for long multiline functions this gets tedious. Editing the SMath file is easier.
Your right this technique can also be used for matrices. I didn't post an example but it looks similar. Adding/deleting rows is easy because the blank cells are directly next to each other. But you do have to be careful and know the number of elements per row. You have to move it up or down a multiple of the number of element per row. Moving a column gets a bit more complicated because the blank cells are seperated by the number of columns. But if your careful it can be done.
Thanks for the advise.
Ed
Ed
#4 Опубликовано: 18.01.2011 03:07:55
Hello Ed, Hello Radovan,
by accident I found a simple solution to insert or delete lines:
Simply go to the cell of the line after that you want to insert or delete cells and type a semicolon.
The line changes into edit mode, like line(a:=1;b:=4;#;d:=7;3;1) and offers you a placeholder (I typed #). You can now insert placeholder (by repeated typing a semicolon) or delete as you like.
At least you need to correct row number of line elements (the last two numbers in the command are row-number and col-number). If you type the correct number, than the edit mode will be finished and you can see the result.
The same can be done with matrices.
Here the matrix changes into edit mode like mat(1;2;3;4;5;#;6;7;8;9;3;3).
Best Regards,
Peter
by accident I found a simple solution to insert or delete lines:
Simply go to the cell of the line after that you want to insert or delete cells and type a semicolon.
The line changes into edit mode, like line(a:=1;b:=4;#;d:=7;3;1) and offers you a placeholder (I typed #). You can now insert placeholder (by repeated typing a semicolon) or delete as you like.
At least you need to correct row number of line elements (the last two numbers in the command are row-number and col-number). If you type the correct number, than the edit mode will be finished and you can see the result.
The same can be done with matrices.
Here the matrix changes into edit mode like mat(1;2;3;4;5;#;6;7;8;9;3;3).
Best Regards,
Peter
2 пользователям понравился этот пост
#5 Опубликовано: 18.01.2011 04:42:59
Thank you Peter,
Very nice tip
. I just forgot about that. It works with mat(), line(), sys() functions.
We should pay attention about the function arguments, as you mentioned, and we can insert or delete mat(), line(), sys() elements.
Regards,
Radovan
EDIT: Although, this might be complicated for longer multiline functions or large matrices - here is a simple example of how to reshape a matrix.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,3,5)[/MATH]
Now, we can click on the last element (lower right corner) and press "," or ";" depending on what the argument separator was. It seems that matrix elements are row by row arguments in mat(...,rows,cols) function - the last two being the number of rows and columns.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,#,3,5)[/MATH]
and change the last two arguments (..,rows,cols) into:
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,#,5,3)[/MATH]
and delete the empty placeholder. If this was a correct reshaping, the new matrix will appear.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,5,3)[/MATH]
It does'nt seem to complicated, when we get use to it
Very nice tip

We should pay attention about the function arguments, as you mentioned, and we can insert or delete mat(), line(), sys() elements.
Regards,
Radovan
EDIT: Although, this might be complicated for longer multiline functions or large matrices - here is a simple example of how to reshape a matrix.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,3,5)[/MATH]
Now, we can click on the last element (lower right corner) and press "," or ";" depending on what the argument separator was. It seems that matrix elements are row by row arguments in mat(...,rows,cols) function - the last two being the number of rows and columns.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,#,3,5)[/MATH]
and change the last two arguments (..,rows,cols) into:
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,#,5,3)[/MATH]
and delete the empty placeholder. If this was a correct reshaping, the new matrix will appear.
[MATH=eng]a←mat(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,5,3)[/MATH]
It does'nt seem to complicated, when we get use to it

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 пользователям понравился этот пост
Oscar Campo 21.01.2011 11:03:00
#6 Опубликовано: 20.01.2011 17:09:23
Neat. Couldn't be simpler. Thanks for the tip.

Ed
#7 Опубликовано: 01.02.2011 16:43:12
Hello Ed, Hello Radovan,
because it is not so easy to modify a matrix by hand I made a little program (for Windows) to do this
.
https://smath.com/wiki/GetFile.aspx?File=forum_attach%2fPeter%2fSMathMatrixEditor.zip
You can resize and modify matrices and exchange matrices with Excel (copy and paste)
.
After you have the SMathMatrixEditor running, you can exchange matrices just by copy from SMath or Excel and paste into the Editor (with a RightMouseClick in the grid) or copy from the Editor (RightMouseClick) and paste into SMath or Excel.
Actually it is necessary to setup Excel with comma as decimal separator.
I think, you can use SMathMatrixEditor intuitive without explanation.
In this pre-version the parser is very simple knitted.
It can not yet handle elements containing a separator, like mat, line, nthroot, alg, minor, ...
But simple expressions and units as well are possible.
Critics, hints and comments would be appreciated.
So, please have fun with it.
Regards,
Peter
because it is not so easy to modify a matrix by hand I made a little program (for Windows) to do this


You can resize and modify matrices and exchange matrices with Excel (copy and paste)

After you have the SMathMatrixEditor running, you can exchange matrices just by copy from SMath or Excel and paste into the Editor (with a RightMouseClick in the grid) or copy from the Editor (RightMouseClick) and paste into SMath or Excel.
Actually it is necessary to setup Excel with comma as decimal separator.

I think, you can use SMathMatrixEditor intuitive without explanation.
In this pre-version the parser is very simple knitted.
It can not yet handle elements containing a separator, like mat, line, nthroot, alg, minor, ...
But simple expressions and units as well are possible.
Critics, hints and comments would be appreciated.
So, please have fun with it.
Regards,
Peter
3 пользователям понравился этот пост
churichuro 16.02.2025 01:03:00, Oscar Campo 07.02.2011 13:02:00, ⚜ Kenny Lemens, P.E. ᵂᴵ 26.07.2023 09:44:00
#8 Опубликовано: 01.02.2011 19:36:34
Hello Peter,
This is just great. Many thanks to you and your efforts
I was just playing by making few dozens of data matrices inserting, deleting data etc. It is very nice
. I've noted that it can take care of decimal separators in SMath, converting them from comma to decimal point as needed
.
The matrix managing is one of the thing that should be improved in SMath. Your editor could be very useful in that direction
. Moreover, there is another think that is not solved in SMath yet, regarding large matrices. I think on input (although we have importData() function), presenting and managing large matrices in SMath. Considering SMath being as a "paper like", there might be problems (just imagine presenting a matrix in SMath with dimensions, say, 1000x5). I guess your editor might solve some of those problems but I do not have the clear idea how to perform this. On the other hand, I think that more closer connection of your editor and SMath might be quite useful.
Best Regards,
Radovan
P.S. Peter, could you please upload your editor on the Wiki page? You could open, say, "Tools" link and upload it there. I hope that sooner or later there will also reside some other tools or plugins (few of them are presented here on the Forum) made by SMath users. Maybe it is better to have them there on one place, at the moment, rather than scattered here on the Forum.
This is just great. Many thanks to you and your efforts

I was just playing by making few dozens of data matrices inserting, deleting data etc. It is very nice


The matrix managing is one of the thing that should be improved in SMath. Your editor could be very useful in that direction

Best Regards,
Radovan
P.S. Peter, could you please upload your editor on the Wiki page? You could open, say, "Tools" link and upload it there. I hope that sooner or later there will also reside some other tools or plugins (few of them are presented here on the Forum) made by SMath users. Maybe it is better to have them there on one place, at the moment, rather than scattered here on the Forum.
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#9 Опубликовано: 02.02.2011 13:15:22
Hello Radovan,
you will find the actual version of the editor as suggested in the new created folder "Tools" on the Wiki page.
I agree with you, that folder could be a good place for all the other tools.
Regarding the separators I found, SMath uses internally the point as decimal separator and the comma as element separator.
Only for Excel I must take care of the setup. I think, I will make a menu to change the separators for copy'n'paste to/from
Excel.
Regarding the parser I found a solution to handle matrices with nested matrices or functions with more than 1 element.
In the next version I will have this integrated. So it should than be possible to modify line-constructs as well.
Btw., if you type for instance 12,5*'N in the editor than you should get in SMath 12.5N with "N" as unit.
Best Regards,
Peter
you will find the actual version of the editor as suggested in the new created folder "Tools" on the Wiki page.
I agree with you, that folder could be a good place for all the other tools.

Regarding the separators I found, SMath uses internally the point as decimal separator and the comma as element separator.
Only for Excel I must take care of the setup. I think, I will make a menu to change the separators for copy'n'paste to/from
Excel.
Regarding the parser I found a solution to handle matrices with nested matrices or functions with more than 1 element.
In the next version I will have this integrated. So it should than be possible to modify line-constructs as well.
Btw., if you type for instance 12,5*'N in the editor than you should get in SMath 12.5N with "N" as unit.
Best Regards,
Peter
#10 Опубликовано: 03.02.2011 08:30:33
Hello Peter,
Many thanks for that
. I've put the "Tools" link from the Main Wiki page. There is only your editor there, at the moment. You can change the text there, add some explanation etc. - whatever you like. I would kindly ask you when uploading the updated SMath Matrix editor there to make a note about it with the additional explanation as well.
Very interesting
I was just wondering how the nested matrices could be handled in your editor.
Looking forward to the updated version,
Regards,
Radovan
Wrote
you will find the actual version of the editor as suggested in the new created folder "Tools" on the Wiki page.
I agree with you, that folder could be a good place for all the other tools.![]()
Many thanks for that

WroteRegarding the parser I found a solution to handle matrices with nested matrices or functions with more than 1 element.
In the next version I will have this integrated. So it should than be possible to modify line-constructs as well.
Btw., if you type for instance 12,5*'N in the editor than you should get in SMath 12.5N with "N" as unit.
Very interesting

Looking forward to the updated version,
Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#11 Опубликовано: 09.02.2011 16:20:47
Hello Radovan,
Thank you for moving the editor into the SMathTools folder of the Wiki.
Now I have uploaded the new version 1.1
Improvements and new festures:
- menu item "Paste" -> the source (SMath or Excel) of the clipboard will be recognized automatically
- menu item "Clear" added -> clears all cells without changing the size
- menu item "New" changed to "New (Rows x Columns)" -> creates a new matrix
- decimal separators for Excel recognized (from Windows setup)
- scientific format from Excel (f.i. 1,20E+03) will now correct converted to SMath
- with + LeftMouseClick into the fixed row or column you can add a unit to the entire row or column
(type the unit with a single quote, as for example: 'N or 'm/'s^2 )
I wish you much fun with the new version.
Hints, suggestions, and recommendations are welcome.
Best Regards,
Peter
PS: Nested matrices, functions with more than one parameter etc. will be handled in the next version
Thank you for moving the editor into the SMathTools folder of the Wiki.
Now I have uploaded the new version 1.1

Improvements and new festures:
- menu item "Paste" -> the source (SMath or Excel) of the clipboard will be recognized automatically

- menu item "Clear" added -> clears all cells without changing the size
- menu item "New" changed to "New (Rows x Columns)" -> creates a new matrix
- decimal separators for Excel recognized (from Windows setup)
- scientific format from Excel (f.i. 1,20E+03) will now correct converted to SMath
- with

(type the unit with a single quote, as for example: 'N or 'm/'s^2 )
I wish you much fun with the new version.
Hints, suggestions, and recommendations are welcome.
Best Regards,
Peter
PS: Nested matrices, functions with more than one parameter etc. will be handled in the next version

1 пользователям понравился этот пост
Radovan Omorjan 09.02.2011 18:40:00
#12 Опубликовано: 09.02.2011 18:57:44
Hello Peter,
Thank you for the new version
. Some other users promissed to put their contribution under "Tolls" as well.
There is a minor issue under "New" - we have two buttons "Ok" and "Abbrechen" (I suppose it means "Cancel" ).
Could you please also introduce new "Help" button with few words of explnanation, although it is quite selfexplained at the moment.
Regards,
Radovan
Thank you for the new version

There is a minor issue under "New" - we have two buttons "Ok" and "Abbrechen" (I suppose it means "Cancel" ).
Could you please also introduce new "Help" button with few words of explnanation, although it is quite selfexplained at the moment.
Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#13 Опубликовано: 10.02.2011 03:34:32
Hello Radovan,
the hint about the Help button is a good idea.
I will add this asap.
I have a little correction to my last post:
- to add a unit to the entire row or column you have to press + LeftMouseClick
(instead of )
- I will change the "Abbrechen" button to "Cancel" (in the New-window and in the Unit-window)
Best Regards,
Peter
the hint about the Help button is a good idea.
I will add this asap.
I have a little correction to my last post:

- to add a unit to the entire row or column you have to press
(instead of
- I will change the "Abbrechen" button to "Cancel" (in the New-window and in the Unit-window)

Best Regards,
Peter
1 пользователям понравился этот пост
Radovan Omorjan 10.02.2011 04:31:00
#14 Опубликовано: 07.03.2011 17:17:46
Hello Radovan,
in the SMath Tools you will find the new version 1.2 of the SMathMatrixEditor.
Now it is possible to edit (or create) matrices containing nested matrices, functions, and strings.
Help button as desired added, some bugs fixed and some little improvements (edit line etc) done.
Best Regards,
Peter
in the SMath Tools you will find the new version 1.2 of the SMathMatrixEditor.

Now it is possible to edit (or create) matrices containing nested matrices, functions, and strings.

Help button as desired added, some bugs fixed and some little improvements (edit line etc) done.
Best Regards,
Peter
1 пользователям понравился этот пост
Radovan Omorjan 08.03.2011 04:44:00
#15 Опубликовано: 06.04.2011 13:50:22
Peter,
What are the system requirements for your app? When I try to run it on my system, I get the following error:

EDIT: After some browsing other threads and testing on my machine, I think that this error is related to the fact that am running Smath 89.8 (beta) instead of the stable version. It appears that the API has undergone some changes in the beta version.
My System:
Windows XP (32-bit)
Smath 0.89.8
Excel 2007
What are the system requirements for your app? When I try to run it on my system, I get the following error:

EDIT: After some browsing other threads and testing on my machine, I think that this error is related to the fact that am running Smath 89.8 (beta) instead of the stable version. It appears that the API has undergone some changes in the beta version.
My System:
Windows XP (32-bit)
Smath 0.89.8
Excel 2007
Will Massie
Mechanical Engineer
Oregon, USA
#16 Опубликовано: 06.04.2011 13:54:35
Peter,
I was wondering if you would be willing to post a link to your entire source code for the benefit of those who want to learn more about writing plugins? (A link to the source code could also be added to the wiki.)
It would also be great if you could edit existing pages and/or add new pages on the wiki under "Developer Guide" as you learn more about plugin development. Documentation on the Smath API is very sparse. I would like to see alot more on the wiki in this regard.
I was wondering if you would be willing to post a link to your entire source code for the benefit of those who want to learn more about writing plugins? (A link to the source code could also be added to the wiki.)
It would also be great if you could edit existing pages and/or add new pages on the wiki under "Developer Guide" as you learn more about plugin development. Documentation on the Smath API is very sparse. I would like to see alot more on the wiki in this regard.
Will Massie
Mechanical Engineer
Oregon, USA
#17 Опубликовано: 21.01.2016 14:31:02
WroteNeat.Couldn't be simpler.Thanks for the tip
Simpler and more general, within Smath. No need for extra gyzma.
Naturally, you could select at will, but you will have to use
the "for loop list select". Posted in the "Matrix Treasury',
c/w example. Very useful for collecting selected data
Jean
Utilities Matrix Stack Augment.sm (7 КиБ) скачан 74 раз(а).
1 страниц (17 вхождений)
-
Новые сообщения
-
Нет новых сообщений