We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge 4 - Colour buttons
#11
I would like to explain the issue of internal names in a hopefully understandable way:

AB says:
When creating a button, we assign its internal name to a variable.
The developer assigns the name of this variable himself. He can use the name that is most convenient and understandable to him.

That's correct, but 2 examples don't use the variable !

In litdev's and my demo the variable is used:
button = Controls.AddButton("",buttonX[i],buttonY[i])
If (Controls.LastClickedButton = button[i]) Then
ButtonRed = Controls.AddButton("",10,10)
If Controls.LastClickedButton = ButtonRed then

[i]The programs work independently of the internal button name


The variable is not used in the example by jr
Button1=Controls.AddButton("My Button1",0,0)
If Controls.LastClickedButton = "Button1" then

The string "Button1" is queried and not the content of the variable Button1.
Beginners might ask, why do I have to put the variable in quotation marks?

The variable is not used in the example by whturner


but[bb]=Controls.AddButton("",50*bb,gh-40)
lastbut=Text.GetSubTextToEnd(Controls.LastClickedButton,7)

It is assumed that the 7th position of the internal name always contains 1, 2 or 3.
Very mysterious for beginners.


Both  programs assume that the internal name never changes!

This could happen with an update of Small Basic (very unlikely).
But also as in my example, where the buttons have to be removed and recreated so that the text gets a different color.
 When a new button is created, the name is continuously incremented. I have expanded the example with a text window output:
    [/i][/i][/i][/i]
Reply


Messages In This Thread
Challenge 4 - Colour buttons - by litdev - 09-04-2024, 06:06 PM
RE: Challenge 4 - Colour buttons - by jrmrhrb00 - 09-04-2024, 07:35 PM
RE: Challenge 4 - Colour buttons - by Scout - 09-04-2024, 09:23 PM
RE: Challenge 4 - Colour buttons - by litdev - 09-05-2024, 09:11 AM
RE: Challenge 4 - Colour buttons - by Scout - 09-05-2024, 11:16 AM
RE: Challenge 4 - Colour buttons - by WhTurner - 09-07-2024, 12:01 PM
RE: Challenge 4 - Colour buttons - by Scout - 09-07-2024, 08:12 PM
RE: Challenge 4 - Colour buttons - by jrmrhrb00 - 09-08-2024, 11:02 AM
RE: Challenge 4 - Colour buttons - by Scout - 09-08-2024, 08:45 PM
RE: Challenge 4 - Colour buttons - by z-s - 09-09-2024, 02:28 AM
RE: Challenge 4 - Colour buttons - by z-s - 09-09-2024, 04:07 AM
RE: Challenge 4 - Colour buttons - by litdev - 09-09-2024, 08:20 AM
RE: Challenge 4 - Colour buttons - by Scout - 09-09-2024, 09:26 AM
RE: Challenge 4 - Colour buttons - by z-s - 09-09-2024, 10:12 AM
RE: Challenge 4 - Colour buttons - by litdev - 09-09-2024, 11:16 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)