PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WB19] Can you please help me correct my indirection syntax.
[WB19] Can you please help me correct my indirection syntax.
Iniciado por guest, 29,jun. 2015 14:58 - 6 respuestas
Publicado el 29,junio 2015 - 14:58
I have been studying example code and I'm trying my first attempt at indirection as follows:

m_sGenericQueryName is string
m_sGenericQueryName = "qry_Room_Generic"

When I reference this in a class method:
HExecuteQuery({m_sGenericQueryName},hQueryDefault,iMyProjID)

I get this error message:
"The file, view or query 'qry_Room_Generic' is unknown."

The spelling is certainly correct and matches an existing query.
Can anyone please tell me what I'm doing wrong.

Many thanks,
Michael
Publicado el 29,junio 2015 - 16:41
Hi Michael,

You could declare your variable as a data source, and than work without indirection:

m_sGenericQueryName is Data Source
m_sGenericQueryName = "qry_Room_Generic"

When I reference this in a class method:
HExecuteQuery(m_sGenericQueryName,hQueryDefault,iMyProjID)

Regards,
Bart
Publicado el 29,junio 2015 - 16:46
Thanks Bart. That worked.

But for future reference I'm still curious to know how I should do this using indirection.

Michael
Publicado el 29,junio 2015 - 17:00
Michael,

No indirection is needed in HExecuteQuery statement (in the help file, you can see that the first parameter is a 'Character string (with or without quotes)').

If you need to access the query items, then you must use indirection: {m_sGenericQueryName+".FIELD_NAME_EXAMPLE",indItem}.

Bruno
Publicado el 29,junio 2015 - 22:01
Hi Michael,

in my opinion, it is useless to use indirection in this case.
I use indirection for composing control names, variable names, etc. like:

I.e. If you have controls EDT_Name1, EDT_Name2 and EDT_Name3, you can use indirection to set their value to value i and make their Caption equal to the name:

FOR i = 1 TO 3
{"EDT_Name" + i,indControl} = i
{"EDT_Name" + i,indControl}..Caption = {"EDT_Name" + i,indControl}..Name
END

(not tested)
Publicado el 30,junio 2015 - 03:57
Couple of reasons

1)If the table name is long MyOutOfStateCarDealers it would make coding easyer.

When loding a table:
TableAddLine(Table,MyOutOfStateCarDealers.ID,MyOutOfStateCarDealers.Name) could be reduced dsOSD is data source = "MyOutOfStateCarDealers" TableAddLine(Table,dsOSD.ID,dsOSD.Name)
2) I have 6 data tables with the same strcture M1 thru M6. I want to view them in a table, I use 1 query and 1 table for all 6 data tables.

That is when I would use indirect.

Just my 2 cents

DW
Publicado el 30,junio 2015 - 11:36
Thanks Stefan & DW.

Michael