Post Reply 
Little explorations with HP calculators (no Prime)
06-15-2017, 01:09 PM (This post was last modified: 06-15-2017 01:30 PM by pier4r.)
Post: #224
RE: Little explorations with the HP calculators
I would like to share a simple program for backup up a directory from home to the SD card.

The examples that I found on this site (search string site:hpmuseum.org sd backup) use heavily the stack - while I like named variables, especially for things that do not have to be fast - and do not use the sdlib included with the sdfiler.

Since I would have liked to see an example with a different layout and I did not find it, I share mine to raise the chances that a reader, for example me in the future, can have another idea.

The program is far from being general, it is just an example how a backup program can be done.

Code:

backupToSd
  @it requires the sdfiler/sdlib library 
  \<<
    "LIFEGDIR" "fileStrDos" DROP
    "" "dateStr" DROP
    "" "timeStr" DROP
    "" "sdDirStr" DROP
    
    \->
    @input 
    
    @local var
    fileStr
    dateStr
    timeStr
    sdDirStr
    \<<
      -42 SF
        @date dd.mm.yyyy
        @time does not need the flag -41
    
      DATE \->STR "." "" SREPL 
      DROP @we don't want to know the number of replacements
      'dateStr' STO
      
      @Now we need to "roll" the data instead of 15062017 we want
      @20170615 further we need to know that we dates with trailing
      @zeroes the tailing zero is lost
      IF
        dateStr SIZE 8 \=/
      THEN
        'dateStr' 0 STO+
      END
      
      dateStr 5 8 SUB @year
      dateStr 3 4 SUB + @month
      dateStr 1 2 SUB + @day
      'dateStr' STO
      
      TIME \->STR "." "" SREPL DROP
      'timeStr' STO
      
      timeStr 1 2 SUB @hours
      timeStr 3 4 SUB @min
      timeStr 5 6 SUB @seconds
      + + @concatenate
      'timeStr' STO
      
      @'fileStr' dateStr STO+
        @we cannot make this now, it cannot be done by the RPL filer
      
      {HOME LIFEG} RCL      
        @put the object in memory 
        @(problem, when the memory does not have enough space to duplicate an object on the stack)
      
      fileStr
      3 \->TAG
      STO @stores it on the sd  
      
      @rename the file on the SD using the library
      fileStr
      'fileStr' dateStr STO+
      'fileStr' timeStr STO+
         @longfilename with all those info
      fileStr
      SDMOVE
      
      @now moving it in the right directory on the sd
      "LIFEGDATABACKUP/B" dateStr + 'sdDirStr' STO
      @sdDirStr SDMKDIR
        @I need to handle the message, luckly the sdlib has also commands that
        @are less strict
      sdDirStr XMKDIR DROP
        @creates the folder, if already existing, it does not fail.
        @this is valid for multiple backups in a day
      
      fileStr
      sdDirStr "/" + fileStr +
      SDMOVE
    \>>
  \>>


Other useful topics that I found (but based heavily on stack operations):
- http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=126574
- http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=112771

(maybe the comp.sys.hp48 is a better archive for RPL questions , especially reading messages from 2010 or before, sometimes people address that newsgroup . Searching for sd backup)
- ok maybe this program http://page.mi.fu-berlin.de/raut/WR49/Filer6.htm from this page http://page.mi.fu-berlin.de/raut/WR49/index.htm#General may help
- https://groups.google.com/forum/#!search...7AI-5vHWQJ this is the discussion about the sdfiler from TW and Claudio L. themselves.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Little explorations with the HP calculators - pier4r - 06-15-2017 01:09 PM



User(s) browsing this thread: 2 Guest(s)