Calling other AppStudio apps

The question came up on the web board: Can I split my AppStudio app into more than one program, and have the parts call each other? Sounds like a good topic for a blog post!

The answer is yes. The benefits are simplification and splitting large apps into smaller ones. You can even share data. Here are the details:

When you deploy your program as a web app, it gets copied into a folder on your server. The server is given the name of your app. The actual program is saved as a file called ‘index.html’ in that folder. When you give enter the path to the folder into the URL bar of your browser, it knows to automatically load ‘index.html’.

Suppose you have an app called AppA and another app called AppB. Both are deployed to your server. The directory will look something like this:

AppA
   index.html
   (other files)
AppB
   index.html
   (other files)

The location command can be used to open the browser to another web page or app. In this case, since the app we want to open is on the same server, we can do this:

   location = "../AppB"

The ‘..’ moves us up one level in the folder structure. The ‘AppB’ selects our other app, and index.html in that folder gets called.

Sharing Data

Can data be shared between the two apps? While all your local variables and controls will be discarded, values in localStorage and SQLite databases will be preserved. So, if you do this in AppA:

   localStorage.myText=TextBox1.value

You can get the value in AppB as follows:

   MsgBox "localStorage is " & localStorage.myText

A few extra notes

  1. This works with Home Screen apps too.
  2. It won’t work with app compiled using PhoneGap.
  3. If you have multiple apps from the same server, be careful how you name your localStorage and SQLite variables. Use different names if you don’t want the data shared.
  4. Setting localStorage to the name of your current app can be a slick way to reinitialize your app.