Page 1 of 1

DCVARGROUP Error

Posted: Fri Dec 16, 2016 9:16 pm
by Cliff Wiernik
I have been using DCVARGROUP for some time without issue.

I am making a test program and took a sample program that uses this code and am reducing the program to create the test program.

This is the code I am using:

Code: Select all

  DCVARGROUP TO oV NAME mVars_Template3 ;
    m_sec_num       := SPACE(3),        ;
    m_sec_name      := SPACE(35),       ;
    m_add_1         := SPACE(25),       ;
    m_add_2         := SPACE(25),       ;                      
    m_city          := SPACE(25),       ;                      
    m_state         := SPACE(2),        ;                      
    m_zip           := SPACE(9),        ;                      
    m_phone         := SPACE(10),       ;                      
    m_contact       := SPACE(35),       ;                      
    m_ndefdays      := 0,               ;
    m_acct_num      := SPACE(9),        ;                      
    m_nadvrate      := 0,               ;
    m_acctnum2      := SPACE(9),        ;
                                        ;
    d_lEditmode     := .F.,             ;                                       // Define for TOOL BAR - in edit mode or not
    d_lAddmode      := .F.,             ;                                       //   in add mode
    d_nTabpage      := 0,               ;                                       //   current tab page number
    d_bNextpage     := NIL,             ;                                       //   code block for next page hot key +
    d_bPrevpage     := NIL,             ;                                       //   code block for next page hot key -
    d_cTitle        := '',              ;                                       //   program dialog title
    d_lDisablesave  := .F.,             ;                                       //   flag to disable save button                        
                                        ;
    d_oDialog       := NIL,             ;                                       //   pointer to option dialog screen
                                        ;
    d_oMsgbox       := NIL,             ;
    d_oStatstatic   := NIL,             ;
    d_oStatbar      := NIL,             ;
                                        ;
    d_nSaverecord   := NIL,             ;                                       //   work variable used for current record position
    d_aNtabs        := NIL,             ;                                       //   array containing tab page ordinal number
    d_aOtabs        := NIL,             ;                                       //   array containing tab page object pointers
    d_lSaveneeded   := .F.,             ;                                       //   flag indicating whether a save process is needed to be performed   // PC CAW 08-07-15
                                        ;
    d_oTabpage1     := NIL,             ;
    d_oTabstatic1   := NIL,             ;
    d_oPagegroup1   := NIL,             ;
    d_oSeekkey      := NIL,             ;
    d_oBrowse       := NIL,             ;
                                        ;
    d_oTabpage2     := NIL,             ;
    d_oTabstatic2   := NIL,             ;
    d_oPagegroup2   := NIL,             ;
    d_oIdent2       := NIL,             ;
    d_oData2        := NIL
But I am getting this error message:

Code: Select all


Xbase++ version     : Xbase++ (R) Version 2.00.758
Operating system    : Windows 10 10.00 Build 14393
------------------------------------------------------------------------------
oError:args         :
          -> VALTYPE: C VALUE: VARGROUP_mVars_Template3
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: A VALUE: {{"m_sec_num", 259}, {"m_sec_name", 259}, {"m_add_1", 259}, {"m_add_2", 259}, {"m_city", 259}, {"m_state", 259}, {"m_zip", 259}, {"m_phone", 259}, {"m_contact", 259}, {"m_ndefdays", 259}, {"m_acct_num", 259}, {"m_nadvrate", 259}, {"m_acctnum2", 259}, {"aApp[1]", 259}, {"d_lAddmode", 259}, {"d_nTabpage", 259}, {"d_bNextpage", 259}, {"d_bPrevpage", 259}, {"d_cTitle", 259}, {"d_lDisablesave", 259}, {"aApp[10]", 259}, {"d_oMsgbox", 259}, {"d_oStatstatic", 259}, {"d_oStatbar", 259}, {"d_nSaverecord", 259}, {"d_aNtabs", 259}, {"d_aOtabs", 259}, {"d_lSaveneeded", 259}, {"d_oTabpage1", 259}, {"d_oTabstatic1", 259}, {"d_oPagegroup1", 259}, {"d_oSeekkey", 259}, {"d_oBrowse", 259}, {"d_oTabpage2", 259}, {"d_oTabstatic2", 259}, {"d_oPagegroup2", 259}, {"d_oIdent2", 259}, {"d_oData2", 259}}
oError:canDefault   : N
oError:canRetry     : N
oError:canSubstitute: Y
oError:cargo        : NIL
oError:description  : Message must start with letter or underscore following by alphanumerics and underscore
oError:filename     : 
oError:genCode      :        147
oError:operation    : classCreate
oError:osCode       :          0
oError:severity     :          2
oError:subCode      :       2268
oError:subSystem    : BASE
oError:thread       :          3
oError:tries        :          0
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Called from DC_VARGROUP(5658)
Called from TEST1(454)
Called from (B)MAIN(12)
I am having trouble trying to determine what is causing the error. Line 5658 is this line of code:

oVars := ClassCreate( cName,, aIVar )

Re: DCVARGROUP Error

Posted: Sat Dec 17, 2016 7:13 am
by c-tec
Hello, try to remove aApp from the vars
regards
Rudolf

Re: DCVARGROUP Error

Posted: Sat Dec 17, 2016 9:38 am
by rdonnay
It appears that one or more of your memvars is defined as aApp[n].

BTW - If you are working in Xbase++, you may want to use a DataObject() instead of a VARGROUP.

You may recall that I introduced the idea of VARGROUP at my eXpress++ conference in Boise in 2008.
Steffen Pirsig was there and he was very positive about the idea. I think it inspired him to add DataObject() to 2.0.

You would still have the aApp[n] problem but the DataObject() is a better implementation of the idea. This is from the 2.0 documentation:

Description
The DataObject class provides objects with dynamic member and dynamic method support. DataObjects are designed to serve as a universal and lightweight transport mechanism between the different tiers of an application.

Using DataObjects is like using objects of any other class. However, unlike ordinary objects whose state and behavior remains static as declared in the class, members and methods can be added dynamically to a data object after the instance object is created. This is done by by sending :new() to a DataObject class object.


I am adding a new DCVARGROUP20 command to the next eXpress++ build. It is much simpler and does not assign a name to the dynamic class. This was always a problem because the name could not be reused without destroying the class.

Compile and run the below code (under Xbase++ 2.0)

Code: Select all

#INCLUDE "dcdialog.CH"

#xtranslate DCVARGROUP20 [TO] <o> <var1> := <val1> [,<varN> := <valN>] =>  ;
            [<o> :=] DC_VarGroup20({{<(var1)>,<val1>} [,{<(varN)>,<valN>}] })

#Pragma Library("dclipx.lib")

FUNCTION Main()

LOCAL o1, oVars1, oVars2, oVars3

DCVARGROUP20 TO oVars1 ;
   Date := Date(), ;
   Time := Time(), ;
   Job := 'Customer', ;
   Name := 'Steve', ;
   Zip := '12345', ;
   Array := {1,2,3,4,5,6}, ;
   Window := AppDeskTop()

DCVARGROUP20 TO oVars2 ;
   Date := nil, ;
   Time := nil, ;
   Job := 'Invoice', ;
   Name := 'Larry', ;
   Zip := '56789', ;
   Array := {1,2,3,4,5,6,7,8}, ;
   Window := AppDeskTop(), ;
   Path := DC_Path(AppName(.t.)), ;
   Default := Set(_SET_DEFAULT)

DCVARGROUP20 TO oVars3 ;
   Date := nil, ;
   Time := nil

DC_ArrayView({oVars1,oVars2,oVars3})

RETURN nil

* ------------

PROC appsys ; RETURN

* ------------

FUNCTION DC_VarGroup20( aVars )

LOCAL i, oVars := DataObject():new()

FOR i := 1 TO Len(aVars)
  oVars:&(aVars[i,1]) := aVars[i,2]
NEXT

RETURN oVars

Re: DCVARGROUP Error

Posted: Sat Dec 17, 2016 5:55 pm
by Cliff Wiernik
Thanks for the info. I had already found my error and did post a reply to my original post before any replies, but it appears to not have been saved. I will look at the data object and dc_dbrecord(). I starting using DCVARGROUP about 5 years ago.