Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Hull and Outfitting

Example 7

  • Last UpdatedJan 20, 2023
  • 1 minute read

This example illustrates the possibility of using the IF and WHILE statement to test the input data. Such a test can be useful to avoid runtime errors.

MACRO,INPUT;

ASSIGN,CONT,1;

WHILE,CONT == 1;

GET/STR=('Key in colour',COL);

IF,COL == 'GREEN' OR COL == 'CYAN'

OR COL == 'BLUE' OR COL == 'MAGENTA'

OR COL == 'RED' OR COL == 'YELLOW'

OR COL == 'WHITE';

ASSIGN,CONT,0;

ENDIF;

ENDWHILE;

!

! When desired colour has been given the rest

! of the macro is executed.

!

ENDMACRO;

It might be more convenient to have such a parameter check as a submacro which would look like follows.

MACRO,INPUT_COLOUR,COL;

DECLARE,COL,STRING;

ASSIGN,CONT,1;

WHILE,CONT == 1;

GET/STR=('Key in colour',COL);

IF,COL == 'GREEN' OR COL == 'CYAN'

OR COL == 'BLUE' OR COL == 'MAGENTA'

OR COL == 'RED' OR COL == 'YELLOW'

OR COL == 'WHITE';

ASSIGN,CONT,0;

ENDIF;

ENDWHILE;

ENDMACRO;

The usage of INPUT_COLOUR could be like this.

MACRO,MAIN;

DECLARE,C,STRING;

CALL,INPUT_COLOUR,C;

COLOUR,C;

!

ENDIF;

TitleResults for “How to create a CRG?”Also Available in