Getting data from a remote server

This turns out to be pretty easy.

First, you’ll need to reformat the data on the server a bit and rename
the file:

Contents of the file:

processData("1,1000,500,500,500,500,500,500,1001,2000,1000,1000,1000");

Call it whatever you like – in my sample, it’s data.js.

Here’s the code in an NS Basic/App Studio program:

'GetData - gets some data from a remote site and processes it

Function Button1_onclick()
  head = document.getElementsByTagName("head")[0]
  newScript = document.createElement("script")
  newScript.type = "text/javascript"
  newScript.src = "http://www.nsbasic.com/data.js"
  head.appendChild(newScript)  
End Function

Function processData(s)
  data=Split(s,",")
  Textarea1.value=""
  For i=0 To UBound(data)-1
    Textarea1.value=Textarea1.value & data(i) & vbcrlf
  End If
End Function

The data in data.js is actually a mini program: it calls a function called processData with the data you want to download.

In the above code, Button1_onclick() takes that file, inserts it into your program and executes it. The code in the file calls processData, which interprets the incoming data and, in this case, simply displays it.

You’ll have to take care that no one can modify data.js, or they could
have all kinds of fun!

This sample will be included in the next build.

WebSockets

We have just uploaded Version 1.0.1. One the things it includes is a new sample called WebSockets.

WebSockets are a very new part of HTML5. They implement a higher level of the regular sockets protocol, with improved security and other advantages. This means, however, that it won’t just simply connect to Windows Winsock. There is more information here:

http://websockets.org/echo.html

WebSockets are supported starting in iOS 4.2.1. They have not appeared in Android yet.

We will be adding more information about WebSockets as we develop it.

NS Basic/App Studio 1.0.1 released

We have just put NS Basic/App Studio 1.0.1 up. You can download it from the same URL as before.

This update concentrates, not unexpectedly, on fixes. Here they are:

  1. Deploy: Meta tag viewport.user-scalable changed to no.
  2. Deploy: Missing file in deploy fixed.
  3. Deploy: Unique name for registered users is now lower case.
  4. Docs: Tutorial 1 updated to show Android install.
  5. Docs: Appearance of Language Reference improved.
  6. Docs: Handbok updated.
  7. Runtime: Titlebar images now all show.
  8. IDE: NSB Icon now appears in top left corner
  9. IDE: Removed single quotes around image names.
  10. IDE: Problem deleting forms is fixed.
  11. Controls: Label.value is now called textContent (same as runtime)
  12. Samples: new WebSockets is an early demo
  13. Translation: a = ((i/100) ^ 12 * a)
  14. Translation: a = Eval(“Grid1_” & x & “_” & y)
  15. Translation: a = NSBVersionView
  16. Translation: a=”<img src=””mario.jpg””>”
  17. Translation: If (Location.coords.longitude > 0) Then Amendment = ” east”
  18. Translation: Dim Amendment; Amendment = “”
  19. Translation: LGA(0) = “a” : LGA(1) = “b” : LGA(2) = “b”
  20. Translation: MsgBox “aaaa ()”
  21. Translation: MsgBox a.b.c()
  22. Translation: MsgBox a.b.c(0)[name]

What about Palm’s WebOS?

Michael Strupp took some time to try out NS Basic/App Studio on a Palm Pre Plus. In theory, it should work OK: it uses the same HTML5 + WebKit + JavaScript framework that NS Basic/App Studio does. Here’s his report:

I had a chance to try out NSBasic App Studio on my Palm Pre Plus and it looks like it works fine – even the email example worked great (the message loaded into my gmail app, including the body of the text). From what I read, WebOS (the OS running on the Palm Pre) is basically all built upon the WebKit model, so the two seem made for each other.

The only sample app that I tested that I couldn’t get to work right was the one where you squeeze and expand the picture of Mario – I think this is because the WebOS browser natively responds to those gestures already. Otherwise, it seems to work great.

Thanks!

Make App Store apps using AppMobi

Lennie De Villiers from South Africa has built an NS Basic app into AppMobi. AppMobi takes your apps and turns them into packages suitable for submission to the App Store. If you try this, let us know how it goes for you. We will probably turn this into a full Tech Note. Here are his notes:

  1. Register for a free account on AppMobi.com, this free account allows you to test the application but if you want to deploy to the App Store then you need to pay the license fee.
  2. Download and install AppMobi XDK IDE, this requires Chrome and Java 6 run-time. The XDK is a full IDE that run within the web browser.
  3. Run the IDE and start a new project.
  4. Choose “Open project folder” menu option.
  5. It open all the project folders… Within this folder you will find “image” folder and the index.html file
  6. Replace these files with your files (see attached sample)
  7. Back at the IDE choose the Reload button. You will see that the interface will change to show the Twitter example.
  8. Go to appmobi.com on your mobile phone
  9. Login
  10. you might need to download the test program to your phone (SlimFat)
  11. Choose your application
  12. Choose “Test Local” or “Test Anywhere”
  13. Chose Launch
  14. SlimFat will open up and run with your NSBasic application.
  15. To deploy to the App Store you need to purchase a license.

More information on how the XDK IDE works etc can be found on theĀ AppMobi web site.

We’re live!

NS Basic/App Studio 1.0.0 has been released!

Here’s the announcement:
http://www.nsbasic.com/app/PR/pr.101201.htm

You can order it here:
http://www.nsbasic.com/order.shtml

Introductory price is $99.95 – regular price is $149.95 for a Single Developer. As always, there are no royalties of distribution charges.

I’d like to thank the team who developed this product in record time. I’d also like to thank the testers who got us through 10 rounds of beta in just 11 days. We received literally hundreds of comments which led to tons of improvements and fixes.

Tip: Images in a Grid

Ever want to put an image in a grid control?

a="<img src='mario.jpg'>"
Grid1.setValue(1,1,a)

The cells in a grid will render HTML as their values. We’re just creating a simple html tag that goes into the cell.