string to code block

This forum is for eXpress++ general support.
Post Reply
Message
Author
Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

string to code block

#1 Post by Andy Edward »

Hi everyone,

Is there a way to make a string such as

myString := '{||oDataSetGENERIC:FieldGet("' + variableWithEverChangingValue + '")}'

into a code block so I can put this into a DCFINDADDCOL DATA parameter like so

DCFINDADDCOL DATA myString HEADER 'PERIOD' TO COL_TABLE ??

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: string to code block

#2 Post by rdonnay »

Code: Select all

myString := '{||oDataSetGENERIC:FieldGet("' + variableWithEverChangingValue + '")}'

bBlock := &myString
The eXpress train is coming - and it has more cars.

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: string to code block

#3 Post by Andy Edward »

rdonnay wrote:

Code: Select all

myString := '{||oDataSetGENERIC:FieldGet("' + variableWithEverChangingValue + '")}'

bBlock := &myString
Hi Roger,

Thanks for the reply.

Using your code does indeed made it into a code block but also returned the value of the code block. So the values inside the field (AMOUNT in this case) is always the value of the first row of the DataSet

Please take a look at the image attached for a better view of the problem. Hardcoded field is how the field finally should look like.

Code: Select all

xFieldName := 'AMOUNT' 
myString := '{||oDataSetGENERIC:FieldGet("' + xFieldName + '")}'
bBlock := &myString

DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet('PERIOD')} HEADER 'FIELD1' TO COL_TABLE
DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet('BATNO')} HEADER 'FIELD2' TO COL_TABLE
DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet('VOUCH')} HEADER 'FIELD3' TO COL_TABLE
DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet('ACNO')} HEADER 'FIELD4' TO COL_TABLE
DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet('DESC')} HEADER 'FIELD5' TO COL_TABLE
DCFINDADDCOL DATA {||oDataSetGENERIC:FieldGet(xFieldName)} HEADER 'Hardcoded' TO COL_TABLE
DCFINDADDCOL DATA bBlock HEADER 'From Forum' TO COL_TABLE

@1,1 DCFINDBROWSE FIELDS COL_TABLE DATA oDataSetGENERIC SIZE x1024+100,y1024+18 AUTOSEEK TITLE XTITLE FONT cSAYFONT TO xSELECT
May I ask kindly for your advice on this matter??
Attachments
Untitled-1.gif
Untitled-1.gif (10.06 KiB) Viewed 8312 times

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: string to code block

#4 Post by rdonnay »

Andy -

I don't know why yours doesn't work. It looks right to me.
Compile and run the below code.
It works as expected.
Use CUSTOMER.DBF from \exp19\data

Roger

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main

LOCAL GetList[0], GetOptions, oBrowse, cFieldName, cField, bField

USE CUSTOMER

@ 0,0 DCBROWSE oBrowse ALIAS 'CUSTOMER' SIZE 10,20 FIT

DCBROWSECOL DATA {||CUSTOMER->bill_name} HEADER 'Name 1' WIDTH 15 PARENT oBrowse

cFieldName := 'bill_name'
cField := '{||CUSTOMER->' + cFieldName + '}'
bField := &cField

DCBROWSECOL DATA bField HEADER 'Name 2' WIDTH 15 PARENT oBrowse

DCREAD GUI FIT TITLE 'Macro test'

RETURN nil

PROC appsys ; return
The eXpress train is coming - and it has more cars.

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: string to code block

#5 Post by Andy Edward »

Just an update, that the problem went away after a system restart. :doh:

Post Reply