Showing posts with label $lfileproperties. Show all posts
Showing posts with label $lfileproperties. Show all posts

Monday, 18 June 2012

Undocumented feature - interrupt - part nine

I know that I said I was done after part eight, but I've had a report of some additional functionality that I thought I should add.



5 - Uniface "usys" directory


As previously discussed, using numeric code "5" returns the working directory.  However, you can also use it to display the Uniface "usys" directory...   

  interrupt(5,"USYS")
  uniface = $result



EDIT: Thank you to James Rodger for pointing out the alternative in his comment...


  uniface = $valuepart($fileproperties("usys:","FULLPATH"))


This in itself seems to be an undocumented feature; I can't find any reference to "usys:" being accessible like this in $fileproperties or $lfileproperties.


I tried to access some other Uniface directories in a similar way, such as "adm" and "bin", but it seems that you can only access "usys".


Thank you to Mark R for point this one out.

Saturday, 16 June 2012

Undocumented feature - interrupt - part eight


Continuing from part seven where we looked at "989", I will now do a full summary of the known functionality that we've looked at in this series of posts...


Code Description Example Alternative
0File information
interrupt(0,"test.txt")
if ( $status < 0 )
  ;file doesn't exist
else
  list = $result
  name = $item("Name",list) ;"test"
  type = $item("Type",list) ;"txt"
  vers = $item("Version",list) ;""
  attr = $item("Attrib",list) ;"UUU"
endif
This doesn't seem to return any useful information now.


Could use:
$fileproperties or
$lfileproperties


These return lots more file information, but not the same.
2Extract filenameinterrupt(2,"C:\temp\test.txt")
filename = $result ;"test.txt"
Use string manipulation
(although interrupt takes 60% of the time)
3Extract file pathinterrupt(3,"C:\temp\test.txt")
filename = $result ;"C:\temp\"
Use string manipulation
(although interrupt takes 60% of the time)
5Working directoryinterrupt(5,"")
working = $result ;"C:\temp\"
Use:
$ldir
5Uniface "usys" directoryinterrupt(5,"USYS")
uniface = $result ;"C:\uniface\"
Use:
$fileproperties of "usys:"
6Concatenate file path$result "C:\temp"
interrupt(6,"test")
filepath = $result ;"C:\temp\test\"
Use string manipulation
(although interrupt takes 70% of the time)
7Parent directoryinterrupt(7,"C:\temp\test\")
parent = $result ;"C:\temp\"
Use string manipulation
(although interrupt takes 33% of the time)
10Directory listing (files)interrupt(10,"C:\temp")
list = $result ;"test.txt·;test2.txt"
count = $status ;2
Use:
$dirlist or
$ldirlist (with "FILE" topic)
11Directory listing (folders)interrupt(11,"C:\temp")
list = $result ;"test·;test2"
count = $status ;2
Use:
$dirlist or
$ldirlist (with "DIR" topic)
989Application focusinterrupt(989,"APPLFOCUS") No alternative
(doesn't seem to work anyway)
989Format string
$result "RPL"
interrupt(989,"FORMAT")
string = $result
Use string manipulation
(doesn't seem to work anyway)
989Undo gold characters$result "R·;P·!L"
interrupt(989,"UNDOGOLD")
string = $result ;"R;P!L"
Use:
$replace



It seems that the interrupt command isn't really very useful anymore.  The functionality has either been replaced by new Uniface functions, or can be achieved by string manipulation.  Given the performance improvements, it may be worth considering using interrupt if you are heavily handling file paths, but given the number of iterations needed to see the difference, I'd be surprised if this was ever worthwhile.


Given the numeric nature of the code, I'm sure that the unknowns (1, 4, 8 and 9) must do something too - I'd love to know what!  Probably some of 12-988 do something as well, so I'm sure there are some hidden gems within the interrupt command.  If you know of any, please let me know in the comments.

Monday, 11 June 2012

Undocumented feature - interrupt - part two

Carrying on from part one, I want to look at the functionality available using the undocumented interrupt command and see if I can find alternatives, preferably documented ones. So let's go through the known numeric codes...


0 - File information


Always a good place to start.  In this case you pass in the filename in the second parameter and $result is populated with a list of information about the file.  If the file does not exist the $status will be -1, so it could also be used for this check, but assuming it does exist then it will be 0.  


In the information on PUUU, $result will return the following list of properties...

  • Path
  • DiskDir
  • Name
  • Type
  • Version
  • Attrib
  • RecSize
  • Filesize

Here's some example code for you...

  interrupt(0,"test.txt")
  if $status < 0 )
    ;file doesn't exist
  else
    list = $result
    name = $item("Name",list)
    type = $item("Type",list)
    vers = $item("Version",list)
    attr = $item("Attrib",list)
  endif

You may notice that I am only referencing a subset of the properties in this example.  This because I've tested this in Uniface 9.5 and I only get these properties in the list.  This is the problem with undocumented features.  Assuming the information on PUUU was accurate when tested in Uniface 7.2, this functionality has changed and some properties are no longer being returned.  I hope no one was relying on them!

So what if we didn't have the interrupt command, could we still access this information?  My first though was "yes", using $fileproperties or $lfileproperties, which are well documented.  This has the following properties (or "topics")...

  • FILETYPE
  • FILESIZE
  • FULLPATH
  • CREATIONDATE
  • MODIFICATIONDATE
  • ACCESSDATE
  • FILEATTRIBUTES
  • COMPRESSEDSIZE
  • CHECKSUM
  • METHOD
  • ZIPFILENAME

Unfortunately when I compare the output of the two, I don't really get any correlation at all.  For my "test.txt" file...

  • Name = "test"
  • Type = "txt"
  • Version = ""
  • Attrib = "UUU"

I have no idea what the attributes "UUU" means, but the topic FILEATTRIBUTES returns a much more sensible "A", meaning that the file is archived and not hidden or system, etc.  Also version is blank, so I don't know if that genuinely is the version, or whether this property is no longer being populated correctly, making it very hard to investigate.

When it comes to name and type, these seem to be a simple case of cutting up the filename, rather than actually being file properties in themselves.  I could compare the performance of the string manipulation over the call to interrupt, but I think in this case I'm going to accept that this command doesn't return any useful information, and disregard it.


1 - Unknown


I have not found any indication of what functionality this might be, but given the incremental nature of the numeric code I have to assume it does something.  My first thought was that it might be the same as "0" but for folders instead of files, unfortunately it always returns a $status of -1 and $result is unaffected.  I tried folders, subfolders, filenames and a blank string, with no difference in behaviour.  I'm giving up, for now.


Summary: Numeric codes "0" and "1" don't seem to be useful.  I'll continue in the next part.