iOS Question iCircularProgress Value (integer to a float number)

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using the iCircularProgress in my B4i App.

The value of the progress in this library is set by a float number.

I need to set the MAX value of the iCirclarProgress to be 1134.

I have created a integer in Process_Globals and I am wanting to set the iCirclarProgress value based on that number.

So far I have created a sub that will work out the percentage:

B4X:
Sub GetPercent(value As String) As Float
    Return NumberFormat(value / 1135 * 100,3,3)
End Sub

I am setting the 'value' of this sub from the integer in the Process_Globals.

So, the GetPercent for 576 should return 50 for 50%.

B4X:
Log(GetPercent(576)) 'should log 50

How can I convert this value to be the value of the iCirclarProgress ?

(Need a way to convert a integer to a float number)
 

strat

Active Member
Licensed User
Longtime User
You set value as String in the GetPercent sub. You can change it as value as int.

B4X:
Sub GetPercent(value As int) As Float
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,
How can I convert this value to be the value of the iCirclarProgress ?
you don't have to multiple by 100:

B4X:
Log(GetValue(567.5)) 'returns 0.5

Sub GetValue(Val As Float) As Float
    Return (Val / 1135)
End Sub

Jan
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

you don't have to multiple by 100:

B4X:
Log(GetValue(567.5)) 'returns 0.5

Sub GetValue(Val As Float) As Float
    Return (Val / 1135)
End Sub

Jan
Thanks for your help with this..

When I run my code 48 times (such as add 1 to my int) and update the progress it shows it at 100%.

For Example:
If I run the following approx 48 times it shows the progress as 100%.

B4X:
Sub RunMe()
    AddedItems = AddedItems + 1
    iProgressBar.AddProgress(GetValue(AddedItems),0)
End Sub

Sub GetValue(Val As Float) As Float
     Return (Val / 1135)
End Sub

I would of thought I would need to run it 1135 times before it hits 100%.

Am I doing it correctly ?
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

Am I doing it correctly ?
No, you are using AddProgress, so the Progress will be added. It's very simple:

B4X:
Sub RunMe() 'When you call this sub 1135 times iCircularProgress shows 100%
    iProgressBar.AddProgress(GetValue(1),0)
End Sub

Sub GetValue(Val As Int) As Float
     Return (Val / 1135)
End Sub
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,


No, you are using AddProgress, so the Progress will be added. It's very simple:

B4X:
Sub RunMe() 'When you call this sub 1135 times iCircularProgress shows 100%
    iProgressBar.AddProgress(GetValue(1),0)
End Sub

Sub GetValue(Val As Int) As Float
     Return (Val / 1135)
End Sub
Perfect, that fixed it.

Thanks heaps for your help. Good job on the library as well.
 
Upvote 0
Top