Working with Zones (JavaScript)
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="JavaScript"
OnClick="FindZones()" ID="Button4">
<INPUT TYPE="button" VALUE="Zones Count" LANGUAGE="JavaScript"
OnClick="ZonesCount()" ID="Button5">
<INPUT TYPE="button" VALUE="Verify Zone" LANGUAGE="JavaScript"
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: |
function FindZones()
{
var nRet;
LEADRasterDoc.GetAutoZoneOptions();
LEADRasterDoc.EnableZoneForceSingleColumn = true;
LEADRasterDoc.ShowZoneGridLines = true;
LEADRasterDoc.SetAutoZoneOptions();
nRet = LEADRasterDoc.FindZones(0, true);
if (nRet == 0)
alert("Automatic zones method finds all available zones into the specified pages successfully");
else
alert("Error" + nRet + "in finding available zone in the specified page");
}
function ZonesCount()
{
var nZoneCount;
nZoneCount = LEADRasterDoc.ZoneCount (0);
alert("Total Zones count = " + nZoneCount);
}
function VerifyZone()
{
var nZoneCount;
var nRet;
var i;
var ZONE_CHK_CHECKCBF_PROHIBIT = 4;
nZoneCount = LEADRasterDoc.ZoneCount(0);
for (i = 0; i < nZoneCount; i++)
{
nRet = LEADRasterDoc.GetZoneInfo(0, i, ZoneData);
if (nRet == 0)
{
if ((ZoneData.Flags & ZONE_CHK_CHECKCBF_PROHIBIT) == ZONE_CHK_CHECKCBF_PROHIBIT)
ZoneData.Flags = ZoneData.Flags & (!ZONE_CHK_CHECKCBF_PROHIBIT);
ZoneData.EnableVerificationEvent = true;
nRet = LEADRasterDoc.UpdateZone (0, i, ZoneData);
if (nRet != 0)
alert("Error" + nRet + "in updating zone # " + i)
}
}
}
5. |
Add the following code between the <HEAD> and </HEAD> tags to handle the Verification event: |
SCRIPT LANGUAGE="JavaScript" FOR="ZoneData" EVENT="Verification(iZoneIndex, bstrWord)">
<!--
var VF_ACCEPT = 4;
ZoneData.VerifyCode = VF_ACCEPT;
ZoneData.StopVerificationEvent = false;
//-->
</SCRIPT>
6. |
Run your page to test it. |
7. |
Save this page to use for testing other code samples. |