Announcement

Collapse
No announcement yet.

SD Config Files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SD Config Files

    I need to be able to store a number (up to 5 digits) which can be recalled at power-up.
    Saving to SD seems to be an option, but I’m not having any luck implementing this. If someone could look at my code to see where I’m going wrong it would be greatly appreciated. The end result is “FFFF” is printed.

    Screen: uLCD-35DT
    PmmC: 1.2
    uSD Card: Supplied by 4D Systems
    ------------------------------------------------------------------
    var ConfigFile;
    var oldNum;

    func oldNumSD()

    if(file_Exists("default.cfg"))
    ConfigFile := file_Erase("default.cfg");
    endif

    if(!file_Exists("default.cfg"))
    ConfigFile := file_Open("default.cfg", 'w');
    oldNum := 100;
    file_PutW(oldNum, ConfigFile);
    file_Close(ConfigFile);
    endif

    oldNum := -1;

    ConfigFile := file_Open("default.cfg", 'r');
    count := file_GetW(ConfigFile);
    file_Close(ConfigFile);

    print( [HEX4] oldNum, "\n"); // Prints "FFFF"

    endfunc
    ------------------------------------------------------------------
    Thanks in advance - Dave

  • #2
    I’ve sorted it…... if I swap out the rouge var “count” (blasted copy & paste) with “oldNum” and use print(oldNum) instead of print( [HEX4] oldNum), it works.

    Sometimes we’re too busy looking for big errors to see the little ones.

    Cheers - Dave
    Last edited by DaveR; 13 June 2014, 12:03 AM.

    Comment

    Working...
    X