On Sep 20, 2006, at 10:53 AM, Norman Palardy wrote:


On Sep 20, 2006, at 11:12 AM, Phil M wrote:


You only need to run this test once per application run, so for an optimization technique I would write the above code like this:

Function PlatformType() As String
  Static myPlatform As String
  Dim shUname As Shell

  If (myPlatform.Len = 0) Then     // not initialized
    shUname = New Shell
    shUname.Execute "uname -p"
    If (shUname.ErrorCode <> 0) Then
      // handle error - is uname corrupt???
    Else
      myPlatform = shUname.Result
    End If
  End If

  Return myPlatform
End Function

This way you only create the Shell once per application launch... after all the platform is not going to dynamically change. =)

unless of course uname fails and you never set myPlatform

That's why my comment about handling the error if shUname.ErrorCode <> 0 ... "The completion of this example is left as an exercise for the reader" and all that :) ...

Tim
--
Tim Jones                                       [EMAIL PROTECTED]

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to