× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



... not very humorous, but simple:
supprocedures could replace subroutines, but subroutines could not replace subprocedures, because they don't have parameters, local variables and prototypes. to keep programms simple you don't need both and best is to forget subroutines.

example to demonstrate power of subProcedures

/* local prototypes
D work PR
D fetchC1 PR n
D doSomething PR
/*--- Constants
D TRUE C *ON
D FALSE C *OFF
/* statefull variables
d halString s 200
d C1Rec e ds extname(COVELENZ)
c/exec sql
c+ declare C1
c+ cursor for S1
/* very unimportant procedure main ----------------------------------*/
c/end-exec
/free
work();
return;
/end-free
/* end of vup -------------------------------------------------------*/
p work b
/free
halString = 'select * from COVELENZ';
exec sql prepare S1 from :halString;:
exec sql open C1;

dow fetchc1();
doSomething();
enddo;

exec sql close C1;
return ;
/end-free
p work e
/*-------------------------------------------------------------------*/
P fetchC1 B
D fetchC1 PI n
d result s n inz(FALSE)
/free
exec sql fetch next from C1
into :C1Rec;
if sqlcode = 0;
result = TRUE;
endif;
return result;
/end-free
P fetchC1 E
/*-------------------------------------------------------------------*/
P doSomething B
D doSomething PI
/free
// process the fetched record
return;
/end-free
P doSomething E
****************** End of data ****************************************

Additinal note:
global data and coupling procedures by global data is not bad design! Bad design is to define data global, which is needed only local!!!

D*B

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.