Jump to content

[HELP] Combobox and splitting problem


..:D&G:..

Recommended Posts

Posted

Hello guys, I am trying to make a currency exchange window. You select the currency from a combobox, which is like this: "Dollars - USD" and I use this to split the "Dollars" (name) from the "USD" (initial):

local listFrom = guiComboBoxGetSelected(currencyListFrom) 
            local textFrom = guiComboBoxGetItemText(currencyListFrom, listFrom) 
            local splittedNameFrom = split ( tostring ( textFrom ), " - " ) 
            local currencyNameFrom = tostring ( splittedNameFrom [ 1 ] ) 
            local currencyInitialsFrom = tonumber ( splittedNameFrom [ 2 ] ) 

The problem is that if I try to output "currencyInitialsFrom" into outputChatBox it gets nil, any ideas why?

Thanks.

Posted

Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

  • Like 1
Posted
Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

In the picture, you tried without spaces so try without spaces.

Posted
Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

In the picture, you tried without spaces so try without spaces.

What spaces? I see that he used the spaces between the text and - ...

Posted
Try to output textFrom and see if it outputs the value you are waiting for ?

Fixed! It was because I made it to be a "tonumber" instead of "tostring" :P

  • Moderators
Posted

dayum ! no one saw it ! nice catch

A copy paste of the 1st line would have save you minutes if it not hours :P

Posted
dayum ! no one saw it ! nice catch

A copy paste of the 1st line would have save you minutes if it not hours :P

Ikr xD I've been smashing my head on this script since 10am

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...