FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   casting textField data to ints
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: casting textField data to ints  (Read 970 times)
Sjeiti

WWW
casting textField data to ints
« on: Mar 23rd, 2005, 5:19pm »

hi...
 
I'm trying to use data from a textField in a calculation but I've got some problems casting Strings to ints.
I've had it working in p5_0068 using splitInts but in p5_0069 it doesn't work anymore (and splitInts suddenly is split?)
here's the Code:
Vector vInp;
 
void setup() {
  size(120,100);
  background(255);
   
  vInp = new Vector(0);
  String[][] lInp = new String[][] {{"width","800"},{"height","600"},{"iterations","1000000"},{"frames","16 "}};
  int iMrg = 20;
  int iWdt = 80;
  int iHgt = 20;
  for (int i=0;i<lInp.length;i++) {
    int iXps = width-iWdt-iMrg;
    int iYps = height-(lInp.length-1)*iHgt+iHgt*i-iMrg - 10;
    TextField oTxt = newTextField(iXps,iYps,iWdt,iHgt,lInp[i][1]);
    oTxt.setName(lInp[i][0]);
    vInp.add(oTxt);
  }
  setLayout(new BorderLayout());
}
 
void mousePressed() {
  String sAfn = ((TextField)vInp.elementAt(3)).getText();
  int iAfn = split(sAfn)[0];
  println(iAfn);
}
 
TextField newTextField(int x, int y, int w, int h, String s) {
  Panel oPnl = new Panel();
  oPnl.setLayout(new BorderLayout());
  add(oPnl);
  oPnl.setBounds(x,y,w,h);
  TextField oInp = new TextField(s);
  oPnl.add(oInp);
  return oInp;
}

thnkz...
 

http://www.sjeiti.com/
fry


WWW
Re: casting textField data to ints
« Reply #1 on: Mar 23rd, 2005, 8:23pm »

on Mar 23rd, 2005, 5:19pm, Sjeiti wrote:
hi...
 
I'm trying to use data from a textField in a calculation but I've got some problems casting Strings to ints.
I've had it working in p5_0068 using splitInts but in p5_0069 it doesn't work anymore (and splitInts suddenly is split)

revisions.txt describes the change:
 
- splitStrings() becomes just split().. splitInts() goes away.  
  splitInts becomes -> toInt(split(someString, ','));
 
more info in there on how split et al work.
 
rhellyer


Re: casting textField data to ints
« Reply #2 on: Mar 29th, 2005, 6:54am »

what's the best way to read the revisions.txt file ... on  win xp it comes out without any line breaks for some reason.
 
r
 
Pages: 1 

« Previous topic | Next topic »