Objected Oriented Programming

Objected Oriented Programming - Сообщения

#1 Опубликовано: 18.01.2023 20:57:31
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

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.
#2 Опубликовано: 18.01.2023 21:35:14
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. Something like this?

obj_set_get.sm (11 КиБ) скачан 52 раз(а).

Best regards
Alvaro.
2 пользователям понравился этот пост
sergio 19.01.2023 07:18:00, Mark R Harris 20.01.2023 04:09:00
#3 Опубликовано: 18.01.2023 21:43:15
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

Hey Alvaro, that is really cool, I didn't know you could do that in SMath. Thank you
#4 Опубликовано: 19.01.2023 15:33:01
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

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?
Screenshot 2023-01-19 102955.png


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.)
Screenshot 2.png


For reference I read through this thread as well: https://en.smath.com/forum/yaf_postst23278_String-to-Variable-Name--str2var.aspx
and tried some of the solutions posted on there but to no avail.
#5 Опубликовано: 19.01.2023 16:28:07
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

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.
#6 Опубликовано: 19.01.2023 17:22:47
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

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

Clipboard01.png

obj_set_get.sm (18 КиБ) скачан 21 раз(а).

Also, I'm go to modify the code for accept set or collections.

Best regards.
Alvaro.

#7 Опубликовано: 19.01.2023 21:32:59
overlord

overlord

549 сообщений из 1332 понравились пользователям.

Группа: Moderator

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 пользователям понравился этот пост
Alvaro Diaz Falconi 19.01.2023 22:06:00, Mark R Harris 20.01.2023 04:11:00
#8 Опубликовано: 19.01.2023 22:08:17
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

Jean's reply is not corresponding with question.



Thanks.

Updated.

obj_set_get V2.sm (46 КиБ) скачан 37 раз(а).
obj_set_get V2.pdf (154 КиБ) скачан 30 раз(а).

Best regards.
Alvaro.

2 пользователям понравился этот пост
overlord 20.01.2023 00:05:00, Mark R Harris 20.01.2023 04:12:00
#9 Опубликовано: 20.01.2023 13:57:13
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

Wrote

Wrote

Jean's reply is not corresponding with question.



Thanks.

Updated.

obj_set_get V2.sm (46 КиБ) скачан 37 раз(а).
obj_set_get V2.pdf (154 КиБ) скачан 30 раз(а).

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.
#10 Опубликовано: 20.01.2023 17:30:40
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

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 please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#11 Опубликовано: 20.01.2023 21:50:59
Artiom Lisin

Artiom Lisin

0 сообщений из 6 понравились пользователям.

Группа: User

Wrote

Wrote

Jean's reply is not corresponding with question.



Thanks.

Updated.

obj_set_get V2.sm (46 КиБ) скачан 37 раз(а).
obj_set_get V2.pdf (154 КиБ) скачан 30 раз(а).

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?
#12 Опубликовано: 20.01.2023 23:32:36
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

... Is there a way to disable the historical value saving? ...



Hi. A version without values history.

obj_set_get V3.sm (53 КиБ) скачан 32 раз(а).

Best regards.
Alvaro.

#13 Опубликовано: 21.01.2023 03:23:13
Вячеслав Мезенцев

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

1402 сообщений из 1708 понравились пользователям.

Группа: Moderator

Maybe this plugin will be useful: Wiz Functions

It contains a set of functions for manipulating key and value pairs.
Russia ☭ forever, Viacheslav N. Mezentsev
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений