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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then Statement Help

Status
Not open for further replies.

vbplg

IS-IT--Management
Mar 30, 2003
22
US
I am new to this stuff, so please bear with me. I have a Clrion 5.0b app that has a browse to display a listing of items. Currently the listing is color code somehow automatically. What I need is for the listing to be color coded based off of the following:

If CUS:LoadColor='Green' Then DIS:Round='1'
ELSE
If etc.....


Could someone please help from the basics. I don't know where to start with all of this.
 
If I remember rightly clarion 5 didn't have style support.
If thats the case then I would try and put your code in Browse.SetQueueRecord after the parent call.

You will need to check the colour property for all listbox fields to be colour coded. This creates four fields in the queue per column (_NormalFG, __NormalBG, _SelectedFG, _SelectedBG).

I think its just a case of setting them as per your condition.



 
It might be easier if you use the color tab on the browse actions instead. You might be able to put your condition in there.
 
ChrisH2: STYLES were added to C5, the LRM does not show them in C4

vbplg: Is this browse hand coded, or template generated?
vbplg: If generated, Are you using ABC or Legacy templates?

I can easily provide you details for hand coding this, but it's my guess that you're using templates.

If you're using templates:
Right click on the listbox, and go the format listbox
Hightlight the column that you wish to have color
check the box for Color or for Styles
(note: Styles are more powerful, as they can be used the change the font etc.)
Color (vs. styles) should be used, when there are a LARGE number of colors in your listbox.

Once you're added color or style to the list control
Then save the window and go to the procedure extentions
Highlight the browse, and select the Color or Styles tab.

There you will be able to pair up a color/style with conditions that should use that color style.

You will also be expected to provide a default to be used when all given conditions fail.

 
It's not a listbox. It's all displayed in a queue. I didn't write this another guy did, and he's gone now. They had me take this over because I'm a VB programmer. I know hardly anything about Clarion.
 
I followed everything down until the Highlight the browse and such.
 
I think I know what happening here. If you right click on the listbox, select properties and then the actions tab. If all thats there is two buttons 'Tables' and 'Embeds' then its just a listbox without the control template (without browse template).

Right click on the listbox and select listbox format.
For each item in the listbox you have various properties like color, style etc.
When you check color you must have four colour columns in your queue directly after the column that is checked.

Eg.
If your listbox contained two columns code and name. Both had color checked the queue would be something like this : -

MyQueue QUEUE
Code STRING(10)
Code_NormalFG LONG !Normal Foreground Colour
Code_NormalBG LONG !Normal Background Colour
Code_SelectedFG LONG !Highlighted row Foreground Colour
Code_SelectedBG LONG !Highlighted row Background Colour
Name STRING(30)
Name_NormalFG LONG
Name_NormalBG LONG
Name_SelectedFG LONG
Name_SelectedBG LONG

Somewhere in the program is must be filling the queue in code. Look for ADD(myQueue). All you need to do is set the four colour columns prior to the add assuming that thats how it has been done.
 
No, I must have the control template because I have several options (tabs). Default Behavior, etc.

The list box has several tabs and they are setup under the conditional behavior. The problem as I can see it is that the field CUS:LoadColor is not on the browse/ListBox. What I am trying to do is:
If the CUS:LoadColor='GREEN' then
DIS:Round='1'
Else
If the CUS:LoadColor='RED' then
DIS:Round='2'
Else
etc.

Thanks
 
I need more info as to what it is currently doing and what you are trying to achieve in terms of user interface instead of code.

Also from the actions tab you should have a colors tab and possible a styles tab (maybe not in c5). What have you got set in those tabs?

What table is the listbox using and what is its prefix? DIS: or CUS:?


 
I have the colors tab but no styles tab. The colors tab has the following:

CUS:LOADCOLOR='GREEN'
CUS:LOADCOLOR='RED'
CUS:LOADCOLOR='BLUE'

I need also that if the CUS:LOADCOLOR='GREEN' Then DIS:Round='1', etc....


The listbox is based off of DIS:DISPATCH

This is not user intervention, but something that should happen automatically whenever the listbox is viewed.

Does this help?

Thanks
 
It makes more sense but I'm failing to understand the significance of DIS:round='1'.
Why do you need to set that? How is it used?

Also if you click properties for CUS:LOADCOLOR='GREEN' etc you will see the colours. This is a condition and when the condition is met the colours will be set accordingly.
 
The significance of DIS:Round='????' sets the the priority of the loads going out. 1 being highest priority, 2 is next, then 3, then a 'C' for Customer Pickup. The colors are just a quick glance at the screen for users convenience. The values stored in the CUS:LoadColor are GREEN, RED, BLUE and Black. I tried to change those values and set the numeric values, then went through and set the conditions where needed, but then the program errors out.

The original use of the color coding was for the dispatchers to see if a load was a good load or a bad load basically. We no longer need or use that functionality that way and need this to work this way.

Thanks Again
 
So let me try and understand all of this.

You say the listbox is based of DIS:DISPATCH
So I am assuming that the table DISPATCH? that contains DIS:DISPATCH also contains DIS:Round.

I am assuming DIS:Round is a string if you want to store 'C' for 'Customer Pickup'

Are you trying to change the contents of DIS:Round something like this? :-

CASE CUS:LoadColor
OF 'GREEN'
DIS:Round = '1'
OF 'RED'
DIS:Round = '2'
OF 'BLUE'
DIS:Round = '3'
OF 'BLACK'
DIS:Round = 'C'
END

But why do you need to set it?
So you can display the value '1', '2', 3' or 'C' or even better 'highest priority', 'Customer Pickup' in the listbox?

Or maybe you want to update the table?

Or maybe you are trying to show th colour as green when DIS:Round = 1 and Red when DIS:Round = 2 etc?


Still not sure what you are trying to achieve.
 
DIS:Round is a string

And this is what I am trying to do:

CASE CUS:LoadColor
OF 'GREEN'
DIS:Round = '1'
OF 'RED'
DIS:Round = '2'
OF 'BLUE'
DIS:Round = '3'
OF 'BLACK'
DIS:Round = 'C'
END

The user can change the Round from whatever it is to a 2 which would then represent basically an afternoon load going out.

 
It sounds like you are wanting to set the initial/default value of DIS:ROUND when a record is inserted.
Is this what you are trying to do?
Has the listbox got insert,change and delete buttons?
Does it call a form to update details?
 
Not trying to set the initial or default value at this point, but read the value and set the color according to the value. The user CAN change the value on another form and this should REFRESH then
 
Now I am confused.

When you say set the colour. What exactly do you mean by this? Colour the text or background of one or more columns in the list box per row?

Are you trying to colour a column green when DIS:Round = '1' and Red when DIS:Round = '2' etc?

 
Color the text for each row. The color for each row would be set based on the value in CUS:LoadColor. The value of DIS:Round needs to be set based on the color value of CUS:LoadColor, but the user needs to be able to change this per row to a 2.

If CUS:LoadColor=GREEN then the DIS:Round Column needs to show a 1, if CUS:LoadColor=RED then show a 2, etc...


Sorry if I am confusing you, but I really don't know the terinology for Clarion stuff. I am trying to learn because I like the way I can easily do some things in it better than in VB.
 
Ah, ok. I think I see what you are trying to do.
First I would need to know how CUST:LoadColor is set.
I am guessing that it's an column on the customer table.
Does the user select the customer on the form and the listbox is filtered for that customer.
Or is it passed into the form as a parameter.
Or is it a related table that is joined in the table schematic and can changed per row
 
It is a related table but I don't see a join. It has to be joined somewhere. The user sets the Customer information on another form and that is stored in the Cus:Customer table. When a new load is entered, the Customer information is pulled from the Customer table and then inserted into the DIS:Dispatch table.

Does this help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top