Use Crystal\CheckForCrystal.dg Use dfrptvw.pkg Use DataDict.pkg Use Windows.pkg Use dfSpnFrm.pkg Use dfRadio.pkg Use cCrystal.pkg Use Vendor.DD Use Customer.DD ACTIVATE_VIEW Activate_oAddressLabelsCR FOR oAddressLabelsCR Object oAddressLabelsCR is a ReportView Set Label to "Address Labels" Set Location to 10 13 Set Size to 135 172 Set piMinSize to 135 229 Object Vendor_DD is a Vendor_DataDictionary Send DefineAllExtendedFields End_Object // Vendor_DD Object Customer_DD is a Customer_DataDictionary Send DefineAllExtendedFields End_Object // Customer_DD Set Main_DD to Customer_DD Set Server to Customer_DD Object oCopiesGroup is a Group Set Size to 32 154 Set Location to 3 6 Set Label to "Number of Labels to Print per Record:" Object oCopies is a SpinForm Set Label to "Print " Set Size to 13 39 Set Location to 13 30 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Minimum_Position to 1 // Procedure : Activating // Purpose : This is used to default the number of labels to print Procedure Activating Forward Send Activating Set Value to 1 End_Procedure // Activating End_Object // oCopies Object oTextBox1 is a Textbox Set Label to "Labels per Record" Set Location to 15 72 Set Size to 10 59 Set TypeFace to "MS Sans Serif" End_Object // oTextBox1 Function NumberOfCopies Returns Integer Integer iCopies Get Value of oCopies to iCopies Function_Return iCopies End_Function // NumberOfCopies End_Object // oCopiesGroup Object oPrintGroup is a RadioGroup Set Size to 54 71 Set Location to 38 7 Set Label to "Print For:" Object oRadio1 is a Radio Set Label to "Customers" Set Size to 10 49 Set Location to 13 9 End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "Vendors" Set Size to 10 43 Set Location to 26 9 End_Object // oRadio2 Object oRadio3 is a Radio Set Label to "Both" Set Size to 10 31 Set Location to 39 9 End_Object // oRadio3 Procedure Notify_Select_State Integer iToItem Integer iFromItem Forward Send Notify_Select_State iToItem iFromItem //for augmentation End_Procedure // Notify_Select_State //If you set Current_Radio, you must set it AFTER the //radio objects have been created AND AFTER Notify_Select_State has been //created. i.e. Set in bottom-code of object at the end!! //Set Current_Radio To 0 End_Object // oPrintGroup Object oDestGroup is a RadioGroup Set Size to 54 76 Set Location to 38 84 Set Label to "Output Destination:" Object oScreen is a Radio Set Label to "Screen" Set Size to 10 39 Set Location to 17 14 End_Object // oScreen Object oPrinter is a Radio Set Label to "Printer" Set Size to 10 37 Set Location to 31 14 End_Object // oPrinter Procedure Notify_Select_State Integer iToItem Integer iFromItem Forward Send Notify_Select_State iToItem iFromItem If (iToItem = 0) Begin Set peOutputDestination of oCrystalReport1 to PRINT_TO_WINDOW End Else Begin Set peOutputDestination of oCrystalReport1 to PRINT_TO_PRINTER End End_Procedure // Notify_Select_State End_Object // oDestGroup Object oOkButton is a Button Set Label to "&OK" Set Size to 14 51 Set Location to 96 51 Set Default_State to True Procedure OnClick Boolean bCrystalOK Get CheckCrystalEnvironment of oCheckForCrystal to bCrystalOK If (bCrystalOK) Begin Send RunReport of oCrystalReport1 End Else Begin Send DisplayDialog of oCheckForCrystal End End_Procedure End_Object // oOkButton Object oCancelButton is a Button Set Label to "&Cancel" Set Location to 96 110 Procedure OnClick Send Request_Cancel End_Procedure // OnClick End_Object // oCancelButton Object oCrystalReport1 is a cCrystal Use Customer.DD Set psReportName to "Labels.rpt" // Array of strings Property String[] pStates // This is called for each customer or vendor we create // a label for. It adds the state if it does not already // exist in the array. Procedure AddState String sState Integer iItem iCount String sVal String[] hoStates Get pStates to hoStates Move (SizeOfArray(hoStates)) to iCount For iItem From 0 to (iCount-1) If (sState = (hoStates[iItem])) Procedure_Return Loop Move sState to hoStates[iCount] Set pStates to hoStates End_Procedure // AddState // This returns an array of vendors. Function LoadVendors Returns Variant[][5] Integer iItem iCopies iLabel Boolean bFound Variant[][5] vData Get NumberOfCopies of oCopiesGroup to iCopies Clear Vendor Find gt Vendor by 1 Move (Found) to bFound While bFound // Must have a City, State, and Zip code to create a label If ((Vendor.City <> "") and (Vendor.State <> "") and (Vendor.Zip <> "")) Begin // copy For iItem From 1 to iCopies Move (Trim(Vendor.Name)) to vData[iLabel][0] Move (Trim(Vendor.Address)) to vData[iLabel][1] Move (Trim(Vendor.City)) to vData[iLabel][2] Move (Trim(Vendor.State)) to vData[iLabel][3] Move (Trim(Vendor.Zip)) to vData[iLabel][4] Increment iLabel Loop // Add state to list Send AddState Vendor.State End Find gt Vendor by 1 Move (Found) to bFound End Function_Return vData End_Function // LoadVendors // This returns an array of customers. Function LoadCustomers Returns Variant[][5] Integer iItem iCopies iLabel Boolean bFound String sCSZ Variant[][5] vData Get NumberOfCopies of oCopiesGroup to iCopies Clear Customer Find gt Customer by 1 Move (Found) to bFound While bFound // Must have a City, State, and Zip code to create a label If ((Customer.City <> "") and (Customer.State <> "") and (Customer.Zip <> "")) Begin Move (Trim(Customer.City)) to sCSZ Append sCSZ ", " (Trim(Customer.State)) " " (Trim(Customer.Zip)) // copy For iItem From 1 to iCopies Move (Trim(Customer.Name)) to vData[iLabel][0] Move (Trim(Customer.Address)) to vData[iLabel][1] Move (Trim(Customer.City)) to vData[iLabel][2] Move (Trim(Customer.State)) to vData[iLabel][3] Move (Trim(Customer.Zip)) to vData[iLabel][4] Increment iLabel Loop // Add state to list Send AddState Customer.State End Find gt Customer by Index.1 Move (Found) to bFound End Function_Return vData End_Function // LoadCustomers Procedure OnInitializeReport Handle hoReport Handle hoParam hoLabels String[] hoStates Variant[][5] vData Integer iItem iCount String sDesc // Clear states Set pStates to hoStates // Create data to print labels Get CreateCDO of hoReport "Label.ttx" to hoLabels If (hoLabels) Begin // Load Vendors If (Current_Radio(oPrintGroup)<>1) Begin Get LoadVendors to vData Send AppendCDOData of hoReport hoLabels vData End // Load Customers If (Current_Radio(oPrintGroup)<>0) Begin Get LoadCustomers to vData Send AppendCDOData of hoReport hoLabels vData End End // Prompt a list of states based on customers and/or vendors Set ComEnableParameterPrompting of hoReport to True // Create Parameter object Get GetParamObjectByName of hoReport "ChoiceOfStates" to hoParam If (hoParam) Begin // Set prompt string Set ComPrompt of hoParam to "Please Select All States to Print Labels For:" // Don't allow user to add states to the list Set ComDisallowEditing of hoParam to True // Allow the user to select more than one state Set ComEnableMultipleValues of hoParam to True // Get list if states Get pStates to hoStates Move (SizeOfArray(hoStates)) to iCount For iItem From 1 to iCount // Add each state to the parameter object Send ComSetNthDefaultValue of hoParam iItem (hoStates[iItem-1]) // Get state code description from validation table Get Find_Code_Description of Customer_State_VT (hoStates[iItem-1]) to sDesc Set ComNthValueDescription of hoParam iItem to (Trim(sDesc)) Loop End End_Procedure // OnInitializeReport End_Object // oCrystalReport1 On_Key Key_Alt+Key_O Send KeyAction of oOkButton On_Key Key_Alt+Key_C Send KeyAction of oCancelButton End_Object // oAddressLabelsCR