Switch Database

Good evening everyone,

I have multiple databases and was wondering if there was a way to switch the active database with AFL by for example using a GuiButton (big fan of those) or maybe even OLE? I tried searching on this forum and google a little but couldn't find anything pertaining to that.

If anyone has any pointers I would appreciate it.

Cheers.

I am not fan of cutting off the branch you are sitting on (and that is exactly what you are trying to do in this idea of switching database from within AFL when AFL is running).

image

Having said that - everything is technically possible if there is a skill. You could call ShellExecute in response to GuiButton and execute external Javascript that would call OLE automation and call AB.LoadDatabase.

4 Likes

Posting this just in case anyone wants to use something similar in the future... it's quick and efficient and I do welcome criticisms and improvements.

  1. Create a JS script👇
AB = new ActiveXObject("Broker.Application"); 
AB.SaveDatabase()
AB.LoadDatabase("C:\\AmiBroker\\Databases\\Database1\\")

Of course replace the above with the relevant path...

  1. Then create a new tool with the script above...
    image

  2. Lastly create a shortcut to the tool you just created...
    image

I believe this would have to be done for each database that you have... there is probably a way to detect the current database name and move to the next one... db1→db2 ... but this will do for me for now.

Cheers.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.