Loading Data and Corresponding Values - New User Help

Sir Brando

New Member
Alright, new to B4A but fluent in a wide range of basic. I have done some digging but I'm afraid I don't know exactly what I'm looking for so any help or redirection would be great. Please bear with me.

This is what I am trying to do. This may be confusing but I’ll give an example at the end. I need to enter a number or select a number from a certain set of numbers. I then need a number corresponding to that number to be loaded from some sort of database, array or external file etc. I will copy whatever method I use for this to have multiple selections. I will use simple math to add these values up for a total.

The application for this deals with weights and moments for balancing aircraft. This is why it is so vague; don’t want to get into the weeds with details. I’ll give the best example I can though.

So my external data (or internal if I’m advised) is basically several charts of weights and corresponding moments (I have a lot of data). For example one chart is 0-3200 in increments of 100. So I’ve got 32 values to choose from. Visually, these need to be displayed in hundreds in decimal format (.1=100, 3.2=3200). I initially thought of just entering in the decimal and doing the math (so user enters 1.8 and 1800 loads as the variable) but I am open to dropdowns. Whatever weight is selected, the corresponding value is set into another variable. So if the user selects 2.5, 2500 will be loaded as the weight variable and 2693 will be loaded as the moment variable. Again, I will do this several times and add up totals at the end.

Another part of this will be loading a standard load into these selections. If the user selects load 1, I would like 1.0, 2.3, and 3.2 loaded into the above selections.

This seems like a lot explaining it but I’m just trying to paint the best picture for you guys. Unfortunately I really don’t have any guidance so far and don’t have any code to give you guys. I do have the designer layout that I will take a snap of later and attach to give sort of a visual representation of what I’m trying to do. Let me know if I'm overestimating the power of B4A as well.

Just to be clear, I’m not asking anyone to do this for me, just asking for some direction. Let me know if I need to give more details or attach data. Any help is appreciated.
 

Sir Brando

New Member
Here is a visual example of what I'm doing.

attachment.php


With my limited knowledge of b4a, my approach for the data will be to define an array for each chart. So for the chart I mentioned, dim an array for 33 variables(0-32). Then if the weight input is 1.1 then the moment will = momentArray(11). Does this sound like the path you guys would take? Something else to keep in mind, my largest chart would need 509 variables this way. Without looking I assume this is within an array's scope.
 

Attachments

  • Fuel Load example.gif
    Fuel Load example.gif
    8.1 KB · Views: 270
Upvote 0

klaus

Expert
Licensed User
Longtime User
Are you working with the demo program ?

Working with charts reminds me some old days.
Then if the weight input is 1.1 then the moment will = momentArray(11).
What is the relationship between the weight and the moment ?
Behind charts the are mathematical equations.
It would be more efficient to use those.
That's the way I would go, but without knowing what exactly is behind these charts it's not easy to give you concrete advice.

I remember for calculation programs (mechanical engeneering) when calculating by hand we had several equations and needed to calculate intermediate values then get another one in a chart to continue with the next equation. In the computer program we replaced the charts by equations, the user entered only the needed data and the rest was done by the program.

Best regards.
 
Upvote 0

Sir Brando

New Member
What is the relationship between the weight and the moment ?
Behind charts the are mathematical equations.
It would be more efficient to use those.

Believe me I wish it were that easy. This all has to do with balancing fuel in multiple tanks for stable aircraft flight. You have the weight of the fuel, then that is multiplied by the distance in Inches from the nose of the aircraft to the tank. There are average distances for rough calculations but the charts factor in distribution of weight across the tank. Therefore a math equation wouldn't be accurate unless I figured out the multiplication factor for every single weight increment in every tank. This would take more time that manually entering the chart data into variables.

Short answer, there is no getting around the chart data. I can explain more visually but at this point I'm going to start plugging the numbers into arrays until someone gives me a better route. My concern now is how much this will slow the program down. Roughly, I have about 2000 numbers to load into 10 arrays doing it this way.

Main issue now is figuring out what Views in the designer fit the needs of the app and make it more efficient.

Thanks for the input.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Sir Brando .. this sounds similar to when I was working in the Oil Industry.
To convert fuels to a global standard temperature of 15 deg celsius you would manually reference conversion charts. knowing the fuels temp. and density you could reference a conversion factor. I often thought of a vb program way back then to input those factors and do the calculation automatically ... but there was no mathematical consistency to the thousands of conversion factors for it to be done progmattically.

Is this similar to your dilemma.

Cheers mj
 
Upvote 0

Sir Brando

New Member
mj,
This sounds like the same kind of situation. There is no way to get around using the data from the tables. There is no consistent math formula. I will just start loading these values into arrays and see how that much data affects performance.

As far as performance goes, should I manually put every value into the code(approx. 2000), or should the values be loaded into arrays from a file at program start?

Thoughts.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
SB don't take my lead as still learning myself , but wouldn't you be populating a database/tables to be referenced when needed, or at least loaded to lists at program start.

Cheers mj
 
Upvote 0
Top