Why will this not properly read a file.

edited November 2014 in Using Processing

Despite the content of the file, all of the global variables are set to zero after running this code int setup. This is the code that reads from the file.

  //Load Keybinds//
  loadkeybinds = loadTable("data/files/keybinds.conf", "header, csv");

  for (TableRow row : loadkeybinds.rows ()) {

    aspectratio = row.getFloat("aspectratio");
    resolutionx = row.getInt("resolutionx");
    resolutiony = row.getInt("resolutiony");
    loadup = row.getInt("key1");
    loaddown = row.getInt("key2");
    loadleft = row.getInt("key3");
    loadright = row.getInt("key4");
    loadhurt = row.getInt("key5");
    loadinventory = row.getInt("key6");
    loadmenu = row.getInt("key7");
    loadblock = row.getInt("key8");
  }
Tagged:

Answers

  • edited November 2014

    Looks like you are loading all the rows into the same variables again and again. You will end up with the values from the last row.

    Would be useful to see the file, a few lines at least.

  • edited November 2014

    the file:

    aspectratio,resolutionx,resolutiony,key1,key2,key3,key4,key5,key6,key7,key8 4.9,640,480,119,115,97,100,113,101,109,114

  • This method has always worked for me in the past, only recently has it changed, comparing code to a previous version led me to no differences at all

  • edited November 2014

    @spamynator_1, I guess you didn't get what @koogs meant! L-)
    As we all know, variables can only hold 1 single value at a single time.
    For each for () iteration, which is the # of rows from loadkeybinds, you're reassigning all those columns to the same variables over & over.
    In the end, only the last TableRow's columns gonna stick in those 11 variables. The rest forgotten! [-(

  • Note that loadTable() will load files from the data folder already, so data/something is redundant, just use something.

Sign In or Register to comment.