+ All Categories
Home > Documents > Exercise Handouts

Exercise Handouts

Date post: 03-Apr-2018
Category:
Upload: vetrikamal
View: 228 times
Download: 0 times
Share this document with a friend

of 14

Transcript
  • 7/28/2019 Exercise Handouts

    1/14

    Exercise 1 Write a macro to build a spongle

    The primitives used are a box, cyl, snout and dish:

    The box is 1000 x 1000 x 1000 The cyl is 400 dia x 600 high The snout is 300 high x 600 Dtop x 400

    Dbot The dish is 600 dia x 300 high

    Note: use connect p-points syntax to connect theprimitives together:

    e.g. CONN P1 TO P2 OF PREV

  • 7/28/2019 Exercise Handouts

    2/14

    Exercise 2

    Modify the spongle macro to acceptparameterised input.

    How many parameters do you need?

  • 7/28/2019 Exercise Handouts

    3/14

    Exercise 3Modify the spongle macro to build the fullspongle shown.

    Treat each leg of the spongle as a subequipment.

    Use a DO loop to copy and connect the

    legs to each of the box p-points 1 to 6.

  • 7/28/2019 Exercise Handouts

    4/14

    Exercise 4

    Convert the basic ladder building macro to aPML2 function

    Call the function ex4.pmlfnc

    Define the function with 3 arguments:!name, !height and !width

    Remember to think carefully about whatdata-types to use for the arguments

    To call the function type:

    !!ex4(myladder,3000,350)

    (Make sure you are at zone level beforecalling the function!)

    WIDTH

  • 7/28/2019 Exercise Handouts

    5/14

    Exercise 5

    Build this form

    Centigrade, Fahrenheit,Minimum C, Maximum C,StepSize, Width, Height, Lengthand Number are all REAL TEXTgadgets

    Input, Name and Result areSTRING TEXT gadgets

    Table is a TEXTPANE gadgetRemember to use the FRAMEgadget as a container for eachgroup of gadgets shown

  • 7/28/2019 Exercise Handouts

    6/14

    Exercise 6

    Create a call-back method.convertctof() to convert a

    temperature in degrees Centigrade toFahrenheit and put the result in the

    Fahrenheit gadget. Create a call-back method

    .convertftoc() to convert a

    temperature in degrees Fahrenheit toCentigrade and put the result in theCentigrade gadget.

    The formulae for the conversions are:degf = degc * 1.8 + 32degc = (degf 32) / 1.8

  • 7/28/2019 Exercise Handouts

    7/14

    Exercise 7

    The temperature range frame onyour form is designed to give youpractice using do loops andwriting methods.

    It works by taking a minimum,

    maximum temperature and a stepsize. Pressing the apply buttoncauses the complete range oftemperatures and theirconversions to be displayed in theresults table.

    Take care to avoid potentialhazards such as no values givenin a field and a maximum valueless than the minimum.

  • 7/28/2019 Exercise Handouts

    8/14

    Exercise 8Modify your workbench form sothat when you enter a string of textin the text input gadget, the resultsshows the number of words and thereversed text string in the result

    string gadget.

    Hints: Use the .split() method forstrings and the .invert() and .size()methods for arrays.

    Hello How Are You

    You Are How Hello

    4

  • 7/28/2019 Exercise Handouts

    9/14

    Exercise 9Build this form

  • 7/28/2019 Exercise Handouts

    10/14

    Exercise 10

    Build this form

    Populate the OPTION andLIST gadget DTEXT arraysussing a constructormethod

    Remember a constructormethod has the same name asthe form:

    e.g.

    define method .ex10()

    -- pml code

    endmethod

  • 7/28/2019 Exercise Handouts

    11/14

    Exercise 11Build this form

    Add an entry in the BAR menuto show your previous forms(from exercises 8, 9 & 10)

  • 7/28/2019 Exercise Handouts

    12/14

    Exercise 12Build this form

    STRING TEXT gadget

    LIST gadgets

    We will discuss how topopulate the LIST gadgets afteryou have built the form

    When the user presses theRead File button print out

    the contents of the selected fileto the requests window usingthe $p syntax

  • 7/28/2019 Exercise Handouts

    13/14

    Exercise 13 Part IBuild this form

    Think carefully about what gadgettypes you need to create

    Populate the position OPTION

    gadgets in a constructor methodWhen the form is shown collect allequipment and add the names intothe first gadget

    When a user selects an equipmentfrom the list update the other

    gadgets with the equipmentattributes

    When the Apply button is pressedmove to the equipment selectedand set the attributes from the formgadget values

  • 7/28/2019 Exercise Handouts

    14/14

    Exercise 13 Part II

    (Optional If time permits)When the user presses the Reportbutton create a report file containingthe attributes NAME, POSITIONand DESCRIPTION for all

    equipment in the listUse the PML1 compose syntax togenerate the report and write this toa text file called:

    /%pdmsuser%/equip-report.txt

    Use a FILE object to write thereport and remember to use the.writeFile() method to write an arrayof the report contents to the file


Recommended