6.1.1. Create an Add Blocks Button for the Script

About this task

A Create an Add Blocks Button
B Create a Mouse Up Event
C Write a Script for the Add Blocks Button
D Finish the Add Blocks Configuration
  1. Create an Add Blocks Button

Procedure

  1. Place a button on the CIMPTRACK screen.
  2. Name the button Add Blocks.

    Tip: Replace the default Button entry in the Text Button>String field.

  3. (Optional) Select a different color for the button face.
    1. Create a Mouse Up Event
  4. Select the Events tab in the button's Properties dialog box.
  5. Do the following.
    A Event field Select Mouse Up in the drop down list.
    B Action
    1. Click the Popup button to the right of the Action field.
    2. Select New Script on the Popup menu.

    Result: An Edit Script window opens.

    1. Write a Script for the Add Blocks Button

    The script includes the following sections

  6. Declare a variable that's going to hold the item ID that the user enters.

    Enter:

    Dim itemid As String Dim model As String

  7. Create the input box that will prompt the user for an item ID and model type for the block.

    Enter:

    itemid = InputBox$("Enter BLOCK item ID, please","Item ID Entry","") model = InputBox$("Enter BLOCK model type, please (valid entries: 25,36,60,99)","Model Type Entry","")

  8. Take the value of the itemid string variable and create a new block item with the itemid string variable as the new block item's ID.

    Declare a new object of type prtitem. Put this statement with your other variable declarations:

    Enter:

    Dim item As New prtItem

  9. Add the code to add this new item to your schedule region.

    Enter:

    'Set the item properties item.regionid="SCHEDULE" item.itemid=itemid item.itemtypeid=model item.regionloc=-1 item.exthold 0 item.groupid="MAIN" item.inthold 0 'Add the item to PRT item.Add

    1. Finish the Add Blocks Configuration
  10. Compile the script.
  11. Click File>Close on the Edit Script window menu bar to close the window.
  12. Click OK to close the Properties dialog box.

Results

The CimEdit screen now has an Add Blocks button.