`{File}.Record` as PROCEDURE parameter, but how?

According to the help:
afbeelding
See: record_declare_record_structure_.htm [Clarion Community Help]
One can pass a RECORD as parameter - but how? I tried *{File}.Record and {File}.Record but the IDE doesn’t save the change - so I guess it won’t allow me

In my case {FILE} is the label of the customers file - TOPSPEED

If I do just *{FILE} I get Label in prototype not defined

I’m just getting back into Clarion so going by memory here…

In BEFORE Global Data, create a TYPE of the Record definition(s) you need

typRec:Table LIKE(PRE:Record),TYPE

PRE: is the prefix of the table/record you need

calling procedure

DATA
myRec typRec:Table

CODE

SomeProc(myRec)

called procedure

SomeProc PROCEDURE(*typeRec:Table pRec)
CODE

! pRec:Field1
! pRec:Field2

In BEFORE Global Data it throws Field not found: RECORD - if I move it to Global Data it does compile but it doesn’t have any fields, at least Intellisense doesn’t show fields - if i use a GROUP instead of LIKE intellisense does show fields, but during compilation it throws an error the field is not found, so:

typeRec:Table GROUP(FILE:Record),TYPE
END

Also using the PRE doesn’t compile - need to use the full file label

ok…

Lets say you have a file
zEventLog PRE(zEVT)
Record

END

AFTER FILE DECLARATIONS

typRec:EventLog GROUP(),TYPE
LIKE(zEVT:Record)
END

Local Data

myRec LIKE(typRec:EventLog)

CODE

!.. set myRec from record
myRec = zEVT:Record

!.. call your proc
TestProc(myRec)

(*File pFilename) - Post must be 20 chars long min.

1 Like

Tried that, as mentioned getting an error that the label is not defined

I’ll check tomorrow if that works

I’ve done (PRE:Record pRecord) before. But you have to make sure that the file is always generated so that the prototype can see it. The chicken has to be hatched before the egg is laid, or something like that.

in cpxml.clw/.inc its used here

!===  FILE  ========
FileToDOM   PROCEDURE(*file f, <string root>,<string label>, DOMStyle style=DOMStyle:ADO_26, byte removePrefix = true,<MapQueue nameMap>)

but in abFile its defined simply as File and not *File.

1 Like

And how can I be sure of that? I can use the FILE inside the procedure without issues - it’s just the PROTOTYPE giving the error

don’t include { } inside of the prototype
Please show us your actual code, so we can help you

Yes you can pass the record buffer as a group, or better yet as a typed group

I like to write:

gtRec_ADJ   GROUP(ADJ:Record),TYPE,PRE(gtADJ); END

I use dot notation on the group - I don’t use it’s prefix
But it’s required to add a prefix - to replace the original prefix in the file
Keys need to have a prefix so nearly all files need to have a prefix

so with that data type I can write:

SomeProc PROCEDURE(*gtREC_ADJ xADJ)
  CODE
  xADJ.ID = 42  ! point being I have access to all of the fields in the file

I can call :

SomeProc( ADJ:Record              )
SomeProc( Adjustment.Record       )
SomeProc( Adjustment{PROP:Record} ) ! this might work, I haven't tested it

This makes it compile, sort of - it seems all type information is lost, so it no longer shows the fields with autocomplete

EDIT: Error was due to a missing variable, oops