Tie It All Together
 
 
 

You are ready to combine the subroutines into the Gardenpath macro. In the VBA IDE, enter the following code in the Code window, after the drawtiles subroutine:

' Execute command, calling constituent functions
Sub gardenpath()
	Dim sblip As Variant
	Dim scmde As Variant
	gpuser
	sblip = ThisDrawing.GetVariable("blipmode")
	scmde = ThisDrawing.GetVariable("cmdecho")
	ThisDrawing.SetVariable "blipmode", 0
	ThisDrawing.SetVariable "cmdecho", 0
	drawout
	drawtiles
	ThisDrawing.SetVariable "blipmode", sblip
	ThisDrawing.SetVariable "cmdecho", scmde
End Sub

The path subroutine calls gpuser to gather the necessary input. The GetVariable method is then used to obtain the current values of the BLIPMODE and CMDECHO system variables, and saves these values as sblip and scmde. The subroutine then uses the SetVariable method to set both of these system variables to 0, thereby disabling blips and command echoing. Next, the path is drawn using the drawout and drawtiles subroutines. Finally, the SetVariable method is used to reset the system variables to their original values.

You may notice that this is the only subroutine you have entered that did not begin with a Private keyword, which ensures the subroutine can only be called from within the current module. Because the gardenpath subroutine must be available to the user, you should omit the Private keyword.

Save your work.