Thursday, May 29, 2014

titanium: Option dialog

//-- Option Dialog
var optdialog = Ti.UI.createOptionDialog({
 cancel: 2,
 options: ['2 hours', '4 hours', '8 hours'],
 buttonNames: ["Cancel"],
 selectedIndex: 2,
 destructive: 0,
 title: 'Sleep'
});
optdialog.show();

optdialog.addEventListener('click', function(e){
Ti.API.info("option dialog ended with: "  + e.index);
});

titanium: Switch, Picker, Button, AlertDialog

 var view = Ti.UI.createView();

// ---------- Switch
var basicSwitch = Ti.UI.createSwitch({
 value:true,
 top: 30, right: 30
});
view.add(basicSwitch);




// ---------- Picker
var picker = Ti.UI.createPicker({
 top:100, right: 30
});

var list = ['Bananas', 'Strawberries','Mangos','Grapes'];
var data = [];
for(var i = 0; i < list.length; i++){
data[i]=Ti.UI.createPickerRow({title:list[i], rowIndex: i});
}


picker.add(data);
picker.selectionIndicator = true;

picker.addEventListener("change", function(e){
Ti.API.info("changed: " + e.rowIndex );
});

view.add(picker);



//-- date picker
var datepicker = Ti.UI.createPicker({
type: Titanium.UI.PICKER_TYPE_DATE,
 top:200
});
datepicker.addEventListener("change", function(e){
Ti.API.info("changed: " + e.value );
});

view.add(datepicker);



//-- button
var button = Titanium.UI.createButton({
  title: 'Get Result',
  top: 420
});
button.addEventListener("click", function(e){
Ti.API.info("switch: " + basicSwitch.value);
Ti.API.info("picker: " + picker.getSelectedRow(0).rowIndex);
Ti.API.info("date picker: " + datepicker.value);

//-- Alert Dialog
var dialog = Ti.UI.createAlertDialog({
   message: 'You have selected switch: ' + basicSwitch.value,
   cancel: 1,
   buttonNames: ["OK",'Try Again', 'Cancel'],
   title: 'Button Clicked'
 });

dialog.addEventListener('click', function(e){
Ti.API.info("dialog ended with: "  + e.index);
});

dialog.show();

});

view.add(button);




Thursday, May 15, 2014

Titanium TableView

var list = [{title:"Label Demo", url:""},
{title:"Button Demo", url:"SecondView.js"}, 
{title:"Switch Demo", url:""}, 
{title:"ImageView Demo", url:"imageview.js"}];
var tableData = [];

for (var i=0; i  < list.length; i++){
 var row = Ti.UI.createTableViewRow({
   className:'forumEvent', // used to improve table performance
   //selectedBackgroundColor:'white',
   rowIndex:i, // custom property, useful for determining the row during events
   height:70,
   backgroundSelectedColor:'#ccc'
 });
 
 
 var labelUserName = Ti.UI.createLabel({
   color:'#333',
   font:{fontFamily:'Roboto', fontSize:18},
   text:list[i].title,
   left:20, top: 15,
   width:200, height: 40
 });
 
 row.add(labelUserName);
 
 tableData.push(row);
}

var tableView = Ti.UI.createTableView({
 backgroundColor:'white',
 separatorColor:'#999',
 data:tableData
});

tableView.addEventListener("click", function(e){
Ti.API.info("clicked at row " + e.rowData.rowIndex);
var win = Ti.UI.createWindow({
url:list[e.rowData.rowIndex].url,
title: list[e.rowData.rowIndex].title,
myVar: list[e.rowData.rowIndex].title,
backgroundColor:"white"
});
win.open();
})

self.add(tableView);


titanium ImageView

  // create another variable , self
var self = Ti.UI.currentWindow;
var view = Ti.UI.createView();


var imageView = Ti.UI.createImageView(
{
image:'/images/screenshot_AVD.png',
enableZoomControls:false,
width:'auto',
height:'auto'
}
);
imageView.addEventListener("load", function(e){
Ti.API.info("image loaded");
Ti.API.info("size: " + imageView.size.width + ", " + imageView.size.height);
}

);
var scrollView = Ti.UI.createScrollView(
{
//contentWidth: 'auto',
 //contentHeight: 'auto',
 showVerticalScrollIndicator: true,
 showHorizontalScrollIndicator: true,
 height: '80%',
 width: '80%'
 //zoomScale:2,
 //minZoomScale:1,
 //maxZoomScale:7
}
);

var originalWidth = -1;
var originalHeight = -1;
var scale = 1;

scrollView.addEventListener("touchend", function(e){
Ti.API.info("touchend");

originalWidth *= scale;
originalHeight *= scale;
});

scrollView.addEventListener("pinch", function(e){
Ti.API.info("pinch: " + e.scale);
//scrollView.zoomScale = e.scale;
if(originalWidth < 0){
Ti.API.info("size: " + imageView.size.width + ", " + imageView.size.height);
originalWidth = imageView.size.width;
originalHeight = imageView.size.height;
}
imageView.width = e.scale * originalWidth;
imageView.height = e.scale * originalHeight;
scale = e.scale;
//scrollView.contentWidth *= e.scale ;
//scrollView.contentHeight *= e.scale;
})

scrollView.add(imageView);
self.add(scrollView);



not fool proof for zooming. scrollbar not showing properly
may be better to use the transform matrix, eg. scale

Titanium Appcelerator - commonly used API & quick code samples

 http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Label
var label2 = Ti.UI.createLabel({
  color:'blue',
  text: 'A long label with\na few line breaks\nand unicode (UTF8)\nsymbols such as\na white chess piece \u2655\nand the euro symbol \u20ac\nlooks like this!\n',
  textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
  top: 30,
  width: 300, height: 200
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Button
var button = Titanium.UI.createButton({
   title: 'Hello',
   top: 10,
   width: 100,
   height: 50
});
button.addEventListener('click',function(e)
{
   Titanium.API.info("You clicked the button");
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TextField
var textField = Ti.UI.createTextField({
  borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
  color: '#336699',
  top: 10, left: 10,
  width: 250, height: 60
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.View
var view = Titanium.UI.createView({
   borderRadius:10,
   backgroundColor:'red',
   width:50,
   height:50
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ScrollView
var scrollView = Ti.UI.createScrollView({
  contentWidth: 'auto',
  contentHeight: 'auto',
  showVerticalScrollIndicator: true,
  showHorizontalScrollIndicator: true,
  height: '80%',
  width: '80%'
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableView
var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ];
var table = Ti.UI.createTableView({
  data: tableData
});

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window
var window = Titanium.UI.createWindow({
     backgroundColor:"#FFC",
     title:"Scroll View Demo",
     navBarHidden:true,
    url:"ScrollViewDemo.js"
 });
 window.open();

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ImageView
var image = Ti.UI.createImageView({
  image:'/images/banner.jpg'     // assuming that the JPG is stored in 'images' folder in 'Resources' folder
});

http://developer.appcelerator.com/question/116655/session---global-variables
eg.: Ti.App.myVar (something like session variable)
OR
Ti.App.Properties.setObject("mystr", "mystr") // persistant storage
OR
newWindow.myVar (something like GET variable passed)

Friday, February 07, 2014

Phonegap / Cordova - set up and 1st app experience

follow installation steps
http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-Line%20Interface

download and install android adt-bundle. add tools and platform-tools dir in sys path
install nodejs
install apache ANT. add path to sys PATH
add Java JDK dir to JAVA_HOME sys variable

restart pc
command prompt
npm install -g cordova (if referring to phonegap docs online: for cordova,. just replace all "phonegap" with "cordova")

phonegap / cordova app installed in user dir, eg
C:\Users\{USERNAME}\AppData\Roaming\npm

cordova create hello com.example.hello "HelloWorld"
    $ cd hello
    $ cordova platform add android
    $ cordova build

still need to download cordova library for www & android. may be for first time use

open eclipse
"import existing Android code to workspace"

Clean project to remove errors and build and run. 



Wednesday, January 15, 2014

IronPython with C#

using python in c#
http://ironpython.codeplex.com/releases/view/28125
http://blogs.msdn.com/b/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx

started console project.
works!

Test.cs
namespace TestPython
{
    public class Test
    {
        int a = 10;
        public int A { get { return a; } }
        public void Method1()
        {
            Console.WriteLine(a);
        }
        public int Method2(int b)
        {
            return a + b;
        }
    }
}

Test.py
import sys
import clr

class MyPyClass:
  myvar = 123
  def _init_(self):
    print "constructor"
  def m1(self):
    print self.myvar

def Simple():
  print "Hello from Python"
  a = 3
  a = a *4
  print a

  # instantiate C# class
  clr.AddReference('TestPython') # can be replaced with "ipy.LoadAssembly(System.Reflection.Assembly.GetExecutingAssembly());" in C#, if necessary
  from TestPython import *
  b = Test();
  b.Method1();

Program.cs
namespace TestPython
{
    class Program
    {
        static void Main(string[] args)
        {
            var ipy = Python.CreateRuntime();
            dynamic test = ipy.UseFile("Test.py");
            test.Simple();

            // use python class in c#
            var instance = test.MyPyClass();
            instance.m1();
         
            Console.WriteLine("Bye");
            Console.ReadLine();
        }
    }
}

Safari browser: enable developer menu

to enable developer menu in safari
Safari > Preferences > Advanced > Show Developer menu


XNA: windows 8.1 tablet

developing xna on a windows 8.1
1) install visual c# 2010 express
2) install Games for Windows Marketplace Client
3) install xna 4

on intel gma chips
new project
when running, may get error that graphic card cannot run xna framework hidef profile

ran into some issues with programming xna in windows 8.1 tablet.

need to use reach profile instead of hidef
windows 8.1 tablet
texture maximum 2048 px


Wednesday, July 24, 2013

Android: downloading text data from network url

reference: http://developer.android.com/training/basics/network-ops/connecting.html

1) create method to download string from url

String downloadURL(String strurl) throws IOException{
InputStream is = null;
   // Only display the first 500 characters of the retrieved
   // web page content.
   int len = 500;
   
   try{
    URL url = new URL(strurl);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setReadTimeout(10000); // 10 sec
    conn.setConnectTimeout(15000); // 15 sec
    conn.setRequestMethod("GET");
    conn.setDoInput(true); // allows receiving data.
    // starts query
    conn.connect();
    int response = conn.getResponseCode();
    Log.d("connection", "response is " + response);
    is = conn.getInputStream();
   
    InputStreamReader reader = new InputStreamReader(is);
   
    char[] buff = new char[len];
    reader.read(buff);
   
    String result =  new String(buff);
    Log.d("connection", "message is " + result);
    return result;
   }
   finally{
    if(is!=null){
    is.close();
    }
   }
}

2) create class to handle download in background process
// class to handle download
// http://developer.android.com/reference/android/os/AsyncTask.html
// < Params, Progress, Result>
// Params - the type of the parameters sent to the task upon execution.
// Progress - the type of the progress units published during the background computation.
// Result - the type of the result of the background computation.
// so in this case, String is the data type of parameter sent to task, void for type of progress units, string for data type of result
class MyTask extends AsyncTask<String, Void, String>{

@Override
  // "String..." = optional parameter. can be nullable 
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
try{
return downloadURL(params[0]);
}
catch (Exception ex){
Log.d("download", "Error is " + ex.getMessage());
}
return null;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Log.d("post-execute", result);
et2.setText(result); // display in EditText
}
}

3) Get connection state and execute the background process

// need to have android.permission.ACCESS_NETWORK_STATE
ConnectivityManager mgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = mgr.getActiveNetworkInfo();
if(netInfo != null && netInfo.isConnected()){
new MyTask().execute(url);
}

Monday, July 22, 2013

Android: video playback

summary:
  1. Add VideoView into the xml layout
  2. copy video into "res/raw" folder
  3. import android.widget.VideoView
  4. VideoView videoView;
  5. videoView = (VideoView)this.findViewById(R.id.videoView1);
  6. String path = "android.resource://" + this.getPackageName() + "/" + R.raw.render; // assume that the video is render.mp4
    • alternatively: can use - String path = "android.resource://" + this.getPackageName() + "/raw/render"; // assume video is render.mp4
    • can use http url to a video file online. but must add uses permission to Internet in Manifest.xml - <uses-permission android:name="android.permission.INTERNET"/>
  7. videoView.setVideoPath(path );
  8. videoView.start();

Sunday, July 21, 2013

Android: music play back

Summary:
  1. Copy the music file, eg: MP3, into the res\raw folder. if raw folder does not exist, create it. 
  2. Check R.*.java. a new id should be created. eg.: R.raw.music.
  3. import android.media.MediaPlayer;
  4. MediaPlayer player
  5. player = MediaPlayer.create(this.getApplicationContext(), R.raw.music);
  6. player.start();
  7. player.pause(); 
  8. player.seekTo(0); // seek to 0 millisec 
Alternatively, use SoundPool to manage a list of sound (eg.: sound effects for a game level): http://developer.android.com/reference/android/media/SoundPool.html
  1. import android.media.*
  2. SoundPool sndPool;
  3. sndPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); // max streams: 10; sample-rate converter quality. Currently has no effect. Use 0 for the default.
  4. int button01 = sndPool.load(this.getApplicationContext(), R.raw.button01, 1); // etc. can load more; priority of the sound. Currently has no effect. Use a value of 1 for future compatibility.
  5. (Activity) : this.setVolumeControlStream(AudioManager.STREAM_MUSIC); // to set Activity sound be controlled by hardware volume keys
  6. when it's time to play, sndPool.play(button01, 1, 1, 0, 0, 1);
    • left & right volume: 0 to 1.0
    • priority: 0 lowest
    • no loop: 0; -1 loop forever
    • play rate: 1.0

Thursday, July 18, 2013

Android: Timer thread

  1. import java.util.*;
  2. Timer timer = new Timer();
  3. create subclass of TimerTask, eg.: class MyTask extends TimerTask { ... }
  4. add "public void run()" method in subclass
  5. timer.schedule(new MyTask(), 0, 30); // assume no delay and 30 millisec interval 
  6. timer.cancel(); // for cleanup. to start timer again, need to instantiate:  new Timer(); then schedule(...)
  7. if using "protected void onPause()" or onResume(), ensure that super.onPause(), etc is called. 
  8. if need to refresh View UI, then use postInvalidate() instead of invalidate(). else will have exception
Activity life cycle (to understand when to stop Timer to prevent waste of resources):


Android: View + touch listener

  1. implements View.OnTouchListener
  2. add public boolean onTouch(View v, MotionEvent event) method
  3. view.setOnTouchListener(this);
  4. event.getX() or getY() to get position of touch
sample code:
public class SecondActivity extends Activity implements View.OnTouchListener{
MyCanvas c;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
c = (MyCanvas)this.findViewById(R.id.myCanvas1);
tv = (TextView)this.findViewById(R.id.textView1);
c.setOnTouchListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
public boolean onTouch(View v, MotionEvent event){
if(v ==c ){
tv.setText("touched: " + event.getX() + ", " + event.getY());
}
return false;
}
}

Wednesday, July 17, 2013

Android: custom View with draw + xml layout

create custom View class:
public class MyCanvas extends View {
int x = 0;
public MyCanvas(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

Paint paint = new Paint();
Rect rect = new Rect();
protected void onDraw(Canvas canvas){
paint.setColor(0xFF999999);
rect.set(x, 100, 200, 150);
canvas.drawRect(rect, paint);
}
public void move(){
x+=5;
this.invalidate(); // redraw
}
}

xml layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" android:id="@+id/layout1">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="21dp"
        android:text="Button" />

    <com.boon.MyCanvas
        android:id="@+id/myCanvas1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button1"
        android:background="#CCCCCC" />

</RelativeLayout>

MainActivity.java: 
public class MainActivity extends Activity implements View.OnClickListener{
Button b;
MyCanvas c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b = (Button)this.findViewById(R.id.button1);
b.setOnClickListener(this);
c = (MyCanvas) this.findViewById(R.id.myCanvas1);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
c.move();
}

}

Wednesday, July 10, 2013

Android: Accelerometer + Gyroscope

summary:
  1. import android.hardware.*;
  2. SensorManager mSensorManager;
  3. Sensor accSensor, gyroSensor;
  4. mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
  5. accSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
  6. gyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
  7. implements SensorEventListener 
  8. public void onSensorChanged(SensorEvent event) { ... }
  9. mSensorManager.registerListener(this, accSensor, SensorManager.SENSOR_DELAY_UI);
  10. mSensorManager.registerListener(this, gyroSensor, SensorManager.SENSOR_DELAY_UI);
  11. get the x, y, z values using event.values[0], [1], [2] in the onSensorChanged method
  12. mSensorManager.unregisterListener(this, accSensor);
  13. mSensorManager.unregisterListener(this, gyroSensor);




Wednesday, April 24, 2013

Kinect + Java + Eclipse

Steps:

  1. Download SimpleOpenNI from https://code.google.com/p/simple-openni/
  2. Extract the zip file. 
  3. In the "OpenNI_NITE_Installer-win32-0.27" folder, install openni "openni-win32-1.5.4.0-dev.msi"
  4. install NITE "nite-win32-1.5.2.21-dev.msi"
  5. download latest kinect primesense driver from https://github.com/avin2/SensorKinect/tree/unstable/Bin
  6. install driver
  7. Connect Kinect camera.
  8. if Kinect SDK driver installed, go to Device Manager and "update driver" for Kinect Camera to Primesense driver. right click on device > Properties > Update Driver Software...> Browse my computer > "Let me pick ... " > "Kinect Camera Version: ...." (unsigned)
  9. Create new Eclipse java project
  10. Add sample source into project. eg.: "OpenNI\Samples\SimpleRead.java"
  11. Add "{installation path}\OpenNI\Bin\org.OpenNI.jar" into eclipse project library build path. Project > Properties > Java Build Path > Add external JAR... > "org.OpenNI.jar". Native library location: "{installation path}\OpenNI\Bin"
  12.  run java app. 

Wednesday, March 27, 2013

Adobe Edge Animate


Stage properties: Title, Composition ID (useful to refer to it using code from outside javascript). eg.: AdobeEdge.getComposition("EDGE-9496421")

Elements and Library panel. 
Elements: HTML elements in the symbol. mainly using jQuery $(...). eg.: sym.getSymbol("rect1").$("RoundRect")
Library: shows the symbols. DO NOT confuse the symbol ID with instance ID below. similar concept with Flash. but strangely the API uses getSymbol() instead of getInstance()

Instance properties: ID. useful for referring to instances in javascript. eg.: sym.getSymbol("rect1")...

Timeline: can add Label like Frame label in flash. for use in javascript: eg.: sym.play("over")

sample code: 

var count = 0; // my own variable
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes

   //Edge symbol: 'stage'
   (function(symbolName) {
   
      Symbol.bindElementAction(compId, symbolName, "${_rect1}", "mouseenter", function(sym, e) {
         // insert code to be run when the mouse enters an element
         sym.getSymbol("rect1").play();
      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_rect1}", "mouseleave", function(sym, e) {
         // insert code to be run when the mouse leaves an element
         sym.getSymbol("rect1").playReverse();
      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_rect1}", "click", function(sym, e) {
         // insert code for mouse click here
         //console.log(sym);
         e.preventDefault();

         // using jquery text() function
         sym.getSymbol("text1").$("Text").text("button clicked: " + (count++));

      });
      //Edge binding end

   })("stage");
   //Edge symbol end:'stage'


})(jQuery, AdobeEdge, "EDGE-9496421");

// my own code
var id = setTimeout(myfn, 1000);
function myfn(){
//console.log("time out");
// run some code in Edge
var comp = AdobeEdge.getComposition("EDGE-9496421");
//console.log("EDGE composition: " + comp);
console.log("stage: " + comp.getStage());

var mytext = comp.getStage().getSymbol("text1").$("Text");

 // using jquery offset() function
var x = mytext.offset().left + 1;
//console.log(x);
mytext.offset({left: x});

id = setTimeout(myfn, 1000);
}

Thursday, March 14, 2013

Unity: instantiating GameObjects at runtime

Use Prefabs!
Assets > Create > Prefab
Drag the model, material, etc into the new prefab

in the JS script, declare a variable. eg.: var bullet:GameObject;
Assuming that this JS script is added to a GameObject, you can drag a prefab from Project View to the variable in the Inspector view.

instantiate using code: eg.:
var bulletClone = Instantiate(bullet, Vector3(Input.mousePosition.x, Input.mousePosition.y, 1.0), Quaternion.identity);


Wednesday, March 13, 2013

Unity: XML parsing


import System.Xml;
import System.IO;

var filename = "Assets/sample.xml";
function Start () {
print("processing xml");
var reader:XmlTextReader = new XmlTextReader(filename);
print (reader);

while (reader.Read()) {
       switch (reader.NodeType) {
         case XmlNodeType.Element:
           print("element: " + reader.Name); // print the name
           print("attribute: " + reader.GetAttribute("name"));
           break;
         case XmlNodeType.Text: // for text node
          print(reader.Value); // read the content of the text
          break;
       }
    }
}


Note: to parse float or int from String, use float.Parse(string), or int.Parse(...) etc