Need help with this.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 20
- Joined: Wed Sep 07, 2022 4:26 pm
Need help with this.
How would I go about making a currency converter.
I want to be able to choose currencies from NOK, euro, dollar and english pounds and convert whichever I want to choose.
I can choose whatever currency I want and it converts to the rest. Those 4 currencies are all I need, how would I make this
I want to be able to choose currencies from NOK, euro, dollar and english pounds and convert whichever I want to choose.
I can choose whatever currency I want and it converts to the rest. Those 4 currencies are all I need, how would I make this
-
- Posts: 20
- Joined: Wed Sep 07, 2022 4:26 pm
Re: Need help with this.
I want to have like a drop down menu where I can choose which currency I want to choose, and it converts to rest of them.
Would be great if anyone could help
Would be great if anyone could help
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
Just the same as you would make a temperature converter . . .
- -
. . . except you would, probably need a way to get the exchange rates from the internet.
Code inside button '∘C':
- -
. . . except you would, probably need a way to get the exchange rates from the internet.
Code inside button '∘C':
Code: Select all
on mouseUp
put fld "fC" into CENTIG
put (0.8 * CENTIG) into fld "fRe"
put (((CENTIG / 5) * 9) + 32) into fld "fF"
put (((CENTIG + 273.15) / 6) * 9) into fld "fRa"
end mouseUp
-
- Posts: 20
- Joined: Wed Sep 07, 2022 4:26 pm
Re: Need help with this.
Thanks, but I was expecting more like a drop down menu where I can choose the currency and choose also which one to convert torichmond62 wrote: ↑Wed Nov 23, 2022 9:12 amJust the same as you would make a temperature converter . . .
-
temps.jpg
-
. . . except you would, probably need a way to get the exchange rates from the internet.
Code inside button '∘C':
Code: Select all
on mouseUp put fld "fC" into CENTIG put (0.8 * CENTIG) into fld "fRe" put (((CENTIG / 5) * 9) + 32) into fld "fF" put (((CENTIG + 273.15) / 6) * 9) into fld "fRa" end mouseUp
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
-
- Attachments
-
- Drop Down.livecode.zip
- Stack.
- (991 Bytes) Downloaded 149 times
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
Possibly, but I am not going to do ALL your work for you.I was expecting more like a drop down menu where I can choose the currency and choose also which one to convert to
-
- Posts: 20
- Joined: Wed Sep 07, 2022 4:26 pm
Re: Need help with this.
I understand, I just need like a concept to work off on.richmond62 wrote: ↑Wed Nov 23, 2022 9:20 amPossibly, but I am not going to do ALL your work for you.I was expecting more like a drop down menu where I can choose the currency and choose also which one to convert to
This is kind of what I am thinking about: https://www.youtube.com/watch?v=hnNMGKhnCxs
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
If you combine what I showed you in the temperature conversion thing and the script
in the drop down stack you should find currency conversions extremely easy.
For instance, I live in Bulgaria, where the local currency (The Lev) is pegged against the Euro
at 1.91, so a simple algorithm converts money each way.
in the drop down stack you should find currency conversions extremely easy.
For instance, I live in Bulgaria, where the local currency (The Lev) is pegged against the Euro
at 1.91, so a simple algorithm converts money each way.
Re: Need help with this.
This will give you a good start.
Go to the sample stacks search for json and download my JSON API Helper stack. Later place this in your plugins folder.
In the helper stack put https://api.exchangerate.host/latest into the JSON Source field and hit the Set TreeView to API IData button. This will load the exchange rates into the tree view.
Expand the rates in the tree view.
Click on the currencies you need and when the popup asks add them, answer Yes.
Once you have the currencies you need, hit the Create Script button.
The script generated will give you a good start, see if you can work out how to use a dropdown to access the code in the script.
Also hit the Test button to see the results of the generated script.
You can also try using this api endpoint https://api.exchangerate.host/convert?from=USD&to=EUR in the JSON API Helper, just change the currencies you need in the endpoint.
Go to the sample stacks search for json and download my JSON API Helper stack. Later place this in your plugins folder.
In the helper stack put https://api.exchangerate.host/latest into the JSON Source field and hit the Set TreeView to API IData button. This will load the exchange rates into the tree view.
Expand the rates in the tree view.
Click on the currencies you need and when the popup asks add them, answer Yes.
Once you have the currencies you need, hit the Create Script button.
The script generated will give you a good start, see if you can work out how to use a dropdown to access the code in the script.
Also hit the Test button to see the results of the generated script.
You can also try using this api endpoint https://api.exchangerate.host/convert?from=USD&to=EUR in the JSON API Helper, just change the currencies you need in the endpoint.
Andy .... LC CLASSIC ROCKS!
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
Code: Select all
on menuPick XXX
switch XXX
case "Kroner"
put fld "fSTART" into MONEY
put "NOK" & MONEY into fld "fKRONER"
put "$" & MONEY/10.07 into fld "fDOLLAR"
put "€" & MONEY/10.386 into fld "fEURO"
put "£" & MONEY/11.98 into fld "fPOUND"
break
case "Dollar"
break
end switch
end menuPick
- Attachments
-
- Drop Down2.livecode.zip
- Stack.
- (7.94 KiB) Downloaded 132 times
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Need help with this.
Use AndyP's method of getting the conversion rates, and then
use what I have shown you to do the conversions.
use what I have shown you to do the conversions.