Arthur Fuller
fuller.artful at gmail.com
Sun Oct 21 12:15:42 CDT 2007
As regulars here well know, I'm a big fan of static functions. But I
recently came across a situation in which the conventional use of statics
didn't work, because they hide the value of interest within themselves, so
two static functions cannot share a single value.
This concerns an implementation of PushDir and PopDir. I ended up writing it
like this. I invite revisions.
<code>
Option Compare Database
Option Explicit
Global DirName_glb As String
Sub PushD()
DirName_glb = CurDir
Debug.Print "Current Directory: " & DirName_glb
End Sub
Sub PopD()
ChDir DirName_glb
Debug.Print "Back to Directory: " & DirName_glb
End Sub
Sub TestPushPop()
PushD
ChDir "c:\Apps"
Debug.Print "New directory: " & CurDir
PopD
End Sub
</code>
TIA,
Arthur