[How To] Load a text file into a text box.

Discussion in 'Jiggy Runtime Development' started by Ryan, Jun 23, 2008.

  1. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    Hey, just to help anyone who needs it. I know what it was like when i was making my app and found something hard and found no help anyware. So here is a quick, basic tutorial to load a text file into a text box for all the people starting with jiggy.


    First make a variable that is a textbox.

    Code:
    var atextbox = new UITextView( [ 20 , 100 , 320 , 250 ] );
    
    This makes a text box and assigns it to the word atextbox. From now on, if you want to use a this textbox you just have to use the word atextbox.

    Next you want to make load your data.

    Code:
    var daata = new Data();
    This means that the variable called daata will make new data.

    Now we want to make it so that this data is the content of the text file.

    Code:
    //load the data, from the file, in your app location. in folder text and file name of textfile.txt
      daata.loadFromFile(Bundle.pathForResource("/Text/textfile.txt"));
    //move from the currentView, to the text box
      mainView.transitionFrom( 1, currentView , atextbox );
    //the text in the text box is equal to the variable called daata, as a string.
      atextbox.text = daata.asString();
    //This makes the data uneditable, to change this make it true (See below)
      atextbox.editable = false;
    //Add the textbox into the current view
      atextbox.addSubview();
      }
    
    So there you go.

    If you need the text file to be editable, then use this code instead.

    make a variable called keyboard

    Code:
    var keyboard = new UIKeyboard();
    
    Code:
      daata.loadFromFile(Bundle.pathForResource("/Text/textfile.txt"));
      mainView.transitionFrom( 1, currentView , atextbox );
      atextbox.text = daata.asString();
      atextbox.editable = true;
      atextbox.addSubview();
    
    keyboard.preferredKeyboardType = 0;
    keyboard.setDefaultReturnKeyType( 0 );
    keyboard.showPreferredLayout();
    keyboard.activate();
    window.addSubview( keyboard );
    
    This brings up a text box with your text file contence in it, plus it allows it to be edited using the keyboard.


    Hope this helped anyone who needed help.


    Next tutorial: Saving your edited text files.
  2. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    Lol don't you think this is kinda useless? Seeing as in like 2 weeks Jiggy and Toolchain Objective C will be dead...
  3. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    yup. But why not help others who need it now?
  4. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    Well anyone still making apps in Jiggy, and planning on a release, is kinda loopy.
  5. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    yeah true but still, its not hurting anyone, and even after 2.0 comes out there still might be some who stick to 1.1.4 and lower just for the jailbreak and free apps.
  6. e.mann30

    e.mann30 New Member

    Joined:
    Nov 13, 2007
    Messages:
    427
    Likes Received:
    8
    Nice tut. Keep them coming. Its always good to learn something. Jiggy will only be dead on the 2.0 platform , not the pre-2.0 ipod/iphones. Plus , people are learning a form of javascript language which can be useful if you are thinking about making web pages or whatever.
  7. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    thanks, and yeah, very true.
  8. Johnny Quest

    Johnny Quest Active Member

    Joined:
    Nov 23, 2007
    Messages:
    1,012
    Likes Received:
    12
    Device:
    iPhone 6
    question on thread #2,#4: what do you mean? couldn't people make apps on their ipot with jiggy? what would be the difference on creating apps? I'm curious. I'm working on an app on jiggy and I want to know if its a waste of time. How will this new thing coming out affect my ipot?
  9. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    here we go again

    Please Register or Log in to view images

    (this has come up alot)...
    Jiggy as it is will not run on Firmware 2.0, nor will any app for 1.1.4 and below.
    Therefore unless someone ports Jiggy to 2.0 our apps wont run on it. Im hopeing some kind smart person does it

    Please Register or Log in to view images

    .
    Personally I wouldnt be suprised if someone does, alot of people diss Jiggy but they just dont get it.
    For me Jiggy wont be dead for a while anyways coz Im not running to 2.0 straight away and have no real interest in app store (all the sorta apps I like arent allowed and I LOVE open source/freeware).
    And if no one does Im sure someone will make something else that makes codeing more acesable, theres other options (altho not quite so freindly) of codeing things for the iPhone and if even one of these get ported I might upgrade....has anyone ever played with that Python for the iPhone?
    Does suck tho, Jiggy really could die....someone be a hero.....SAVE JIGGY!!!!
  10. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    ^ yes, well sed lol

Share This Page