Working with Zones (Visual Basic Script)

Take the following steps to add code to the existing page that will let you manipulate zones:

1.

Start with the program you created in Working with Pages.

2.

Add the following code between the <BODY> and </BODY> tags to add three buttons to the page:

<INPUT TYPE="button" VALUE="Find Zones" LANGUAGE="VBScript"
         OnClick="FindZones" ID="Button4">

<INPUT TYPE="button" VALUE="Zones Count" LANGUAGE="VBScript"
         OnClick="ZonesCount" ID="Button5">

<INPUT TYPE="button" VALUE="Verify Zone" LANGUAGE="VBScript"
         OnClick="VerifyZone" ID="Button6">

3.

Add the following code to add an instance of the LTZoneData class:

<object classid="clsid:00140B4A-B1BA-11CE-ABC6-F5B2E79D9E3F">
</object>

4.

Add the following code between the <SCRIPT> and /SCRIPT> tags:

Sub FindZones()
         Dim nRet
         LEADRasterDoc.GetAutoZoneOptions
         LEADRasterDoc.EnableZoneForceSingleColumn = True
         LEADRasterDoc.ShowZoneGridLines = True

         LEADRasterDoc.SetAutoZoneOptions
         nRet = LEADRasterDoc.FindZones(0, True)
         If (nRet = 0) Then
            MsgBox "Automatic zones method finds all available zones into the specified pages successfully"
         Else
            MsgBox "Error" + CStr(nRet) + "in finding available zone in the specified page"
         End If
End Sub

Sub ZonesCount()
         Dim nZoneCount
         nZoneCount = LEADRasterDoc.ZoneCount(0)
         MsgBox "Total Zones count = " + CStr(nZoneCount)
End Sub

Sub VerifyZone()         
         Dim nZoneCount
         Dim nRet
         Dim i
         Dim ZONE_CHK_CHECKCBF_PROHIBIT

         ZONE_CHK_CHECKCBF_PROHIBIT = 4

         nZoneCount = LEADRasterDoc.ZoneCount(0)
         For i = 0 To  nZoneCount -1
            nRet = LEADRasterDoc.GetZoneInfo(0, i, ZoneData)
            If (nRet = 0) Then
               If ((ZoneData.Flags And ZONE_CHK_CHECKCBF_PROHIBIT) = ZONE_CHK_CHECKCBF_PROHIBIT) Then
                  ZoneData.Flags = ZoneData.Flags And (Not ZONE_CHK_CHECKCBF_PROHIBIT)
               End If

               ZoneData.EnableVerificationEvent = True
               nRet = LEADRasterDoc.UpdateZone(0, i, ZoneData)

               If (nRet <> 0) Then
                  MsgBox "Error" + CStr(nRet) + "in updating zone # " + CStr(i)
               End If
            End If
         Next
End Sub

5.

Add the following code between the <HEAD> and </HEAD> tags to handle the Verification event:

<SCRIPT LANGUAGE="VBScript" FOR="ZoneData" EVENT="Verification(iZoneIndex, bstrWord)"> 
      <!--
         Dim VF_ACCEPT
         VF_ACCEPT = 4

         ZoneData.VerifyCode = VF_ACCEPT
         ZoneData.StopVerificationEvent = False
         MsgBox bstrWord
      //-->
</SCRIPT>

6.

Run your page to test it.

7.

Save this page to use for testing other code samples.