The following Natural samples demonstrate the interface between Portus and the Natural programming language
RESET #CODE (B4) INPUT #CODE CALL 'XMIDNATH' #CODE END
DEFINE DATA PARAMETER 1 #NATENVOUT (A80) 1 #OSENVOUT (A80) 1 #TIMEOUT (A30) END-DEFINE * COMPRESS 'NATURAL' *NATVERS 'PL' *PATCH-LEVEL 'SRVTYPE =' *SERVER-TYPE ', UI =' *UI INTO #NATENVOUT * COMPRESS *OS *OSVERS 'ON' *HARDWARE INTO #OSENVOUT * COMPRESS *DAT4I *TIME INTO #TIMEOUT END
DEFINE DATA PARAMETER 1 echoIn (a30) 1 echoOut (a30) END-DEFINE * MOVE echoIn to echoOut * END
DEFINE DATA PARAMETER 1 #OPERATION (A1) 1 #OPERAND-1 (I4) 1 #OPERAND-2 (I4) 1 #FUNCTION-RESULT (I4) LOCAL 1 #WORK-RESULT (I4) END-DEFINE * DECIDE ON FIRST VALUE OF #OPERATION VALUE '+' COMPUTE #FUNCTION-RESULT = #OPERAND-1 + #OPERAND-2 VALUE '-' COMPUTE #FUNCTION-RESULT = #OPERAND-1 - #OPERAND-2 VALUE '*' COMPUTE #FUNCTION-RESULT = #OPERAND-1 * #OPERAND-2 VALUE '/' IF #OPERAND-2 NE 0 THEN COMPUTE #FUNCTION-RESULT = #OPERAND-1 / #OPERAND-2 ELSE MOVE 0 TO #FUNCTION-RESULT END-IF VALUE '%' IF #OPERAND-2 NE 0 THEN DIVIDE #OPERAND-1 INTO #OPERAND-2 GIVING #WORK-RESULT REMAINDER #FUNCTION-RESULT ELSE MOVE 0 TO #FUNCTION-RESULT END-IF NONE VALUE MOVE 0 TO #FUNCTION-RESULT END-DECIDE * END