Negative values returned from file in NXC

后端 未结 1 363
無奈伤痛
無奈伤痛 2021-01-27 13:55

I am saving values to a .csv file in NXC(Not eXactly C) and then calling on them ata later point in time. The problem I am having is when calling any negative values back from a

相关标签:
1条回答
  • 2021-01-27 14:19

    StrToNum should convert negativ numbers. Its a bit strange that an integer number starts with 0. You should also use Enhanced NBC/NXC firmware.

    First: You should always clear the screen before writing some output! Use:

    NumOut(0,LCD_LINE1,lstFwd, DRAW_OPT_CLEAR_LINE);
    

    If the problem still exists try:

    string val;
    OpenFileRead("map.csv", fSize, count);
      until (eof == true) {
        ReadLnString(count, val);
        int lstFwd = StrToNum(val);
        if(SubStr(val, 0, 1) == "-") lstFwd *= -1; // Check if first char is "-"
        NumOut(0,LCD_LINE1,lstFwd, DRAW_OPT_CLEAR_LINE);
      }
    while(true);
    
    0 讨论(0)
提交回复
热议问题