function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "Linear", "VCenter,FillXY" )
app.ChooseFile( "Choose a file", "*/*", test )
txt = app.CreateText( "" )
lay.AddChild( txt )
//Create a text label and add it to layout.
btnshort = app.CreateButton( "Long" )
btnshort.SetOnTouch( btnshort_OnTouch )
lay.AddChild( btnshort )
btnlong = app.CreateButton( "Short" )
btnlong.SetOnTouch( btnlong_OnTouch )
lay.AddChild( btnlong )
//Add layout to app. app.AddLayout( lay )
}
function test( file )
{
alert(file)
fileuri = file;
txt.SetText( app.ReadFile( file ) )
}
function btnshort_OnTouch()
{
app.WriteFile( fileuri, "Hello how are you?" )
txt.SetText( app.ReadFile( fileuri ) )
}
function btnlong_OnTouch()
{
// app.WriteFile( fileuri, "I'm good." )
var f = app.CreateFile( fileuri,"w")
f.WriteData("I'm good.","Text")
f.Close()
txt.SetText( app.ReadFile( fileuri ) )
}
```file
After CreateFile with a uri,
then methods give error
"Cannot read prooerties of null"
(choose a file, then touch Short button)