Pointers and dynamic arrays - not for the faint hearted - very invloved 
Author Message
 Pointers and dynamic arrays - not for the faint hearted - very invloved

I am trying to use a 3rd party DLL, the 3rd party has provided sample code
for delphi and
for C. However I am struggling to get the type definitions correct for
clarion.

In C the following is defined.
1)       int (FAR Pascal _export *UserSelection)(HWND, struct StrField huge
*,int);
                           /* a pointer to the function returning the user
                           selected field through the structure pointer.
                           Your application returns the chosen field through
                           the first parameter.  The second argument
indicates
                           the sort field number. If it is equal to zero,
                           it means that the field being sought is not a
sort
                           field. The function returns a TRUE value if
                           successful.
i.e. a pointer to a procedure/function this is difined within a structure -
converted to

GROUP,TYPE
i have used &CSTRING - assuming i can point to the name of a function name -
any ideas?
typedef int (FAR PASCAL _export *USER_SELECTION)(HWND, struct StrField huge
*,int);
typedef int (FAR PASCAL _export *VERIFY_FIELD)(HWND, struct StrField huge
*,int);
The above two lines are also declared - what do they mean?
Obviously this is compiling OK just now - can go any further to test my
theory because of the

next problem.

3)
struct StrField {                 // define each field
         int source;              // source of field data:
application,calculation,system, constant etc

         char name[NAME_WIDTH+2]; // field name
         int FileId;              // an optional id that may be defined by
the calling application
         int FieldId;             // another optional id that may be defined
by the calling application
         int type;                // numeric/alphanumeric/logical/date
         int width;               // field data width as stored in your
database
         int DecPlaces;           // decimal places for numeric fields
 ...cut...

Quote:
}

The above strucure i have converted to a GROUP,TYPE - no problem.

However the next structure is as follows :-

struct StrRep {
       char file[299];   // form file name

       struct StrField huge *field; // (OUTPUT) pointer to an array of
fields used by the
                                    // form
       int TotalFields;     // (OUTPUT) Number of fields in the 'field'
array.

       struct StrField huge *SortField; // (OUTPUT) pointer to an array of
fields used for
                                        // sorting.
       int TotalSortFields; // (OUTPUT) Number of fields in the 'SortField'
array.

Quote:
}

As you can see this uses the previous structure in a dynamic array.
Delphi does this in two stages - type dynamic array of Strfield :-
AStrField  = array [0..0] of StrField
Then a pointer TYPE
PStrField = ^AStrField
the above is then declared as TYPE

   StrRep = record
       FileName: array [0..298] of char;   { form file name}

       field: PStrField;    { (OUTPUT) pointer to an array of fields used by
the
                             form.}
       TotalFields: Integer;{ (OUTPUT) Number of fields in the 'field'
array. }

       SortField: PStrField; { (OUTPUT) pointer to an array of fields used
for
                             sorting.}
       TotalSortFields: Integer; { (OUTPUT) Number of fields in the
'SortField' array. }

end

So my question how do i do this in Clarion - particularly the dynamic array
bit.
I am not particularly good with reference variables so could you please
explain this in an idiot

proof manner.
Also i will need to know how to create this new structure and access it
individual elements.
Many thanks in advance.
Amanda Weddell.



Mon, 22 Mar 2004 17:08:10 GMT  
 Pointers and dynamic arrays - not for the faint hearted - very invloved
int (FAR PASCAL _export *UserSelection)(HWND, struct StrField huge
*,int);
would be

UserSelection(unsigned,long,signed),signed,proc,pascal,name('UserSelection')
you'll need to work out the pointer to the struct - use cw address function.
Jim Kane


Quote:
> I am trying to use a 3rd party DLL, the 3rd party has provided sample code
> for delphi and
> for C. However I am struggling to get the type definitions correct for
> clarion.

> In C the following is defined.
> 1)       int (FAR PASCAL _export *UserSelection)(HWND, struct StrField
huge
> *,int);
>                            /* a pointer to the function returning the user
>                            selected field through the structure pointer.
>                            Your application returns the chosen field
through
>                            the first parameter.  The second argument
> indicates
>                            the sort field number. If it is equal to zero,
>                            it means that the field being sought is not a
> sort
>                            field. The function returns a TRUE value if
>                            successful.
> i.e. a pointer to a procedure/function this is difined within a
structure -
> converted to

> GROUP,TYPE
> i have used &CSTRING - assuming i can point to the name of a function
name -
> any ideas?
> typedef int (FAR PASCAL _export *USER_SELECTION)(HWND, struct StrField
huge
> *,int);
> typedef int (FAR PASCAL _export *VERIFY_FIELD)(HWND, struct StrField huge
> *,int);
> The above two lines are also declared - what do they mean?
> Obviously this is compiling OK just now - can go any further to test my
> theory because of the

> next problem.

> 3)
> struct StrField {                 // define each field
>          int source;              // source of field data:
> application,calculation,system, constant etc

>          char name[NAME_WIDTH+2]; // field name
>          int FileId;              // an optional id that may be defined by
> the calling application
>          int FieldId;             // another optional id that may be
defined
> by the calling application
>          int type;                // numeric/alphanumeric/logical/date
>          int width;               // field data width as stored in your
> database
>          int DecPlaces;           // decimal places for numeric fields
>  ...cut...
> }
> The above strucure i have converted to a GROUP,TYPE - no problem.

> However the next structure is as follows :-

> struct StrRep {
>        char file[299];   // form file name

>        struct StrField huge *field; // (OUTPUT) pointer to an array of
> fields used by the
>                                     // form
>        int TotalFields;     // (OUTPUT) Number of fields in the 'field'
> array.

>        struct StrField huge *SortField; // (OUTPUT) pointer to an array of
> fields used for
>                                         // sorting.
>        int TotalSortFields; // (OUTPUT) Number of fields in the
'SortField'
> array.
> }
> As you can see this uses the previous structure in a dynamic array.
> Delphi does this in two stages - type dynamic array of Strfield :-
> AStrField  = array [0..0] of StrField
> Then a pointer TYPE
> PStrField = ^AStrField
> the above is then declared as TYPE

>    StrRep = record
>        FileName: array [0..298] of char;   { form file name}

>        field: PStrField;    { (OUTPUT) pointer to an array of fields used
by
> the
>                              form.}
>        TotalFields: Integer;{ (OUTPUT) Number of fields in the 'field'
> array. }

>        SortField: PStrField; { (OUTPUT) pointer to an array of fields used
> for
>                              sorting.}
>        TotalSortFields: Integer; { (OUTPUT) Number of fields in the
> 'SortField' array. }

> end

> So my question how do i do this in Clarion - particularly the dynamic
array
> bit.
> I am not particularly good with reference variables so could you please
> explain this in an idiot

> proof manner.
> Also i will need to know how to create this new structure and access it
> individual elements.
> Many thanks in advance.
> Amanda Weddell.



Tue, 23 Mar 2004 08:11:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. allocatable array *not* equivalent to dynamic allocation?

2. pointer to pointer to field / dynamic field

3. A pointer to an array of pointers

4. A couple of simple pointer questions (targets, arrays of pointers)

5. Dynamic web pages! not Dynamic HTML

6. Ada83 array of pointers to unconstrained array type

7. DEALLOCATE of a derived type array containing pointer array components

8. Light Hearted Input

9. java array return value not array in tcl

10. looking for tool and pointers to design 3D and dynamic web pages

11. Dynamic call using procedure pointer

12. Pointers and Dynamic Allocation

 

 
Powered by phpBB® Forum Software