Tab switching code gone wrong

In whenanybutton.clicked, there is an if statement. The first if statement works fine. However the else portion does not. For some reason the current_tab variable = tab 2 but should equal tab 1 in this scenario. This is a picture of all my code. I am trying to make tabs.



You have other Button.Click handlers, so you need to shield your Any Button Click logic with an
If notAlreadyHandled test.

(Unless you want this logic to run for the other buttons too.)

Also, how many digits does DynamicComponents1.GetId return?
Enough to trigger a text Contains '1' when you get past 9?

Well there can be an infinite number of tabs and this should run. But I am testing with just tab 1 and tab 2. and it wont work so I doubt it will work with tab 8 or 16 or 300. Also can you show me an example of " so you need to shield your Any Button Click logic with an
If notAlreadyHandled test." Because I don't quite understand.

So how do I fix it ? I dont understand

Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

.

okay.
Echo_proxy_bare_mytabs.aia (362.0 KB)

This is what I meant.


(draggable)

It looks the same. I dont understand what to change

Look near the top.

Now I have another problem. In my deletion code when I delete tab 1. The other tabs change like tab 2 becomes tab 1. But because I deleted tab 1. I want tab 2 that becomes tab 1 to go to google. But when tab 2 switches to tab 1 it maintains the url from the original tab 1.

It sounds like you want your tab collection to act like an AI2 list, where items move up after deletion.

That's hard to do when you give them names like tabN.

Store them together in a list.

The moving up and down works fine. Its the url. So when I delete tab one, the new tab 1 or the tab 2 switches to the old tab 1 url and not google.

It's not clear to me what rule you want covering the Google URL.

So say I have two tabs. Tab 1 and tab 2. Tab 1's url is x for example and tab 2 is y. When I delete Tab 1 I want tab 2 to become tab 1 (the new tab 1) and the new tab 1 to go to google. Right now when I delete tab 1. Tab 2 becomes tab 1 like it should. But the new tab 1's url is x like it was before. I don't want it to be x in this case. Here when I delete the current tab 1 I want the new tab 1's url to be Google. Not x. Does this help?

Maybe your intended rule is that empty tabs go to google?

You can do that by deleting tabN from TinyDB when tabN is deleted, and setting the default when reading missing tabN from TinyDB to be google.

I think the rule is, if tab 1 is deleted tab 2 becomes tab 1 and goes to google.

I don't understand how to fix it

I recommend learning how to use lists.

You are also using the tab number as the key to save/retrieve your data to the database, but when you delete tabs (and the remaining are renumbered ) then your database data is 'offset' ( is no more in sync ) respect to the new tab numbering.
Instead assign every tab a 'code' and use that code as key in the database ( the code is simply a counter, every tab you create you increment it ).