Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline stephen16  
#1 Posted : 01 July 2021 04:28:24(UTC)
stephen16

Rank: Newbie

Groups: Registered
Joined: 01/07/2021(UTC)
Posts: 2
Japan
Location: Yokohama

I am expecting the global variable value to change and maintain the change after exiting the function.

Example

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Razonar  
#2 Posted : 01 July 2021 05:49:39(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. The only way I know for a function to modify a variable is to pass it by reference to the function.

Clipboard01.jpg

Best regards.
Alvaro.
Offline stephen16  
#3 Posted : 01 July 2021 06:03:51(UTC)
stephen16

Rank: Newbie

Groups: Registered
Joined: 01/07/2021(UTC)
Posts: 2
Japan
Location: Yokohama

Hi Alvaro,

Thank you for your reply. How do I do that? Could you share some sample.
Offline Razonar  
#4 Posted : 01 July 2021 06:12:28(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi.

example_by_ref.sm (5kb) downloaded 13 time(s).

Clipboard01.jpg

Best regards.
Alvaro.
Offline Jean Giraud  
#5 Posted : 01 July 2021 14:35:00(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Native Smath has the exceptional feature of being algo style.
You can do what you want from in-situ command line.

AlgoCode.PNG
thanks 1 user thanked Jean Giraud for this useful post.
on 01/07/2021(UTC)
Users browsing this topic
Guest
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.