Corona pickerWheel add column value 0

Hello,

Is there a way to add a column value 0 to the pickerWheel?

pickerWheel minutes:

for m = 1, 60 do if (m \< 10) then minutes[m] = "0"..m else minutes[m] = m end end

I tried changing the m to 0, but that didnt work, it still starts at 1. So is there a way to make it start at 0? I couldnt figure this out.

Hi @selami.c92,

So you just want the “value” of the column (as returned by picker:getValues()) to begin at 0? This loop should do it (just subtract 1 from ‘m’ and change the < to <= ):

[lua]

for m = 1, 60 do

    if ( m <= 10 ) then

        minutes[m] = “0”…m-1

    else

        minutes[m] = m-1

    end

end

[/lua]

Hope this helps,

Brent

Thank you, that did the trick. But i’ve got another problem now. For this pickerwheel I use the current time as a startIndex 

local currentDate = os.date( '\*t' ) startIndex = currentDate.min

I do get the value 0, but now it always substracts one. Lets say the minute from current time is …:14, it will show as …:13, because of the -1

Is there also a way to loop through it, without having to scroll all the way up again?

EDIT: I think I got it. I did,

startIndex = currentDate.min + 1 and with getting the right value I did: currentMinute = values[2].index - 1

Would this be a right solution? 

Exactly right. What is it that you’re trying to do, out of curiosity?

Hi @selami.c92,

So you just want the “value” of the column (as returned by picker:getValues()) to begin at 0? This loop should do it (just subtract 1 from ‘m’ and change the < to <= ):

[lua]

for m = 1, 60 do

    if ( m <= 10 ) then

        minutes[m] = “0”…m-1

    else

        minutes[m] = m-1

    end

end

[/lua]

Hope this helps,

Brent

Thank you, that did the trick. But i’ve got another problem now. For this pickerwheel I use the current time as a startIndex 

local currentDate = os.date( '\*t' ) startIndex = currentDate.min

I do get the value 0, but now it always substracts one. Lets say the minute from current time is …:14, it will show as …:13, because of the -1

Is there also a way to loop through it, without having to scroll all the way up again?

EDIT: I think I got it. I did,

startIndex = currentDate.min + 1 and with getting the right value I did: currentMinute = values[2].index - 1

Would this be a right solution? 

Exactly right. What is it that you’re trying to do, out of curiosity?