Variable Math
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Variable Math
I am running into problems adding (or another math operation) with variables. I am trying the following with global variables. These are defined in the card script and the action is also in the card script:
put _v1 + _v2 into _vTotal
What I have read so far only concerns adding integers to a variable or adding the variable values to a field and then extracting back out of the field into another variable.
Any advice?
put _v1 + _v2 into _vTotal
What I have read so far only concerns adding integers to a variable or adding the variable values to a field and then extracting back out of the field into another variable.
Any advice?
-
- VIP Livecode Opensource Backer
- Posts: 365
- Joined: Mon Jun 10, 2013 1:32 pm
Re: Variable Math
sounds like you haven't put the code in a command or function or "executed" it via a button press.
To make it easier when you are playing
put a button on the card and put the following in the script of the button
And why are you starting the variables with an underscore - extra typing for no reason.
And check out this lesson
http://lessons.livecode.com/m/4603/l/28 ... n-livecode
Regards Lagi
To make it easier when you are playing
put a button on the card and put the following in the script of the button
Code: Select all
global _v1, _v2, _vtotal
on mouseUp
put 1 into _v1
put 23 into _v2
put _v1 + _v2 into _vtotal
put _vtotal
end mouseUp
And check out this lesson
http://lessons.livecode.com/m/4603/l/28 ... n-livecode
Regards Lagi
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Variable Math
Well I assume your line of code resides in a valid handler, no?
Do each of the variables contain a number? In other words, are you getting a error at runtime, or is the handler not compiling? Otherwise there is nothing wrong with the snippet.
As for underscores, I never use them, simply as a matter of style. I find they remind me of languages I never want to meet. But there is no reason not to, if your style "sees" these sorts of things more easily, or separates them into classes of variables that you find pleasing.
Craig Newman
Do each of the variables contain a number? In other words, are you getting a error at runtime, or is the handler not compiling? Otherwise there is nothing wrong with the snippet.
As for underscores, I never use them, simply as a matter of style. I find they remind me of languages I never want to meet. But there is no reason not to, if your style "sees" these sorts of things more easily, or separates them into classes of variables that you find pleasing.
Craig Newman
-
- Posts: 1
- Joined: Wed Apr 11, 2018 9:41 am
How to script equations
Hi all,
Sorry for my English, I'll try to descibe what is my problem with Scripting on livecode.
I've 4 points A,B,C and E on a image.
with these 4 points I've 2 straights : (AB) and (CE). I know with my script the positions of A,B,C and E.
What I would like to do : having the equation of (AB) and (CE) (like y=ax+b, I know with my script a, and b)
The aim is to find the angle of the intersection of (AB) and (CE).
If it is necessary, I can post the script
kind regards
Florian
Sorry for my English, I'll try to descibe what is my problem with Scripting on livecode.
I've 4 points A,B,C and E on a image.
with these 4 points I've 2 straights : (AB) and (CE). I know with my script the positions of A,B,C and E.
What I would like to do : having the equation of (AB) and (CE) (like y=ax+b, I know with my script a, and b)
The aim is to find the angle of the intersection of (AB) and (CE).
If it is necessary, I can post the script
kind regards
Florian
Re: Variable Math
message 1 and 4 are troll/ nonsense messages
Re: Variable Math
Hoi Klaus,
i putted this in the "exclamation mark": "These are spam/troll messages, why 2 person login with their first message ever on the same subject ?"
Thanks for keeping this forum healthy
Gruessen!
i putted this in the "exclamation mark": "These are spam/troll messages, why 2 person login with their first message ever on the same subject ?"
Thanks for keeping this forum healthy
Gruessen!
Re: Variable Math
Dag Sphere,
yes, I read your report, but the user names and posting are in fact different!
What am I missing?
Groetjes (Grüße)
Klaus
yes, I read your report, but the user names and posting are in fact different!
What am I missing?
Groetjes (Grüße)
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Variable Math
If you take the slope of each line, and it seems you know how to do that, then each slope can form a triangle upon which you can derive the tangent. The difference between the two arcTangents will be the difference in the two angles.
It matters how you visualize these lines, of course; you need to think of them both "radiating out" from the origin, or at least oriented similarly based on the origin.
Once you have a single angle, you can derive the other three. The opposite will be the same, and the adjacent will be 180 - that angle.
Craig Newman
It matters how you visualize these lines, of course; you need to think of them both "radiating out" from the origin, or at least oriented similarly based on the origin.
Once you have a single angle, you can derive the other three. The opposite will be the same, and the adjacent will be 180 - that angle.
Craig Newman
Re: Variable Math
Hi Klaus, it was a feeling i had, i found it a bit strange, despite the different names.
I saw such things before, 1 message with questions and never a reply from the author again, except the people willing to help.
But maybe i'm wrong, we'll have to see
I saw such things before, 1 message with questions and never a reply from the author again, except the people willing to help.
But maybe i'm wrong, we'll have to see
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Variable Math
I read the report as well (thanks for submitting it, Sphere), and my take was similar to Klaus'. The only thing worse than having a spam-filled forum would be a forum where merely improper English was treated like spam.
The posts themselves contained no ads or links, and neither do the profiles. If they were intended as spam they should give up their spam jobs and become English teachers since their English is more effective than their spamming abilities.
For the moment all available evidence is plausibly explained by the content. My default on these things is like Klaus': to maintain a welcoming flavor to this forum, I tend to delete only posts that are clearly either spam or completely irrelevant.
If there's a chance it may be a real person wanting to learn LiveCode, we want to help them.
The posts themselves contained no ads or links, and neither do the profiles. If they were intended as spam they should give up their spam jobs and become English teachers since their English is more effective than their spamming abilities.
For the moment all available evidence is plausibly explained by the content. My default on these things is like Klaus': to maintain a welcoming flavor to this forum, I tend to delete only posts that are clearly either spam or completely irrelevant.
If there's a chance it may be a real person wanting to learn LiveCode, we want to help them.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Variable Math
I have no problems with that at all, i make many mistakes in foreign languages. I can read thru that.The only thing worse than having a spam-filled forum would be a forum where merely improper English was treated like spam.
Of course, i'd like to help tooIf there's a chance it may be a real person wanting to learn LiveCode, we want to help them.