ioPlus module

Monkey Programming Forums/User Modules/ioPlus module

Aman(Posted 2012) [#1]
This is a module that does some basic file input&output. It also adds support to the native Windows Phone 7 keyboard (Not perfect though). And it has a two, or one button notification dialog.

It has the following functions:

format_code('void showAlert(string title, string message, bool twoButtons, string Button1, string Button2)')
description: opens a notification dialog with one or two buttons. To get the result(a string that contain the text of the pressed button), use the getClickedButton() function.
Supported targets: XNA, Android, Flash(Not complete)

format_code('string getClickedButton()')
description: Used to get the result of the ShowAlert() funtion. It returns a string that contain the text of the pressed button. After it is called. result will be reset to "Not intiated yet".
Supported targets: XNA, Android

format_code('void showXNAKeyboard(string title, string prompt, string defaultText)')
description: XNA virtual keyboards is not supported in monkey. This will toggle the keyboard. To get the result (a string that has the typed content), use the getKeyboardInput() function.
Supported targets: XNA only (Tested on WP7)

format_code('string getKeyboardInput()')
description: Used to get the result of the showKeyboard funtion. It returns a string that contains the text typed by the user. After it is called. result will be reset to "Not intiated yet".
Supported targets: XNA only (Tested on WP7)

format_code('string loadStringFromFile(string filename)')
description: reads a file and return its content as a file. If the file does not exit, it will create it.
Supported targets: XNA, Android, GLFW

format_code('void saveStringToFile(string message, string filename)')
description: write a string to a file. If the file does not exit, it will create it. Does not append data, it writes over them. If you want to append content to a file, use loadStringFromFile first.
Supported targets: XNA, Android, GLFW

Warning: I did this really fast. It has been a long time since I worked on them. There might be a bug here or there and there is plenty of room for enhancements.

I created a Google Project page here:
http://code.google.com/p/monkey-ioplus

You can download the module from here: http://monkey-ioplus.googlecode.com/files/ioPlus.zip
Alternative Link: http://www.2shared.com/file/9ObqQhz6/ioPlus.html


Xaron(Posted 2012) [#2]
Wow that's really cool! Thanks, will check it out!


Aman(Posted 2012) [#3]
Hey Xaron, I had a feeling you would be interested in this ;)

Here are some stuff I forgot to mention in the first post:
showXNAKeyboard Will be ignored under windows. getKeyboardInput will always return "XNAWINDOWS".

I also forget to include a function that might be useful for some: Get_XNA_Target which will tell you if the game is running under windows, wp7, or xbox.

There is also another function called share(text:String) that will allow user to share a text using the native share method in Android and added a sharing method for WP7 as well. But it is not finished yet.

loadStringFromFile & saveStringToFile create & handle files in the program's path by default. I forgot where exactly will that be for each target.

Possible functions to add:
format_code('
SetPath:Void(path:String)
GetPath:Strin()
ResetPath:Void()
FileExist:Bool(filename:String)
')


Shinkiro1(Posted 2012) [#4]
Would
format_code('DirectoryFiles:String[] (dirPath:String)')
also be possible?

Thanks for sharing.


Aman(Posted 2012) [#5]
I think so but I think what is important to add iOS as a supported target first.


ziggy(Posted 2012) [#6]
Thanks!


OvineByDesign(Posted 2012) [#7]
+1 for android and IOS support :)


Aman(Posted 2012) [#8]
android is already supported. GLFW, and XNA are also supported.

HTML5 and Flash are not possible to support them using the same approach. The only way to suport them is through the save and load file dialog.


Cocopino(Posted 2012) [#9]
"HTML5 and Flash are not possible to support them using the same approach. The only way to suport them is through the save and load file dialog."

Since you're already running a browser then you could probably use a serverside script like PHP/ASP in these cases to write to a file.

I'm very interested whether you can pull it off to write local files on iOs... thanks so far!


Aman(Posted 2012) [#10]
Why? so far it seems straight forward:
http://tinyurl.com/AppleIOSfilesystem

https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Strings/Articles/readingFiles.html#//apple_ref/doc/uid/TP40003459-SW1


I am thinking of providing functions to save files directly when available or using the file delegate when available


rebelas(Posted 2012) [#11]
Is ioPlus dead?


cageInfamous(Posted 2012) [#12]
Awesome module!