× 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.



Found a solution. I think it is kinda ugly but it seems to work. 

Define second array based on pointer and then in dynamic allocation
code, add one line of code to load the address of the function array. 

I still wonder if there is not a more elegant way to do this. 

     d g_FunctionList...
     d                 ds                  Qualified
     d                                     Based(g_ptrFunctionList)
     d                                     Dim(32764)
     d    FunctionName...
     d                               50a
     d    ServiceProgramName...
     d                                     Like(StdNam)
     d    ServiceProgramLibrary...
     d                                     Like(StdNam)
     d    ServiceProcedure...
     d                               64a   Varying
     d    pptrProcedure...
     d                                     Like(StdPrcPtr)

     d g_FunctionName...
<<< New Array
     d                 s             50a    Based(g_ptrFunctionName)
     d                                      Dim(32764) 


         Position = %Lookup(Function      :
                            g_FunctionName:
                            1             :
                            g_FunctionCount);
         If Position = 0;
            Position = LoadFunction(%TrimR(Function));
         EndIf;

LoadFunction code.

       g_FunctionCount += 1;
       If g_FunctionCount > g_ListSize;
         If g_FunctionCount = 1;
           g_ListSize        = cInitialListSize;
           g_ptrFunctionList = %Alloc(g_ListSize *
%Size(g_FunctionList));
         Else;
           g_ListSize       += cListIncrement;
           g_ptrFunctionList = %ReAlloc(g_ptrFunctionList
:
                                        g_ListSize *
%Size(g_FunctionList));
         EndIf;
      
         // Get pointer into function name list for lookup.
         g_ptrFunctionName = %Addr(g_FunctionList(1).FunctionName);  <<
New code 
       EndIf;

Haven't tested yet but it should work.                     


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.