`{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.

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.

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

Just needed to do this again, the example from @MarkGoldberg works, but only if used as PROCEDURE parameter I can access the fields (ex1)- the one from @greenslk using LIKE instead of GROUP also allows it to be used as local variable with access to the fields (ex2)

FILE:

Dummy           FILE,DRIVER('TOPSPEED'),NAME('data\Dummy.dat'),PRE(DUM),CREATE
Dum_KeyNr         KEY(DUM:Nummer),PRIMARY,NOCASE,OPT
record            RECORD
Nummer              STRING(1)
                  END
                END

EX1:

Record:Dummy GROUP(DUM:Record),TYPE,PRE(R:DUM)
END

PROC_WORKS PROCEDURE(*Record:Dummy dumdum)
    CODE
        dumdum.Nummer = 1;

PROC_NO_WORKS PROCEDURE()
!dumdum Record:Dummy ! Does not compile
dumdum LIKE(Record:Dummy)
!or
!dumdum GROUP(Record:Dummy),PRE(dd)
!END
    CODE
        dumdum.Nummer = 1; ! FIELD NOT FOUND

EX2:

Record:Dummy LIKE(DUM:Record),TYPE

PROC_WORKS PROCEDURE()
!dumdum Record:Dummy ! Does not compile sadly
dumdum LIKE(Record:Dummy)
    CODE
        dumdum.Nummer = 1;

That's really weird - I was able to reproduce that unexpected behavior using 11.0.13244

FWIW, you could re-write PROC_NO_WORKS as

PROC_NO_WORKS PROCEDURE()
dumdum GROUP(Dummy.Record),PRE(DD);END  ! compiles
!dumdum GROUP(Dummy:Record),PRE(DD);END ! compiles
!dumdum GROUP(DUM:Record),PRE(DD);END   ! compiles

!dumdum LIKE(Dummy.Record)  ! compiles
!dumdum LIKE(Dummy:Record)  ! compiles
!dumdum LIKE(DUM:Record)    ! compiles
    CODE
        dumdum.Nummer = 1; ! FIELD NOT FOUND

The purpose of the ,TYPE was to be able to pass a record as a parameter and have access to field(s). But if the File Dummy is in scope then the above LIKE compiles just fine

Replacing the PREFIX with PRE(RDUM) allows it to compile
my guess is the the : exposed the odd behavior

Record:Dummy GROUP(DUM:Record),TYPE,PRE(RDUM)
END

The support of parameters of *GROUP type (both generic and having a named type) is very partial. The compiler produces different errors for parameters of such types and their usage. Fixes for known me issues related to parameters of GROUP types were sent to SV several months ago.