iOS Question how to handle number (double) and display it as a text label

Yves Rossignol

Member
Licensed User
I'm totally new in b4i and i want to make a small program for welds design (the purebasic version have more than 3700 lines)... but in this case, i don't understand hot to handle number and text.... Please help me... If someone want to help me.... just show me how to make Lw = Depth +witdh... i will continue my works after. I can pay and if you want the software (when it will be done... i will send you a free version)

Yves

sorry I'm french canadian so english is very bad.

you can see the windows version at : www.yrtechnosoft.com
 

Attachments

  • Welds.zip
    219.6 KB · Views: 266

klaus

Expert
Licensed User
Longtime User
You need to give some more information.
What is Lw supposed to be?
You have TextFields in your layouts with the name Lw.
So what exactly do you want to do?
You can ask the questions in the french forum.

Tu dois fournir plus d'informations.
Que représente Lw?
Tu as des TextFields dans tes layouts avec le nom Lw.
Qu'est-ce que tu veux faire exactement.
Tu peux poser les question dans le forum français.
 
Upvote 0

Yves Rossignol

Member
Licensed User
No, not this way... I want to enter a value at lblDepth into first screen so the user can change Depth and width...

explanation of formula lenght of weld = depth + width (no realy for a single weld... but i just try to understand... for a square welds Lw = 2*(Depth+witdh)
 
Upvote 0

Yves Rossignol

Member
Licensed User
it is from this table and I give you and exemple of program in other language. I give you an image for a doube welds...
 

Attachments

  • Capture.JPG
    Capture.JPG
    21.8 KB · Views: 249
  • page1.JPG
    page1.JPG
    125.3 KB · Views: 246
  • Capture1.JPG
    Capture1.JPG
    23.4 KB · Views: 225
Upvote 0

klaus

Expert
Licensed User
Longtime User
If you want the user to enter data you need to use TextFields and not Labels.
If you want to only display data you should use Labels and not TextFields.
So, you should add in btnresultsp_Click
Depth = txfDepth.Text
Witdh = txfWidth.Text

txfDepth and v should be TextFields.

Then in the resultsp module you can set:
Lw.Text = singleW.Depth + singleW.Width
Lw should be a Label

I had prepaired this post before your last post.
Now i see in one image Lw as a variable and in your layouts you have TextFields with the same name!?
Do you also need Lw as a variable?
 
Last edited:
Upvote 0

Yves Rossignol

Member
Licensed User
It's work yes and no.. I explain, when I hit the btnresultsp the application go to the result screen but without computing Lw .... I go bck to the singleW screen and hit again btnresultsp and this time I have the result...
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, I don't understand the logic.
Why do you want to oblige the user to go to the result screen, go back to the singleW screen and again go to the result screen.
From a users point of view i don't understand, or your explanation is incomplete.

I had a closer look at your project and have some suggestions.

1. Don't use TextViews to just display text, TextField are editable use Labels instead.

2. Use meaningful prefixes for views. You use lblDepth for a TextField.
Use lblDepth for a Label and txfDepth for a TextField.
3. Don't use same names for views and numeric variables.

4. Use different colors for different views to make clear what is a button, what is a user entry field, what is text, what is a displayed result etc.

5. For the units, don't use a TextField, because the user can enter anything.
Use a selection view and give the user only existing choices.
Selecting views:
SegmentedControl, if you up tp 4 entries.
Picker, if you have more entries.
Combobox(not iOS standard), Android like selection view (I have never used it).

6. I would limit the screen orientations to portrait only for iphones and landscape for ipads.
Use only one page and use for each layout a Panel.
Then you can display one Panel at the same time on iphones and two Panels side by side on ipads.
 
Last edited:
Upvote 0

Yves Rossignol

Member
Licensed User
Hi, I explain the behavior of the app not what i want. I want to hit the btnresultsp and make two actions : 1-compute Lw and go to result sreen in the same time....

I will take a closer look at your advice. Thank you sir, Merry Christmas.

A zip file is included with this post.
 

Attachments

  • Welds.zip
    442.4 KB · Views: 229
Upvote 0

Yves Rossignol

Member
Licensed User
Hello I will explain the logic that I want to make. I am a little lost because I think I made too much change at the same time. The application starts with "main" and by pressing the "OK" button one should go to the "choice" screen. By pressing on one of the buttons of this screen there are choices of welding geometry (there will be at least two pages of choice). Then we go to the page of the type of welding (singleW, doubleW, etc.) and calculate the properties ... There I have a problem because in the screen "resultsp" variables have the same name either by Example Lw.text = singleW.Lw, but should be Lw.text = doubleW.Lw for the second type of solder ... I added a variable "choiceW" and I want to put "if" to choose the right name .... after calculating the properties I have to calculate the forces and flows. I would always use the same page "resultsp", and "force" (coming soon) for every type of welds. I will also have pages for the "disclaimer", "theory", "register", etc ... I'll need a menu ... and help and advice. Thank you and Merry Christmas.
 

Attachments

  • resultsp.zip
    111.1 KB · Views: 235
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I would have used a Map or a custom type that holds all the information that needs to be displayed.

Something like:
B4X:
'resultp
Public Show(Data As Map)
 Lw.Text = Data.Get("Lw") 'case sensitive
 ...
End Sub

'singleW
ResultP.Show(CreateMap("Lw": Lw, "Sx": Sx))

Using a custom type is a bit more elegant.
You need to declare it once (in the main module or any other).
B4X:
Type WeldingData (Lw As Double, Sx As Double, ...)

Now use an instance of this type in each of the modules and pass it to ResultP.Show.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would use only one page to enter the data and, depending on what kind of welding, display only the relevant views.
Use the same variables for the different parameters therefore no need to make a ditinction between similar variables.
I repeat, you should not use TextFields nor TextViews to display text but Labels.
For example, if you click on any view in the result page, the keyboard is shown, do you really want this?
 
Upvote 0

Yves Rossignol

Member
Licensed User
What do you think if I use a matrix like dim resu(20) as double and put all value into this matrix... it is like using my own type but I need a translation sub... but I will need later to change all value from metric to english system and from english to metric... Lw is in mm, Sx in cubic mm, etc...
 
Upvote 0

Yves Rossignol

Member
Licensed User
I have made a lot of change into my app. But i need to understand the way to use type weldingdata and how to use exponential result like 1.2e+6 instead of 1200000

thank you... after that i will have a lot of work

yves

the source file is too big... what can I do ????
 
Upvote 0
Top