Showing posts with label puuu. Show all posts
Showing posts with label puuu. Show all posts

Saturday, 16 June 2012

Undocumented feature - interrupt - part seven


Continuing from part six where we looked at "10", "11" and "12" onwards, we're now going to look at "989".  This has a number of different uses, which are used by the debugger, so should be relatively safe to use moving forwards.


989 - Application focus


When the debugger kicks in, maybe caused by a debug statement in your code, the focus is immediately set to the debugger.  Apparently this is done using the interrupt command...


interrupt(989,"APPLFOCUS")


As far as I can tell this doesn't work, maybe because I'm using Windows 7 for my testing.  When you hit a debug statement it does bring the debugger into focus, but if my Uniface application calls the interrupt command above whilst another application has focus, it does not come into focus as I would expect.





989 - Format string


According to PUUU, this is supposed to format a string by adding carriage returns in.  It's not clear on the details, but something like this...


$result "RPL"
interrupt(989,"FORMAT")
string = $result


However, I couldn't get this to work for me, $result remained unaffected.  If you wanted to do something like this then you could use string manipulation, but I'm not sure why you'd want to.  Again, this is supposed to be used by the debugger, but I can't recall seeing an behaviour like this myself.





989 - Undo gold


When the debugger displays lists, it always uses semi-colon (;) and exclamation mark (!) as the delimiter, instead of their gold equivalents.  Apparently it uses the following command to do it...



$result "R·;P·!L"
interrupt(989,"UNDOGOLD")
string = $result

This replaces the gold delimiters with their normal equivalents.  It does not replace the wildcard characters, only the delimiters.  This one does actually work!  It's easy to find an alternative using $replace however...

string = $replace($replace("R·;P·!L",1,"·;",";",-1),1,"·!","!",-1)

This code is probably slightly easier to read, as you can easily see which characters are included in the "undo".  How about the performance though, over 2,000,000 iterations...

  • interrupt = 00:07.89, 00:07.64, 00:07.73 (almost 8 seconds)
  • $replace = 00:07.95, 00:07.83, 00:07.88 (almost 8 seconds)
So as you can see, it takes pretty much exactly the same amount of time either way, so I'll definitely be sticking with the alternative, instead of using interrupt.

Summary: Numeric code "989" has multiple uses, but it seems that they either don't work any more, or are easily replaced with alternatives.  I'll do a full summary of the interrupt command in the next post.




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.

Sunday, 10 June 2012

Undocumented feature - interrupt - part one

This is an undocumented feature that has been known about and used for a while, including a good guide on PUUU.  However, Compuware have documented a number of undocumented features in Uniface 9.5 and interrupt is not one of them.  This makes me think that there must be alternative ways of doing most of these things, or at least that's what I hope to determine whilst writing this post.


The most frequent usage, as far as I'm aware, is getting the working directory...


  interrupt(5,"")
  working = $result


The way that interrupt works is that you pass in a numeric code in the first parameter which determines the functionality, and then the second parameter can be used to pass a value in if needed.  The output is then place in $result for you to do with what you need.  Of course, this example is no longer needed as there is now $ldir which returns the same thing...

  working = $ldir()

So clearly the new version is documented and therefore supported, it's also more concise code and easier to maintain.  So once again a familiar question pops into my head... Which performs best?  I tested both of them over 2,000,000 iterations...

  • interrupt = 00:07.31, 00:07.34, 00:07.36 (just over 7 seconds)
  • $ldir = 00:06.11, 00:06.09, 00:06.04 (just over 6 seconds)

So as you can see, $ldir also performs fractionally better.  Given the number of iterations, it's pretty negligible, but on top of all the other reasons, I'm convinced that I should be using it over the old interrupt method.

In the next part I will be going through each of the known interrupt codes, trying to find alternatives that are documented, and testing the performance where appropriate.

Monday, 28 May 2012

Useful links

For a few weeks before I started this blog, I looked around to try and find what Uniface resources there were available, such as blogs and forums.  The list wasn't long, but I've also been researching to find out how active they are.  Here is the list I've come up with...

Official Compuware links...

Social links...

Active sites...

Semi-active sites...

Inactive sites...

I hope you find these links useful - please post more in the comments if you have them.