Author Topic: How do I set a variable to the text in a text box.  (Read 714 times)

Sai I have a gui window with a text box and a send button. [and a cancel button and a text contol]

Code:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new GuiControl(send) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 2";
   visible = "1";

   new GuiWindowCtrl() {
      profile = "GuiWindowProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "171 228";
      extent = "170 145";
      minExtent = "8 2";
      visible = "1";
      maxLength = "255";
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "1";
      minSize = "50 50";

      new GuiBitmapButtonCtrl() {
         profile = "GuiDefaultProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "18 101";
         extent = "68 30";
         minExtent = "8 2";
         visible = "1";
         text = "      Send";
         groupNum = "-1";
         buttonType = "PushButton";
         bitmap = "base/client/ui/button1";
         lockAspectRatio = "0";
         alignLeft = "0";
         overflowImage = "0";
         mKeepCached = "0";
         mColor = "255 255 255 255";
      };
      new GuiBitmapButtonCtrl() {
         profile = "GuiDefaultProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "92 101";
         extent = "68 30";
         minExtent = "8 2";
         visible = "1";
         text = "      Cancel";
         groupNum = "-1";
         buttonType = "PushButton";
         bitmap = "base/client/ui/button1";
         lockAspectRatio = "0";
         alignLeft = "0";
         overflowImage = "0";
         mKeepCached = "0";
         mColor = "255 255 255 255";
      };
      new GuiTextEditCtrl() {
         profile = "GuiTextEditProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "23 73";
         extent = "126 18";
         minExtent = "8 2";
         visible = "1";
         text = "Fill me please!";
         maxLength = "255";
         historySize = "0";
         password = "0";
         tabComplete = "0";
         sinkAllKeyEvents = "0";
      };
      new GuiTextCtrl() {
         profile = "GuiTextProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "23 49";
         extent = "50 18";
         minExtent = "8 2";
         visible = "1";
         text = "Command:";
         maxLength = "255";
      };
   };
};
//--- OBJECT WRITE END ---



I want to make it [lets sai for now] echo whats in the text box when iou [u,] press the send button.
How would I do this.


I can make stuff happen when I click a button.
I don't need ani help on that part.
I just need to know how to put what's in the text box into a var.

I can make stuff happen when I click a button.
I don't need ani help on that part.
I just need to know how to put what's in the text box into a var.

Also, how do I save to a file.
Like.


$bob = "Hello.";


How do I make a text document [example --- 'joe.txt' ] with $bob in it?

$variable = TextBoxName.getvalue();

Something like that.


To communicate with files you use fileObjects.

Define a new fileObject like this.
Code: [Select]
new fileObject(myFileObject);
Then you can apply several different methods to communicate with files.
Path is the path from the base Blockland folder to your file.  Add-Ons/myFile.txt is an example.  We can also work with files inside .zip's, so you can use Add-Ons/Weapon_Sword/server.cs too.

Code: [Select]
myFileObject.openForRead(path);This opens a file for read.

Code: [Select]
myFileObject.openForAppend(path);This opens a file and adds to the end of it.

Code: [Select]
myFileObject.openForWrite(path);This writes to the file.  Rather than opening it and adding to the end, it actually clears the file and starts it off blank.

Now we can read/write from the file.

Code: [Select]
myFileObject.readLine();This reads the next line and returns it.  It's best to specify a variable if you want to know what it is.  For use when you opened a file for reading.

Code: [Select]
myFileObject.writeLine(text);This writes the next line and returns it.  Text is the text you write to it.  For use when you opened a file for writing/appending.

Thank iou [u,] both veri much!