 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
Hello!
Brand new to SMath, and I was curious to know if there was a way to simulate creating objects with properties etc. For example, I have a car object that has a speed it's moving at and its weight.
|
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,318  Was thanked: 796 time(s) in 504 post(s)
|
Hi. Something like this? obj_set_get.sm (12kb) downloaded 34 time(s).Best regards Alvaro.
|
 2 users thanked Razonar for this useful post.
|
on 19/01/2023(UTC), on 20/01/2023(UTC)
|
|
 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
Hey Alvaro, that is really cool, I didn't know you could do that in SMath. Thank you
|
|
|
|
 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
Hey Alvaro, I was testing out your methods with the inclusion of loops and it seems that I can't create a variable beforehand and assign it, it has to be empty. Do you know a way around this?  This is ultimately what I am trying to do with these functions, where I can get a mutable array of "Zones", each with their own properties (ie. area, x/y location etc.)  For reference I read through this thread as well: https://en.smath.com/for...iable-Name--str2var.aspxand tried some of the solutions posted on there but to no avail.
|
|
|
|
 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
I figured it out, just don't know a way around it. Since I'm calling str2num(output_i), it's giving me the value of that expression and not the variable itself.
|
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,318  Was thanked: 796 time(s) in 504 post(s)
|
Originally Posted by: alisin  I figured it out, just don't know a way around it. Since I'm calling str2num(output_i), it's giving me the value of that expression and not the variable itself. Yep. You need to call str2num at the worksheet level. Something like this  obj_set_get.sm (19kb) downloaded 5 time(s).Also, I'm go to modify the code for accept set or collections. Best regards. Alvaro.
|
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,072  Was thanked: 481 time(s) in 319 post(s)
|
Jean's reply is not corresponding with question.
This algorithm is not creating an object. It is only finding index of a key in data.
|
 2 users thanked overlord for this useful post.
|
on 20/01/2023(UTC), on 20/01/2023(UTC)
|
|
  Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,318  Was thanked: 796 time(s) in 504 post(s)
|
Originally Posted by: overlord  Jean's reply is not corresponding with question. Thanks. Updated. obj_set_get V2.sm (47kb) downloaded 20 time(s). obj_set_get V2.pdf (155kb) downloaded 12 time(s).Best regards. Alvaro.
|
 2 users thanked Razonar for this useful post.
|
on 20/01/2023(UTC), on 20/01/2023(UTC)
|
|
 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
Originally Posted by: Razonar  Originally Posted by: overlord  Jean's reply is not corresponding with question. Thanks. Updated. obj_set_get V2.sm (47kb) downloaded 20 time(s). obj_set_get V2.pdf (155kb) downloaded 12 time(s).Best regards. Alvaro. This is incredible work, it would be really cool to see this kind of feature built-in to SMath in the future.
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,613   Location: Italy Was thanked: 1318 time(s) in 869 post(s)
|
Originally Posted by: overlord  Jean's reply is not corresponding with question.
This algorithm is not creating an object. It is only finding index of a key in data. mod: Deleted since it was off-topic.
@Jean: please stay on topic. |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
 Rank: Newbie
Groups: Registered
Joined: 19/01/2023(UTC) Posts: 6 Location: Canada
|
Originally Posted by: Razonar  Originally Posted by: overlord  Jean's reply is not corresponding with question. Thanks. Updated. obj_set_get V2.sm (47kb) downloaded 20 time(s). obj_set_get V2.pdf (155kb) downloaded 12 time(s).Best regards. Alvaro. I"ve been absolutely loving using this! Is there a way to disable the historical value saving? I'm trying to override some values rather than keep a record of them, I was thinking of going through a loop that check to see if the second column is zero and making a new submatrix without that row and calling it recursively until there are no 0 values left, however that presents a future problem when the value I want to set is 0. Is there a way around this?
|
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,318  Was thanked: 796 time(s) in 504 post(s)
|
Originally Posted by: alisin  ... Is there a way to disable the historical value saving? ... Hi. A version without values history. obj_set_get V3.sm (54kb) downloaded 15 time(s).Best regards. Alvaro.
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,469   Was thanked: 1256 time(s) in 731 post(s)
|
Maybe this plugin will be useful: Wiz FunctionsIt contains a set of functions for manipulating key and value pairs. |
Russia ☭ forever Viacheslav N. Mezentsev |
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.