Current Page: NeXtMidas Training Primitives Lab 2 Instructions
- - | Lab 2 (Part A): Create a new primitive called `primlab2`. The primitive will take in a single argument `STR1` which will be a message string to print out. It will then print out the value of the message (as an INFO message) in the `open()` method of the primitive. `open()` should return `FINISH`. You do not need a `process()` or a `close()`. Use `UPDATE` to update the command dictionary. Use `BUILD` or `BLD` to build the primitive. Once you are done, give it a try.
        nM> primlab2 "Hello World!"
        INFO: Hello World! [PRIMLAB2]
- - Lab 2 (Part B): Modify the primitive you wrote in Part A so that it will print out the message as a warning if the `/WARN` switch is given. Once you are done, give it a try.
        nM> primlab2 "Hello World!"
        INFO: Hello World! [PRIMLAB2]
        nM> primlab2/warn "Hello World!"
        WARN: Hello World! [PRIMLAB2]
- - Lab 2 (Part C): Modify the primitive you wrote in Part B so that it will take in a keyword only parameter `RESNAME`. Tip: Keyword only parameters are read the same way as any other parameter. Tip: You will need to tell `UPDATE` that your primitive now takes in `1+` arguments. Once the message has been printed put a copy of the message in a new result that matches the name given with `RESNAME`. Once you are done, give it a try.
        nM> primlab2 "Hello" RESNAME=myres
        INFO: Hello [PRIMLAB2]
        nM> res myres
        5S: Hello
Now run it again, but with the message `Hi`. What happens? Tip: Use the "untranslated" get method to get names of results parameters and not their value.
Don't Make This Mistake:
When using the `UPDATE` command, make sure to include the `=` after specifying each parameter name. Example: `STR1=`, instead of `STR1`. Failure to include the `=` sign will result in the parameter not being recognized by NeXtMidas.