Forum Post: Re: Convert String Value Into Expression

  • Thread starter Thread starter savoine
  • Start date Start date
Status
Not open for further replies.
S

savoine

Guest
DEF TEMP-TABLE tt-report FIELD i-id AS INT FIELD i-line AS INT FIELD c-text AS CHAR. DEF TEMP-TABLE tt-client FIELD c-name AS CHAR FIELD c-address AS CHAR FIELD c-cep AS CHAR FIELD i-type AS INT. DEF TEMP-TABLE tt-param FIELD c-from AS CHAR FIELD c-to AS CHAR. DEF VAR i-number AS INTEGER NO-UNDO. ASSIGN i-number = 12345. CREATE tt-report. ASSIGN tt-report.i-id = 1 tt-report.i-line = 1 tt-report.c-text = "CLIENT: #client#, Number: #number#, CEP: #cep#". CREATE tt-report. ASSIGN tt-report.i-id = 1 tt-report.i-line = 2 tt-report.c-text = "Type for this client is #type#". /***************************************************************************/ CREATE tt-client. ASSIGN tt-client.c-name = 'Eduardo' tt-client.c-address = 'Av. Brasil, 235' tt-client.c-cep = '15500000' tt-client.i-type = 1. /***************************************************************************/ CREATE tt-param. ASSIGN tt-param.c-from = "#client#" tt-param.c-to = "tt-client.c-name". CREATE tt-param. ASSIGN tt-param.c-from = "#number#" tt-param.c-to = "i-number". CREATE tt-param. ASSIGN tt-param.c-from = "#cep#" tt-param.c-to = "STRING(tt-client.c-cep,'99.999-999')". CREATE tt-param. ASSIGN tt-param.c-from = "#type#" tt-param.c-to = "IF tt-client.i-type = 1 THEN 'INFORMATION1' ELSE 'INFORMATION2'". /**************************************************************************/ /**** WHERE tt-report - Rows of a report table. tt-client - Data from my client. tt-param - Table from/to the variables useds into report table rows. i-number - any variable In this example I have only one client table but the report may be linked to other tables. ****/ FIND FIRST tt-client NO-ERROR. FOR EACH tt-report WHERE tt-report.i-id = 1: FOR EACH tt-param: /* REPLACE values c-from to c-to */ END. /* DISPLAY RESULT */ END. /* I hope it has become clear my intention */

Continue reading...
 
Status
Not open for further replies.
Back
Top