Writing to file on android: Null Function Pointer

86 views
Skip to first unread message

Michelle Brodeur

unread,
Apr 15, 2014, 1:48:17 PM4/15/14
to haxe...@googlegroups.com

Ok, read a lot of post, seem sto be written correctly.

Here is the code:

in the application.xml we have

<!— Android Permisions —>

<android permission=“android.permission.WRITEEXTERNALSTORAGE” />

In our test function we have:

public static function testWrite( ):Bool

{

// Attempting to open/create the file:

var lfileOut:Dynamic = null;

trace(“write path and file: ” + SystemPath.applicationStorageDirectory + “test.dat” );

try {

lfileOut = File.write( SystemPath.applicationStorageDirectory + “test.dat”, true );

} catch ( perror:Error ) { return false; }

trace(“fileout ” + lfileOut + “.”);

if ( lfileOut != null )

{

trace( “Trying to get the uuid.”);

var ldeviceUID:String = Device.getUuid();

trace(“the uuid is: ” + ldeviceUID + “.” );

var ldeviceUIDLength:Dynamic = ldeviceUID.length;

trace(“The length of the UID is ” + ldeviceUIDLength + “.”);

lfileOut.writeString( ldeviceUIDLength );

trace(“The length of the UID is written.” );

lfileOut.writeString( ldeviceUID );

trace(“file was written.”);

lfileOut.close();

trace(“File was closed.”);

return true;

}

// If somthing went wrong we return false:

return false;

}

When we run it on the android we get this:

I/trace (23094): TestIO.hx:49: write path and file: openfl.utils.Sys

temPathtest.dat

I/trace (23094): Lib.hx:300: [fileopen,openfl.utils.SystemPathtest.dat]

I/trace (24692): TestIO.hx:49: write path and file: openfl.utils.Sys

temPathiaptoken.dat

I/trace (24692): Lib.hx:300: [fileopen,openfl.utils.SystemPathtest.dat]

I/trace (25827): IAPUnlockHelpers.hx:49: write path and file: /data/data/com.A

byss.test/filestest.dat

I/trace (25827): IAPUnlockHelpers.hx:54: fileout FileOutput.

I/trace (25827): IAPUnlockHelpers.hx:57: Trying to get the uuid.

I/trace (25827): IAPUnlockHelpers.hx:59: the uuid is: ************

I/trace (25827): IAPUnlockHelpers.hx:61: The length of the UID is 36.

I/trace (25827): Lib.hx:300: Null Function Pointer

Any ideas?


Cauê Waneck

unread,
Apr 15, 2014, 4:07:58 PM4/15/14
to haxe...@googlegroups.com
var ldeviceUIDLength:Dynamic = ldeviceUID.length;

the problem is with using Dynamic. writeString() expects a string to be passed, you are however passing an Int as a Dynamic. You should convert the length into a string by either using Std.string() or var len = ldeviceUID.length + "";



--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Michelle Brodeur

unread,
Apr 15, 2014, 4:46:49 PM4/15/14
to haxe...@googlegroups.com
Sorry No Joy

This did not work.

Big problem is why does the Try Catch not catch it for not making the file.

It comes back as a Type of “FileOutput” and so it passes a Null check.

We have tried byte, int, string


with lime clean application android

lime build application android

lime test application android


everything is the latest version with update and upgrade.

Michelle Brodeur

unread,
Apr 15, 2014, 4:57:46 PM4/15/14
to haxe...@googlegroups.com
Ok any one reading this post, this was the prblem.
var fileOut:Dynamic = null;

should be

var fileOut = null;

Who knew.....

thanks all


On Tuesday, 15 April 2014 13:48:17 UTC-4, Michelle Brodeur wrote:
Reply all
Reply to author
Forward
0 new messages