When you compile a VB 4.0 or 5.0 program, the CDDAGETLASTCPF subroutine gives the error:
Too Many local, nonstatic variables


There is a bug in VB 4.0 and 5.0 where a Globally Type Declared variable allocates stack space for each usage of the variable within a function. In this case, the ddaGetLastCPF function is called 21 times within the CDDAGETLASTCPF function, thus allocating the entire LastCPF message variable (1578 Bytes) 21 times, so that 34,716 Bytes of memory is allocated. This overflows the local variable space, which has a maximum allocation of 32,000 bytes.
However, when a standard string variable is referenced in each ddaGetLastCPF call, the system doesn't allocate local string space like it does with Type Declared variables, thus eliminating the problem in the CDDAGETLASTCPF routine.
Use the following work-around:
  1. Change the ddaGetLastCPF Declaration in a CoreCode Generated VB module:

    Declare Function ddaGetLastCPF Lib "dda40032.dll" (ByVal session As Long, ByVal LastCPF As String) As Long

  2. Create the following variable in the Global Variables section of the DDA/00 BAS module:

    Global LastCPF2 As String * 1579 'Temporary Last CPF Message String

  3. Change all LastCPF references to LastCPF2 for each of the ddaGetLastCPF function calls in CDDAGETLASTCPF.
  4. Add the Mid$ block of code at the end of the CDDAGETLASTCPF function so the messages are parsed correctly into the LastCPF structure from string variable LastCPF2.

Sample CDDALASTCPF Function

Function CDDAGETLASTCPF(ByVal EFormat As String) As Integer
'**                                                        **
'** Function: CDDAGETLASTCPF                               **
'** Purpose:  Get the last CPF message (if any)            **
'** Parms:    None.                                        **
'** Returns:  DDASUCCESS: LastCPF holds last CPF message.  **
'**           Other:      Error Occurred. Check Return Code**
'**                                                        **

If UCase$(EFormat) = "ITEMMAST" Then
'Get the last CPF message...
ddaret = ddaGetLastCPF(HOST_ARRAY(1).HostSession, LastCPF2)
End If

'Before Exiting this routine we need to fill in the LastCPF 
'Message Structure by parsing variable LastCPF2
LastCPF.MsgID = Mid$(LastCPF2, 1, 7)
LastCPF.MsgType = Mid$(LastCPF2, 8, 15)
LastCPF.MsgFile = Mid$(LastCPF2, 23, 20)
LastCPF.ExtraInfo = Mid$(LastCPF2, 43, 512)
LastCPF.MsgData = Mid$(LastCPF2, 555, 512)
LastCPF.MsgText = Mid$(LastCPF2, 1067, 512)


End Function
Still have questions? We can help. Submit a case to technical support

Last Modified On:
You don't have the appropriate permissions.
No, open a new Support Case