Difference between revisions of "A Simple Program"

From NSB App Studio
Jump to navigation Jump to search
 
(19 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
The purpose of this tutorial is to demonstrate how a simple program is created using AppStudio. You should have AppStudio installed before beginning this tutorial.
 
The purpose of this tutorial is to demonstrate how a simple program is created using AppStudio. You should have AppStudio installed before beginning this tutorial.
 +
 +
You can view a similar video here: https://www.youtube.com/watch?v=hzyXuOJjp-E
  
 
=== Description of the Program ===
 
=== Description of the Program ===
Line 16: Line 18:
 
# Deploy Bar: Starts your app. The picker lets you choose where you want it run.
 
# Deploy Bar: Starts your app. The picker lets you choose where you want it run.
 
# Tab Bar: Use this to switch between your open designs and code.
 
# Tab Bar: Use this to switch between your open designs and code.
 +
# Editor Bar: Choose Design Screen or Code Window, also Find and go to a function.
 
# ToolBox: A list of controls you can put on a form.
 
# ToolBox: A list of controls you can put on a form.
# Editor Bar: Choose Design Screen or Code Window, also Find and go to a function.
 
 
# Design Screen: Here is where you layout the objects on the form.
 
# Design Screen: Here is where you layout the objects on the form.
 
# Project Explorer: See the structure of your code. Use this to select objects and to bring up the Properties for them.
 
# Project Explorer: See the structure of your code. Use this to select objects and to bring up the Properties for them.
Line 24: Line 26:
 
# Hints: Some tips on the current object.
 
# Hints: Some tips on the current object.
 
# (not shown yet) Code Window: An editor for your program code.
 
# (not shown yet) Code Window: An editor for your program code.
 +
<br><br>
  
 
2. Create a new project. Select menu item File...New. Choose BASIC as your programming language, the default iPhone/Nexus size and use HelloWorld as your new File name.  
 
2. Create a new project. Select menu item File...New. Choose BASIC as your programming language, the default iPhone/Nexus size and use HelloWorld as your new File name.  
  
 
[[File:TT01.02.png]]<br>
 
[[File:TT01.02.png]]<br>
 +
<br><br>
 +
 
It's best to create your project in a new folder.
 
It's best to create your project in a new folder.
  
 
[[File:TT01.03.JPG]]<br>
 
[[File:TT01.03.JPG]]<br>
 +
<br><br>
 +
 
3. Add a Button. Select the button in the ToolBox and drag & drop it where you like.
 
3. Add a Button. Select the button in the ToolBox and drag & drop it where you like.
  
 
[[File:TT01.04.JPG]]<br>
 
[[File:TT01.04.JPG]]<br>
 +
<br><br>
 +
 
4. Edit the Value of the button to say "Click Me!"
 
4. Edit the Value of the button to say "Click Me!"
  
 
[[File:TT01.05.JPG]]<br>
 
[[File:TT01.05.JPG]]<br>
 +
<br><br>
 +
 
5. We can actually run the program now. Choose Run...Start in Desktop Browser. It runs in your default browser: we recommend using Chrome or Safari, as these support the WebKit extensions which mobile devices use. We could even run this on a device, but let's do a bit more first...
 
5. We can actually run the program now. Choose Run...Start in Desktop Browser. It runs in your default browser: we recommend using Chrome or Safari, as these support the WebKit extensions which mobile devices use. We could even run this on a device, but let's do a bit more first...
  
 
[[File:TT01.06.JPG]]<br>
 
[[File:TT01.06.JPG]]<br>
6. In the Properties Editor, choose onclick. It will show a popup with 'Button1_onclick()'. Select that, and you will go into the Code Window:
+
<br><br>
 +
 
 +
6. In the Properties Editor, choose Events. It will show a popup with with the events for buttons. Near the top, you will see 'onclick'. Select that, and you will go into the Code Window:
  
 
[[File:TT01.07.JPG]]<br>
 
[[File:TT01.07.JPG]]<br>
 +
 +
<br><br>
 
7. Add the following code into the function:
 
7. Add the following code into the function:
 
   Msgbox "Hello World!"
 
   Msgbox "Hello World!"
  
 
[[File:TT01.08.JPG]]<br>
 
[[File:TT01.08.JPG]]<br>
 +
 +
<br><br>
 
8. Now, run it again and click on "Click Me!"
 
8. Now, run it again and click on "Click Me!"
  
 
[[File:TT01.09.JPG]]<br>
 
[[File:TT01.09.JPG]]<br>
 +
 +
<br><br>
  
 
=== Run on an iPhone ===
 
=== Run on an iPhone ===
  
1. Good work! Now let's run it on a phone. From the Deploy picker, choose "Deploy to nsbapp.com server". The IDE will upload your complete app to a webserver called nsbapp.com. We have set this one up for AppStudio users for testing. (We're using an iPhone here. We'll do it for Android next.)
+
1. Good work! Now let's run it on a phone. From the Deploy picker, choose "Deploy to Volt". Volt is a test server we have set up for AppStudio users. (We're using an iPhone here. We'll do it for Android next.)
 +
 
 +
Choose "I'd like to continue using the demo account for now". You can set up a permanent account later, and click Deploy.
  
 
[[File:TT01.10.JPG]]<br>
 
[[File:TT01.10.JPG]]<br>
2. Now, get your iPhone and go into Safari. Enter in the URL from the last step.
+
<br><br>
 +
 
 +
2. You'll see this. Enter the link into Safari or use a QR Code scan utility to start app.
 +
 
 +
[[File:TT01.11.JPG]]<br>
 +
<br><br>
  
[[File:TT01.11.png]]<br>
 
 
3. Hit Go. The page will appear. You can tap on "Click Me!", and you'll see: a working app in AppStudio.
 
3. Hit Go. The page will appear. You can tap on "Click Me!", and you'll see: a working app in AppStudio.
  
[[File:TT01.12.JPG]]<br>
+
[[File:TT01.12.png|border]]<br>
4. But this isn't a real app: it's just a web page that looks like one. Let's turn it into a real app on the Home Screen. First, we'll tap on the arrow icon at the bottom of the screen.
+
<br><br>
 +
 
 +
4. But this isn't a real app: it's just a web page that looks like one. Let's turn it into a real app on the Home Screen. First, we'll tap on the box with an arrow icon at the bottom of the screen.
 +
 
 +
[[File:TT01.13.png]]<br>
 +
<br><br>
  
[[File:TT01.13.JPG]]<br>
 
 
5. Choose "Add To Home Screen", then click on Add.
 
5. Choose "Add To Home Screen", then click on Add.
  
[[File:TT01.14.JPG]]<br>
+
[[File:TT01.14.png]]<br>
 
6. We're done. Let's have a look. Here is the Home Screen:
 
6. We're done. Let's have a look. Here is the Home Screen:
  
[[File:TT01.15.JPG]]<br>
+
[[File:TT01.15.png]]<br>
7. Click on the HelloWorld icon, and this splash screen shows up:
+
7. Click on the HelloWorld icon. Now the app itself is showing. Notice the top Safari bar is not there? This app now looks and runs like a normal phone app. It will even run if the device is offline.
 
 
[[File:TT01.16.JPG]]<br>
 
8. Now the app itself is showing. Notice the top Safari bar is not there? This app now looks and runs like a normal phone app. It will even run if the device is offline.
 
  
[[File:TT01.17.JPG]]<br>
+
[[File:TT01.17.png]]<br>
  
 
=== Run on an Android device ===
 
=== Run on an Android device ===
Line 84: Line 110:
 
1. Here is how our app looks.
 
1. Here is how our app looks.
  
[[File:TT01.18.JPG|240px|320px]]<br>
+
[[File:TT01.18.png|border]]<br>
2. Tap on the menu button to bring up your choices. Click on Bookmarks.
+
<br><br>
 +
 
 +
2. Tap on the menu button to bring up your choices. Click on Add to homescreen.
  
[[File:TT01.19.JPG|240px|320px]]<br>
+
[[File:TT01.19.png]]<br>
3. Click on Add to add it to your bookmarks.
+
<br><br>
  
[[File:TT01.20.JPG|240px|320px]]<br>
 
4. Change the name if you need to, then tap on OK.
 
  
[[File:TT01.21.JPG|240px|320px]]<br>
+
3. Click on Add to add it to your Home Screen.
5. Hit the Home key to get back to the Home Screen
 
  
[[File:TT01.22.JPG|240px|320px]]<br>
+
[[File:TT01.20.png]]<br>
6. Hold your finger down on the Home Screen until this pops up. Select Shortcuts.
+
<br><br>
  
[[File:TT01.23.JPG|240px|320px]]<br>
+
4. Here is how it looks on the homescreen.
7. Select Bookmark.
 
  
[[File:TT01.24.JPG|240px|320px]]<br>
+
[[File:TT01.21.png]]<br>
8. Select HelloWorld.
+
<br><br>
  
[[File:TT01.25.JPG|240px|320px]]<br>
+
5. Here is how it looks running on the homescreen.
9. And here is our new Home Screen. The new app on the home screen will run whether the device is connected to the net or not.
 
  
[[File:TT01.26.JPG|240px|320px]]<br>
+
[[File:TT01.22.png|240px|320px]]<br>

Latest revision as of 14:20, 10 May 2019

Purpose

The purpose of this tutorial is to demonstrate how a simple program is created using AppStudio. You should have AppStudio installed before beginning this tutorial.

You can view a similar video here: https://www.youtube.com/watch?v=hzyXuOJjp-E

Description of the Program

The program to be developed will display a form with a button on it. When the user taps the button, the program responds with the message "Hello World!"

Program Development

Startup

1. Start AppStudio from the Start menu. Here is what you will see:

TT01.01.png

  1. Deploy Bar: Starts your app. The picker lets you choose where you want it run.
  2. Tab Bar: Use this to switch between your open designs and code.
  3. Editor Bar: Choose Design Screen or Code Window, also Find and go to a function.
  4. ToolBox: A list of controls you can put on a form.
  5. Design Screen: Here is where you layout the objects on the form.
  6. Project Explorer: See the structure of your code. Use this to select objects and to bring up the Properties for them.
  7. Properties Grid: A list of the properties of the item selected in the Project Explorer.
  8. Status Bar: Messages from the IDE to you.
  9. Hints: Some tips on the current object.
  10. (not shown yet) Code Window: An editor for your program code.



2. Create a new project. Select menu item File...New. Choose BASIC as your programming language, the default iPhone/Nexus size and use HelloWorld as your new File name.

TT01.02.png


It's best to create your project in a new folder.

TT01.03.JPG


3. Add a Button. Select the button in the ToolBox and drag & drop it where you like.

TT01.04.JPG


4. Edit the Value of the button to say "Click Me!"

TT01.05.JPG


5. We can actually run the program now. Choose Run...Start in Desktop Browser. It runs in your default browser: we recommend using Chrome or Safari, as these support the WebKit extensions which mobile devices use. We could even run this on a device, but let's do a bit more first...

TT01.06.JPG


6. In the Properties Editor, choose Events. It will show a popup with with the events for buttons. Near the top, you will see 'onclick'. Select that, and you will go into the Code Window:

TT01.07.JPG



7. Add the following code into the function:

 Msgbox "Hello World!"

TT01.08.JPG



8. Now, run it again and click on "Click Me!"

TT01.09.JPG



Run on an iPhone

1. Good work! Now let's run it on a phone. From the Deploy picker, choose "Deploy to Volt". Volt is a test server we have set up for AppStudio users. (We're using an iPhone here. We'll do it for Android next.)

Choose "I'd like to continue using the demo account for now". You can set up a permanent account later, and click Deploy.

TT01.10.JPG


2. You'll see this. Enter the link into Safari or use a QR Code scan utility to start app.

TT01.11.JPG


3. Hit Go. The page will appear. You can tap on "Click Me!", and you'll see: a working app in AppStudio.

TT01.12.png


4. But this isn't a real app: it's just a web page that looks like one. Let's turn it into a real app on the Home Screen. First, we'll tap on the box with an arrow icon at the bottom of the screen.

TT01.13.png


5. Choose "Add To Home Screen", then click on Add.

TT01.14.png
6. We're done. Let's have a look. Here is the Home Screen:

TT01.15.png
7. Click on the HelloWorld icon. Now the app itself is showing. Notice the top Safari bar is not there? This app now looks and runs like a normal phone app. It will even run if the device is offline.

TT01.17.png

Run on an Android device

On Android the procedure is even simpler.

1. Here is how our app looks.

TT01.18.png


2. Tap on the menu button to bring up your choices. Click on Add to homescreen.

TT01.19.png



3. Click on Add to add it to your Home Screen.

TT01.20.png


4. Here is how it looks on the homescreen.

TT01.21.png


5. Here is how it looks running on the homescreen.

TT01.22.png