Trying to learnLive code and cannot do even the most simple of programming features ...
I have a single stack and want return a varA from a function disp_to_acceleration and put it into a text field i call AccelValue
my goal is to create a collection of functions . click a button and have it populate different text boxes.
Stuck on the first one.
on mouseUp
put field "FreqValue" into varF -- this works
put field "DispValue" into varD -- this works
let varA= (disp_to_acceleration(varF,varD), stack "Dynamic Conversion") -- this fails
put varA into field "AccelValue"
end mouseUp
with error
button "Button": execution error at line 6 (Chunk: can't find stack), char 1
There are two tabs and one of them says stack "Dynamic Conversion", which is were my function lives.
function disp_to_acceleration(varF,varD)
return varF*varD
end disp_to_acceleration
any help is appreciated. This is the simplist of things to do , but, totally escapes me in LiveCode.
Simple Function use
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Simple Function use
Hi mkholcomb@aol.com,
1. welcome to the forum!
2. to get used to Livecode, I recommend to check these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html
For your problem, declare the function like this:
And use it like this:
Best
Klaus
1. welcome to the forum!

2. to get used to Livecode, I recommend to check these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html
For your problem, declare the function like this:
Code: Select all
function disp_to_acceleration var1,var2
return var1*var2
end disp_to_acceleration
Code: Select all
on mouseUp
put field "FreqValue" into varF -- this works
put field "DispValue" into varD -- this works
## let varA= (disp_to_acceleration(varF,varD), stack "Dynamic Conversion")
## this fails, because it is Basic or something like this :-)
## Correct use of function in LC
## put disp_to_acceleration(varF,varD) into varA
## put varA into field "AccelValue"
## Or shorter:
put disp_to_acceleration(varF,varD) into field "AccelValue"
end mouseUp
Klaus
Re: Simple Function use
You have programmed before.
When you wrote
Where did you get the idea that "let" was a native word? I am not chastising, just trying to make a point. A new language requires learning a new vocabulary and syntax. Take Klaus advice and dig into the basics. You are at an advantage in that you already have coded. You are at a disadvantage in that you need to unlearn quite a bit.
Craig Newman
When you wrote
Code: Select all
"let varA= (disp_to_acceleration(varF,varD), stack "Dynamic Conversion") -- this fails"
Craig Newman