1

I am new to the NATURAL programming language. I am trying to find a way that I can pass one parameter to a subroutine just like in C++ or Java. Right now I have to move everything to another variable and call the method. Thus is cumbersome and is a lot more code to write.

Question: Can a Natural Program Sub-Routine have a parameter list like in C++ or Java?

   D = passVariable1
   PERFORM FLIP-DATE
      A = D 
   END-SUBROUTINE
   newVariable = A

Code:

 DEFINE SUBROUTINE FLIP-DATE          
    #A    = #D                    
    #B    = #E                     
    #C    = #F                  
    RESET   #NMM #NDD #NCCYY                                                
 END-SUBROUTINE

What I would like to do.

Code:

   DEFINE SUBROUTINE FLIP-DATE(A,B,C,D,E,F) <-- is this possible somehow?          
     #A    = #D                    
     #B    = #E                     
     #C    = #F                  
     RESET   #NMM #NDD #NCCYY                                                
   END-SUBROUTINE
Doug Hauf
  • 3,025
  • 8
  • 46
  • 70
  • I answered your question below, however I do have a question. What data type is passVariable1? Is it NATURAL D (date) or T (time) format, by any chance? – zarchasmpgmr Feb 09 '14 at 00:22
  • Alpha is the data type that is reference with passVariable1 – Doug Hauf Feb 09 '14 at 01:35
  • Ah. Date/time formatted variables have some nice features where you can play games like this. You might also want to look at the MOVE SUBSTRING statement. Disclaimer: I'm ex-SAG R&D. – zarchasmpgmr Feb 10 '14 at 02:48

2 Answers2

2

The parameter data area (PDA) is a special verision of the local data area (LDA), that is used in function, external subroutine, or helproutine objects. You can either define parameters inline like

DEFINE DATA
PARAMETER
1 #A(N2)
1 #B(N2)
1 #C(N2)
1 #D(N2)
1 #E(N2)
1 #F(N2)
LOCAL
your local variables
END-DEFINE
…

Alternatively you can also create a separate source object, similar to an external LDA.

DEFINE DATA
PARAMETER USING pda
LOCAL
your local variables
END-DEFINE
…

Note that you cannot use parameters with an internal subroutine.

I suggest you start reading the Natural documentation on Software AG's web site, especially the "First Steps" manual, if you've never worked with this powerful language before.

zarchasmpgmr
  • 1,422
  • 10
  • 21
1

parameter-data-area can be used to pass the data to sub programs and routines.

Gagan
  • 11
  • 1