ulisses
ulisses

Reputation: 1581

How to insert label in the info with %n - field's values?

I have to stamp to video a simple string, with label and field's values.

I have this code:

 info (strFmt (" @SYS334481: %1 , @SYS4569: %2 " , myTable.AliasUser, myTable.Day) );

I have an output looklike this :

Alias user , Day

I haven't the field's values. I also tried to use this way , but I have a syntax error:

info (strFmt (" "@SYS334481": %1 , "@SYS4569": %2 " , myTable.AliasUser, myTable.Day ));

What is the correct way?

Upvotes: 3

Views: 6528

Answers (2)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

While making a specific label will work, I would prefer the simpler:

info(strFmt('%1: %2, %3: %4', fieldPname(myTable,AliasUser), myTable.AliasUser, fieldPname(myTable,Day), myTable.Day));

I often use this technique with setPrefix instead:

setPrefix(strFmt('%1: %2, %3: %4', fieldPname(myTable,AliasUser), myTable.AliasUser, fieldPname(myTable,Day), myTable.Day));
info("More specific message here");

If only one field use the PrefixField macro:

setPrefix(#PrefixField(myTable,AliasUser));
info("More specific message here");

or the PrefixFieldValue sister:

setPrefix(#PrefixField(myTable, AliasUser, myTable.AliasUser+':'));
info("More specific message here");

Upvotes: 4

ulisses
ulisses

Reputation: 1581

I found a possible solution, It's to creat a new label with %n inside.

I create a label looklike :

@xx00000 = "Alias User: %1 - Day: %2"

I used this syntax:

info (strFmt ("@xx00000" , myTable.AliasUser, myTable.Day) );

I don't know if It's the better solution but It works so well.

If do you have any other solution, write well, will be more information, thanks this community.

enjoy!

Upvotes: 3

Related Questions