Page 1 of 1

Error at STRUCTURE/ENDSTRUCTURE!

Posted: Fri Jan 16, 2009 11:02 pm
by JC
Dear Antonio and friends,

I have tried to create a structure with STRUCTURE/ENDSTRUCTURE but i get an error

Code: Select all

   STRUCT oQueryAlias

          //type:STRING,NUMERIC,LOGICAL,DATE,DATETIME,CODEBLOCK,ARRAY,OBJECT,HASH>

          MEMBER cQueryAlias   AS STRING INIT ""
          MEMBER cColunaFiltro AS STRING INIT ""
          MEMBER aFieldSql     AS ARRAY  INIT {}
          MEMBER aWhereSql     AS ARRAY  INIT {}
          MEMBER aGroupSql     AS ARRAY  INIT {}
          MEMBER aOrderSql     AS ARRAY  INIT {}
          MEMBER nLimitSql     AS LONG   INIT 0
          MEMBER nOffSetSql    AS LONG   INIT 0

   ENDSTRUCT
The error:

Code: Select all

Application
===========
   Path and name: C:\test\app.EXE (32 bits)
   Size: 1,961,984 bytes
   Time from start: 0 hours 0 mins 6 secs 
   Error occurred at: 16/01/2009, 19:31:26
   Error description: Error BASE/1106  Argument error: REPLICATE
   Args:
     [   1] = C    
     [   2] = U   

Stack Calls
===========
   Called from:  => REPLICATE(0)
   Called from: .\source\classes\TStruct.PRG => TSTRUCT:ADDMEMBER(0)
   Called from: C:\extras\xbrowse.prg => TXBROWSE:SETOBJQUERY(6233)
   Called from: C:\extras\xbrowse.prg => TXBROWSE:NEW(610)
   Called from: C:\modulos\Cadastros\Cadastro_Empresa.prg => SELECIONAEMPRESA(1411)
   Called from: C:\modulos\Cadastros\Cadastro_UsuariosSistema.prg => LOGINSISTEMA(632)
   Called from: C:\RepositorioLocal\main.prg => (b)MAIN(214)
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(0)
   Called from: C:\RepositorioLocal\main.prg => MAIN(214)

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Fri Jan 16, 2009 11:18 pm
by toninhofwi
HI,

If you are talking about STRUCTURE/ENDSTRUCTURE created by me in [x]Harbour, you can do this:

---cut---
#include "hbstruct.ch"

procedure main()

local oStru

STRUCTURE oStru

MEMBER c1, c2, c3, c4 AS STRING

MEMBER c5 AS STRING INIT "my structure"

MEMBER n1, n2, n3, n4 AS NUMERIC

MEMBER b1 AS CODEBLOCK INIT { || QOut( "Hello!!!" ) }

MEMBER a1, a2, a3 AS ARRAY

MEMBER d1 AS DATE INIT Date()

ENDSTRUCTURE

? ValToPrg( oStru:c1 )
? ValToPrg( oStru:c2 )
? ValToPrg( oStru:c3 )
? ValToPrg( oStru:c4 )
? ValToPrg( oStru:c5 )
? ValToPrg( oStru:b1 )
? ValToPrg( oStru:d1 )

Eval( oStru:b1 )
?

return
---cut---

regards,

Toninho.

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Fri Jan 16, 2009 11:24 pm
by JC
Ok, but... and the error?

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Sat Jan 17, 2009 11:56 am
by toninhofwi
JC wrote:Ok, but... and the error?
Hi JC,

IMO you are mixing things, If you need FWH C language structures support commmands, you need "Struct.CH". Please see how use it in fwh\source\TTRAY.PRG

Regards,

Toninho.

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Sat Jan 17, 2009 10:41 pm
by JC
This file "Struct.ch" already included!
But, the error still again!

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Sun Jan 18, 2009 1:25 pm
by Euclides
Julio,
if you do search in the compilation warnings, you will find:
Warning W0001 Ambiguous reference: 'ARRAY'
if you remove the ARRAY definitions from the STRUCT it will compile and run OK.
How to use ARRAY elements inside STRUC definition is an other problem :-)
Regards, Euclides

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Mon Jan 19, 2009 1:18 pm
by JC
Please, see the error.log!
The error is other!
Not works!

With data type array, work fine! But, when I try to use a STRING MEMBER type... this get me a REPLICATE error! Into error.log, this is detailed!

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Mon Jan 19, 2009 2:31 pm
by Enrico Maria Giordano
Please post a reduced and self-contained sample of the problem.

EMG

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Mon Jan 19, 2009 2:59 pm
by JC
Enrico,

This is the link with the self-example!
http://rapidshare.com/files/186026366/Struct.zip.html

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Mon Jan 19, 2009 10:37 pm
by Enrico Maria Giordano
From where did you get that ARRAY can be used as STRUCT type?

EMG

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Mon Jan 19, 2009 11:43 pm
by JC
Enrico,

From the HBStruct.ch into xharbour\include\

Code: Select all

#ifndef _H_STRUCTURE
#define _H_STRUCTURE

#xcommand STRUCTURE <hStruct> => <hStruct> := HSetCaseMatch( Hash(), .F. ) ; #undef _TSTRUCT_ ; #define _TSTRUCT_ <hStruct>
#xcommand STRUC <hStruct> => <hStruct> := HSetCaseMatch( Hash(), .F.) ; #undef _TSTRUCT_ ; #define _TSTRUCT_ <hStruct>

#xcommand MEMBER <cName, ...> ;
             [ AS <type:STRING,NUMERIC,LOGICAL,DATE,DATETIME,CODEBLOCK,ARRAY,OBJECT,HASH> ] ;
             [ INIT <uValue> ]          ;
          => ;
          HashAddMember( {<(cName)>}, <(type)>, <uValue>, _TSTRUCT_ )

#xcommand ENDSTRUCTURE => HSetAutoAdd( _TSTRUCT_, .f. )
#xcommand ENDSTRUC => HSetAutoAdd( _TSTRUCT_, .f. )

#translate DESTROY STRUCTURE <hStruct> => <hStruct> := nil

#endif

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Tue Jan 20, 2009 10:15 am
by Enrico Maria Giordano
Right. Sorry, I don't know why it doesn't work. :-(

EMG

Re: Error at STRUCTURE/ENDSTRUCTURE!

Posted: Tue Jan 20, 2009 11:50 am
by JC
Enrico Maria Giordano wrote:Right. Sorry, I don't know why it doesn't work. :-(

EMG
Enrico,

Ok! Thanks for you attention! Maybe Antonio can help me with this :(