Post Reply 
Hp 50g, SDLIB, SDFiler and moving HPDIR on the SD
09-04-2017, 07:43 PM (This post was last modified: 09-04-2017 07:43 PM by pier4r.)
Post: #1
Hp 50g, SDLIB, SDFiler and moving HPDIR on the SD
I am doing data collection with the 50g since almost 90 days now. I am slowly realizing a project I always want to do but being too lazy to implement it until David started his ListExt library that convinced me to use the 50g plus lists to collect data. The final idea is in the same category of the one exposed in this article. I hope I'll write a topic about it.

Anyway for the moment I just collect data. The process is enough to expand my knowledge of the hp 50g, its built in functions, third party programs and possible limits.

For example I employ shortcuts that I read in a post in this General forum (surely they were known before, but the earliest record in my mind is a forum post in this new forum): "right shift + var_name on the soft menu" to recall the content of a variable, modify those, "left shift + var_name on the soft menu" to store the modified content back in the variable.

Of course, since there is little input check, I may, by mistake, save the content of a variable in another. Therefore I do a daily backup (plus recall of the backup, one has to check if the backups are all fine!).

I tried a backup program employing SDLIB, but while saving the HPDIR works, moving the file on the SD or recalling it sometimes hangs the calculator. I'll have to check if I can fix it with multiple calls to Xreset.

The workaround so far is to use a program to store the HPDIR with built-in calculator commands. The following is the current version of this program:

Code:

\<<
    @in input one puts a string with the time like "201708201116"
    @then the STO command is going to save the LIFEG directory
    @ (one executes the program within the directory)
    @with the name LGB201708201116
    @but while STO puts the entire name, only the first 8(?) letters
    @are important for it. So often there is a conflict with
    @existing files
    @and we need a workaround.
    
    "" "filenameStr" DROP
    
    \->
    @input
    inputStr
    @local var
    filenameStr
    
    \<<
      @check input
      IF
        inputStr TYPE 2 \=/
      THEN
        "argument as string please"
        DOERR
      END
      
      @save all the variables for later comparisons with the backup
      {HOME LIFEG} EVAL
        @move in the directory
        
      @clean up 'allvars' from the existing list
      @it is needed a "delete" command actually from a list, so it can be safer
      IFERR
        'allListVars' PURGE
      THEN
        "var likely does not exist" DROP
          
        @drop the commands if last argument is enabled.
        IF
          -55 FC?
        THEN
          DROP
        END
      END
        
      5 TVARS  @collect all the lists
      'allListVars' STO
        @global var
        
      
      
      
      inputStr
      @generate a random number with 4 digits
      10000 RAND * IP
      DUP 
      9000 <
        @returns 0 or 1
      1000 * +
        @add 1000 to the number only if that is lower than 9000
      R\->I
        @no trailing points
      \->STR  
      "LGB" + 
        @we have nnnnLGB
        @that can be cleaned later.
      SWAP + 
      @3. \->TAG 
      'filenameStr' STO
        @lesson learned, it seems that tags are not saved in variables
      
      UPDIR 'LIFEG' RCL 
      filenameStr 
      3. \->TAG 
      STO
      
      filenameStr 
      3. \->TAG 
      RCL 
        @check the result after storing.
    \>>
  \>>

This works very well so far, and generates a file called:
<4randomDigits>LGB2017MMDDHHMM
on the main root of the SD.

Then with SDfiler I first rename the saved file, getting only "LGB2017MMDDHHMM" then I move (or copy when I want to feel safe) it in a directory called LIFEGBACKUP .

Since a couple of days, though, the HPDIR object resulting by the move or copy of the original file is a file that is readable but has less data.

What I mean is, for example, the original HPDIR saved on the SD has a list holding days from mid June to September (this list is still there if I recall the object on the stack). The copied/moved HPDIR has days until the early August, when I recall it on the stack. So it is like the object is trucated.
Therefore I may do backups but the actual data is lost.

Does anyone know why or know a workaround?
Another side problem is that the SDfiler not always shows all the files/subfolders in a folder if those are many (say: 40+). Sometimes I have to open the folder a couple of times to see all content.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
09-04-2017, 09:30 PM
Post: #2
RE: Hp 50g, SDLIB, SDFiler and moving HPDIR on the SD
(09-04-2017 07:43 PM)pier4r Wrote:  For example I employ shortcuts that I read in a post in this General forum (surely they were known before, but the earliest record in my mind is a forum post in this new forum): "right shift + var_name on the soft menu" to recall the content of a variable, modify those, "left shift + var_name on the soft menu" to store the modified content back in the variable.

Of course, since there is little input check, I may, by mistake, save the content of a variable in another.

Just in case you didn't know, there is also a keyboard trick for that situation too. Every time you press left shift + var_name to overwrite a variable with new contents, its PREVIOUS contents get automatically moved into LASTARG, along with its name. This makes recovery from accidental storing easy: just hit LASTARG (which is left shift + Enter). If you then hit STO, LASTARG, DROP, you'll be right back where you were before the accidental overwrite. Full recovery without using a backup!

Warning: LASTARG is very volatile. Almost every operation changes it. So the above recovery trick only works if performed IMMEDIATELY after the accidental overwrite, before you do anything that changes the contents of LASTARG.

The same feature is built into the STO key. Whenever you use the STO key, that variable's PREVIOUS contents automatically get moved into LASTARG for easy recovery in case of an accidental overwrite.

A similar recovery trick is built into the TOOL / PURGE softkey: it moves the specified variable and its name into LASTARG before deleting the variable, for easy recovery in case of an accidental PURGE.

Please note that these recovery tricks are built into the keyboard operations only, not the corresponding programmable commands STO and PURGE.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
09-05-2017, 05:39 AM (This post was last modified: 09-05-2017 05:56 AM by pier4r.)
Post: #3
RE: Hp 50g, SDLIB, SDFiler and moving HPDIR on the SD
(09-04-2017 09:30 PM)Joe Horn Wrote:  Just in case you didn't know, there is also a keyboard trick for that situation too. ...

No I did not know, that will be super useful, thanks. Once again, this little project plus the documentation and the community is showing me that the 50g - that already amazed me - is even better than expected.

update:

The content of a list in the directory in memory is this one for example:
[Image: CHTMzGv.jpg]

[Image: 774r8vf.jpg]

[Image: GjOSWm4.jpg]

Now I just discovered that if I recall the backup object from the SD using the built in filer, the data is there (also if I move it before with the Sd filer). If I use SDfiler, the data is not always there (and sometimes I get "no entries" where there are plenty.)

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




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