Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new to pb, which would be the best way to do this?

Status
Not open for further replies.

chedderslam

Programmer
Jun 16, 2008
24
US
I am brand new to powerbuilder.

One of my first tasks at my new job is to update some text in an object that is part of an object that generates pdfs.

Currently, it is a plain text control(? is that the proper term?). They need it to display text based upon conditions, either one string of text or the other.

I think there are two ways to do this, and I'm not sure which will work or if it is the proper way to do this...

First, I can go into the text property of the control and add an expression like this:
if( var1 = '5' and var2 = 'something', 'print this string', 'print this other string' )

After adding the expression, the box next to the text attributes turns green, but the text in the box under "Text" in the property window is still there. Do I need to delete this or what? Will the expression do what I want it to do?

The other option is to do a computed field, using the expression I listed above.

So, which should I use?

Thank you.
 
So, you're doing this on a DataWindow, I assume? And var1 and var2 are either ComputedFields or Columns? If so, then use the expression you listed in a ComputedField, and it should do what you're looking for...

However, a StaticText control is sometimes useful to use the way you're using it, simply because whatever is listed in the Text property will show during design, and then during runtime, the expression is evaluated. Whereas, if you're using a computed field, the expression is what will show for the control on the painter.

Unless someone has some substantial reasons for one way or the other, I'd lean towards the ComputedField over the StaticText.
 
The green is an indicator of the existence of an expression. The text will be changed during run time based on the expression.

Matt

"Nature forges everything on the anvil of time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top