Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
yochankim
- Posts: 8
- Joined: Tue Mar 05, 2019 4:06 am
Post
by yochankim » Wed Mar 06, 2019 12:30 pm
Thank you!
I solve this problem with the samples!
(because my development environment is offline, I haven't seen the sample stacks.

)
Best regards,
RogGuay wrote: ↑Wed Mar 06, 2019 6:11 am
I have stack that I uploaded to LiveCode Sample Stack called Coup de Graph. It may give you some ideas.
Cheers,
Roger
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Mar 06, 2019 12:50 pm
RogGuay wrote: ↑Wed Mar 06, 2019 6:11 am
I have stack that
I uploaded to LiveCode Sample Stack called Coup de Graph. It may give you some ideas.
Cheers,
Roger
Just in case yochankim is too new to know how to get to the user samples, you can either get there in the LiveCode environment from the menubar icon "User Samples" or directly through the web browser at
http://livecodeshare.runrev.com/
Your sample was right at the top Roger, congrats !

- Yay!
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10309
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Mar 06, 2019 4:28 pm
First off, I updated my handler so it actually works. This does not mean it actually works.
As to your question, put something like "10x^3 + 4" into fld 1 and hit a button that contains the script below.
Code: Select all
on mouseup
put fld 1 into arg
put integrate(arg,"x") into fld 2
end mouseup
function integrate arg,var
set the itemDel to var
put item 1 of arg into coeff
if coeff = "" or coeff = 1 then put "" into coeff
put item 2 of arg into everythingElse
if everythingElse contains "^" then
set the itemDel to "^"
put word 1 of item 2 of everythingElse into expon
put word 2 of everythingElse into operator
put word 3 of everythingElse into const
else
put 1 into expon
put word 1 of everythingElse into operator
put word 2 of everythingElse into const
end if
add 1 to expon
if coeff ="" then return coeff & var & "^" & expon && "/" && expon && operator && const & var && "C"
else return coeff / expon & var & "^" & expon && operator && const & var && "C"
end integrate
Craig
Last edited by
dunbarx on Wed Mar 06, 2019 6:18 pm, edited 2 times in total.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10309
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Mar 06, 2019 4:35 pm
The handler will not accommodate an expression that has the form:
"10x^3 + 3x + 5"
In other words, it does not "see" the "3x".
Can you update the function to include this extra term? It will be good practice for you in pursuit of your original inquiry.
Craig
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Tue Mar 12, 2019 3:13 pm
shiftLock happens