Sign in to follow this  
..:D&G:..

[HELP] Combobox and splitting problem

Recommended Posts

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.

Share this post


Link to post

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

Share this post


Link to post

It looks like it outputs nil here:

local currencyInitialsTo = tonumber ( splittedNameTo [ 2 ] ) 

But I don't know why

Share this post


Link to post
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.

Share this post


Link to post
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 - ...

Share this post


Link to post

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

Share this post


Link to post
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

Share this post


Link to post

dayum ! no one saw it ! nice catch

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

Share this post


Link to post
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

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.