Page 1 of 1
Variable Math
Posted: Sat Jan 28, 2017 2:05 am
by JwB
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?
Re: Variable Math
Posted: Sat Jan 28, 2017 3:32 am
by Lagi Pittas
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
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 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
Re: Variable Math
Posted: Sat Jan 28, 2017 4:51 am
by dunbarx
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
How to script equations
Posted: Wed Apr 11, 2018 10:00 am
by FlorianCrg
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
Re: Variable Math
Posted: Wed Apr 11, 2018 11:43 am
by sphere
message 1 and 4 are troll/ nonsense messages
Re: Variable Math
Posted: Wed Apr 11, 2018 11:47 am
by Klaus
sphere wrote: ↑Wed Apr 11, 2018 11:43 am
message 1 and 4 are troll/ nonsense messages
What makes you think so?
The look like legitimate questions to me.
But don't worry, I have an eye on EVERTHING here in the forum!

Re: Variable Math
Posted: Wed Apr 11, 2018 11:51 am
by sphere
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!
Re: Variable Math
Posted: Wed Apr 11, 2018 12:00 pm
by Klaus
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
Re: Variable Math
Posted: Wed Apr 11, 2018 2:15 pm
by dunbarx
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
Re: Variable Math
Posted: Wed Apr 11, 2018 6:22 pm
by sphere
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

Re: Variable Math
Posted: Wed Apr 11, 2018 11:41 pm
by FourthWorld
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.
Re: Variable Math
Posted: Thu Apr 12, 2018 12:12 pm
by sphere
The only thing worse than having a spam-filled forum would be a forum where merely improper English was treated like spam.
I have no problems with that at all, i make many mistakes in foreign languages. I can read thru that.
If there's a chance it may be a real person wanting to learn LiveCode, we want to help them.
Of course, i'd like to help too