Android Question Designer / Variable

FrankDev

Active Member
Licensed User
Longtime User
hello

Question about the designer.

is it somehow possible to use variables ?
I need to know a calculated value again and again.

Greetings
Frank
 

DonManfred

Expert
Licensed User
Longtime User
AFAIK no.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Yes you can.
Example:
Calculate the width of three Buttons covering the full screen width with a given space.

B4X:
Space = 10dip
Width = (100%x - 4 * Space) / 3
Button1.Left = Space
Button1.Width = Width
Button2.Left = Button1.Right + Space
Button2.Width = Width
Button3.Left = Button2.Right + Space
Button3.Width = Width
 
Upvote 1

FrankDev

Active Member
Licensed User
Longtime User
Hello Klaus,

this is exactly what I was looking for.
My problem was, I had tried to dim the variable.

that did not work. On the idea not to dimension the variable I did not come :)

Thanks !!!!!

Best regards
Frank
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Yes you can.
Example:
Calculate the width of three Buttons covering the full screen width with a given space.

B4X:
Space = 10dip
Width = (100%x - 4 * Space) / 3
Button1.Left = Space
Button1.Width = Width
Button2.Left = Button1.Right + Space
Button2.Width = Width
Button3.Left = Button2.Right + Space
Button3.Width = Width
I also did not knew it. Thanks.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I had used 'breite'.
What does not work?

The code below works!
B4X:
Spalte = 10dip
Breite = (100%x - 4 * Spalte) / 3
Button1.Left = Spalte
Button1.Width = Breite
Button2.Left = Button1.Right + Spalte
Button2.Width = Breite
Button3.Left = Button2.Right + Spalte
Button3.Width = Breite
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
@klaus

Breite = (((panNumbers.Width - 22dip) - (panNumber1.width * 5)) / 4) + panNumber1.width

->>Die Datei ObfuscatorMap.txt wurde im Objects-Verzeichnis angelegt.
Kompiliere Layoutcode. Error
Unassigned variable: 'width'


Width = (((panNumbers.Width - 22dip) - (panNumber1.width * 5)) / 4) + panNumber1.width

works
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
only this code
I had also tried other variable names - without sucess


B4X:
'All variants script
AutoScaleAll

Trenner1.Width = 2dip

width = (((panNumbers.Width - 22dip) - (panNumber1.width * 5)) / 4) + panNumber1.width

panNumber2.Left = panNumber1.Left + Width
panNumber3.Left = panNumber2.Left + Width
panNumber4.Left = panNumber3.Left + Width
panNumber5.Left = panNumber4.Left + Width

panNumber7.Left = panNumber6.Left + Width
panNumber8.Left = panNumber7.Left + Width
panNumber9.Left = panNumber8.Left + Width
panNumber0.Left = panNumber9.Left + Width
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
I believe 'Width' is a reserved word. Try another variable name.

Violations of reserved words can be very difficult to debug..... as the error you get does not always give a clue to the error the compiler has experienced
 
Upvote 0
Top