Update a variable

Discussion in 'Jiggy Runtime Development' started by diff_one, Jun 21, 2008.

  1. diff_one

    diff_one New Member

    Joined:
    Jun 11, 2008
    Messages:
    2
    Likes Received:
    0
    Device:
    iPod touch
    Hello guys....

    I am creating a program for math.
    I took as a "basis" the program Score Keeper.app by The Ax.

    I can' t update the value of variables when I insert new values in the UIPreferencesControlTableCell.

    For Example: in the first one (title:"Grado dell' Equazione") how can I update the value in the variable "dani"?

    Thank you and....Sorry for my english

    Please Register or Log in to view images



    Code:
    Plugins.load( "UIKit" );
    
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
    
    var mainView = new UIView();
    mainView.setCanHandleSwipes(true);
    window.setContentView( mainView );
    
    
    
    
    //----------------------------CARICAMENTO BARRA DI BENVENUTO-------------------------------
    onLoad = function()
    {
      menu.popupAlertAnimated( true );
    }
    Application.setStatusBarMode( 1 , 0 , 0 , 0); 
    Application.setStatusBarCustomText( "Air Texting" ) 
    Application.setApplicationBadge( "NEW!" ) 
    
    //---------------------------------BARRA DI BENVENUTO--------------------------------------
    var menu = new UIAlertSheet("Donate", "OK");
    menu.setTitle("Benvenuto") 
    menu.setAlertSheetStyle(2) 
    menu.setBodyText("Benvenuto nel programma di integrazione numerica con il metodo dei rettangoli");
    menu.setDimsBackground(true) 
    menu.onButtonClicked = function(button){
    if (button == 1)
    menu.dismiss(true);
    }
    
    ///***************************************************************************PreferencesTable
    
    // Create the preferences table
    
    var ptable = new UIPreferencesTable( [ + 0 , 48 , window.bounds[ 2 ] -0 , 362]  );
    
    // Return the number of groups that will be in the table
    
    ptable.onGetNumberOfGroups = function( tbl )
    {
      return 3;
    }
    
    // Return the number of rows in each group
    
    ptable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 15;
        case 1 : return 3;
        case 2 : return 1;
      }
    }
    
    // Tell the table that the third group is a label group
    
    ptable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
        case 1 : return false;
        case 2 : return true;
      }
    }
    
    // Now, create the title cells - we only need 2 because the third
    // group is a label
    
    var titleCells = [];
    
    var titleCell;
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Dati";
    
    titleCells.push( titleCell );
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Risultati";
    
    titleCells.push( titleCell );
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "bla bla";
    titleCells.push( titleCell );
    
    // Add the event handler to return the title cells
    
    ptable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCells[ group ];
      else
        return null;
    };
    
    // Return row heights
    
    ptable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        // This is the height for title groups
    
        return 50;
      }
    
      if ( group == 0 && row == 2 )
      {
        // We'll make this one taller
    
        return 50;
      }
    
    // Return row widths
    
    ptable.onGetWidthForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        // This is the height for title groups
    
        return 100;
      }
    
      if ( group == 0 && row == 2 )
      {
        // We'll make this one taller
    
        return 50;
      }
    }
    
      // Otherwise, we return the height it wants
    
      return proposedHeight;
    };
    
    // Now we have to create the real cells
    
    // We create an array of groups - and each group
    // is an array of cells.
    
    var cells = [ [] , [] , [] ];
    
    var cell;
    var control;
    
    // group 0 , cell 0
    
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Grado dell' Equazione";
    cell.setEnabled( true );
    cell.value = 5;
    var dani = parseInt(cell.value);
    //cell.showSelection = true; 
    cell.preferredKeyboardType = 7;
    cells[0].push( cell );
    
    
    log("dani:"+dani);
    
    // group 0 , cell 1
    
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Intervallo di Integrazione sx ";
    cell.setEnabled( true );
    cell.value = "";
    var isx= cell.value;
    //cell.showSelection = true; 
    cells[0].push( cell );
    
    
    // group 0 , cell 2
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Intervallo di Integrazione dx";
    cell.setEnabled( true );
    cell.value = "";
    var idx=cell.value;
    //cell.showSelection = true; 
    cells[0].push( cell );
    
    // group 0 , cell 3
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Numero di divisioni";
    cell.setEnabled( true );
    cell.value = "";
    //cell.showSelection = true; 
    cells[0].push( cell );
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 10";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani == 10){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 9";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 9){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 8";
    cell.setEnabled( false );
    cell.value = "",
    cell.showSelection = false; 
    if (dani >= 8){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 7";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 7){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 6";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 6){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 5";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 5 ){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 4";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 4 ){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 3";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 3){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 2";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 2){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Coeff di Grado 1";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani >= 1){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Termine Noto";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = false; 
    if (dani > 0){
    cell.setEnabled( true )
    }
    cells[0].push( cell );
    
    
    
    // group 1 , cell 2
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Integrale per eccesso";
    cell.setEnabled( false );
    cell.value = isx;
    cell.showSelection = false;
    
    cells[ 1 ].push( cell );
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Integrale per difetto";
    cell.setEnabled( false );
    cell.value = idx;
    cell.showSelection = false;
    
    cells[ 1 ].push( cell );
    
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Errore";
    cell.setEnabled( false );
    cell.value = "";
    cell.showSelection = true;
    
    cells[ 1 ].push( cell );
    // group 2 , cell 0
    
    cell = new UIPreferencesTableCell();
    cell.title = "";
    cells[ 2 ].push( cell );
    
    // Attach the event handler to dole out the cells
    
    ptable.onGetCell = 
      function( tbl , group , row )
      {
        return cells[ group ][ row ];
      };
    // And LOAD the table!
    
    ptable.reloadData();
    
    mainView.addSubview( ptable );
    
    
    //--------------------------------BARRA DI NAVIGAZIONE IN ALTO-------------------------------------
    var bar = new UINavigationBar( [ 0 , 0 , window.bounds[ 2 ] , 48] );
    bar.showButtonsWithStyle("Registra" , 1 , "Calcola" , 0)
    bar.setBarStyle(1) 
    mainView.addSubview( bar );
    var itemOne = new UINavigationItem( "Integrazione Numerica" );
    bar.pushNavigationItem( itemOne );
    
    
    //------------------------------BARRA DI NAVIGAZIONE IN BASSO----------------------------------------
    // You have to define all the possible buttons for the bar in an array like this
    
    var buttons = 
    [
     ];
    
    var bb = new UIButtonBar( mainView , [ -10 , 410 , 330 , 50 ] , buttons );
    bb.barStyle = 1;
    
  2. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    Dude im confused?

    I saw air texting and stopped reading.
    Trying to finish my creation?

    also can you please send me a link to the application I dont know where I put it
  3. diff_one

    diff_one New Member

    Joined:
    Jun 11, 2008
    Messages:
    2
    Likes Received:
    0
    Device:
    iPod touch
    Yes I modify your program but for make different operations...

    The problem is at the line 163....I assign at var "dani" the value insert into the first UIPreferencesTextTableCell but, when I change the value (when the program run) the value insered in "dani" don't change...

    I hope to have been clear, but I don't think so

    Please Register or Log in to view images



    I have enclosed the program..
    ...thank you

    Attached Files:

Share This Page