Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) LE background color different depending on Value (Read 3001 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
LE background color different depending on Value
May 28th, 2009 at 2:02pm
Print Post Print Post  
I have searched the archives, but cannot find specifically what I'm wanting to do.  When building a Sales Order, using subform SOLines, I want to change the ItemQty background color if the quantity is a negative number.  If the ItemQty is a positive number, then 'no background color change'.  But I need each record to retain its programmed background color in ItemQty when it switches to TableView for the PrintForm.  The color difference for negative value is to aid the delivery drivers in seeing different things on the delivery ticket, which is printed with a PrintForm command.

Is it possible to have multiple subform SOLines records on a Parent OrderForm where the ItemQty LE background color can be different on each saved record (so that each line item retains its different color, both on the screen and when printed?

What's happening with the following code is:
-ItemQty:ShockednElementExit is changing ItemQty background to yellow if the value is negative
-this record is saved.
-Next record is created, and ItemQty background color is reset to white, FOR THE NEW RECORD, pending the subsequent value that is entered in ItemQty.  

But the background color isn't being retained differently for each record, as desired.

ItemQty:ShockednElementChange
#Include "sbasic_include.sbas"


If @ToNumber(ItemQty) < 0
 {
   FormAttribute("", "ItemQty", ATTR_ID_BACK_RGB_COLOR, "252 252 0")
   FormAttribute("", "ItemQty", ATTR_ID_TEXT_RGB_COLOR, "252 0 0")
   ForceRedraw()
 }
so far so good, but when the next record is created, and the following code executed (to insure that ItemQty background on new record begins as white, it reverts the background colors of the previously saved records, too.

Next record, on ItemNum:ShockednElementEntry
{
 FormAttribute("", "ItemQty", ATTR_ID_BACK_RGB_COLOR, "255 255 255")
 FormAttribute("", "ItemQty", ATTR_ID_TEXT_RGB_COLOR, "0 0 0")
 ForceRedraw()
}


  

Larry
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: LE background color different depending on Val
Reply #1 - May 28th, 2009 at 2:16pm
Print Post Print Post  
You need to do Table View differently since more than one record is visible at one time.  Use the On Draw event. See the example on page 20 of the Sesame Programming Guide.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #2 - May 28th, 2009 at 9:51pm
Print Post Print Post  
Thank you, Hammer.   I'll look at it this evening.

I used the following code in ItemQty:ShockednDraw , and Sesame didn't like it at all.  When I loaded my app and clicked on Orders from AppMenu, it showed a Search/Update Orders tab on the bottom of the Sesame screen, but wouldn't show the screen itself.  Sesame was then unresponsive to input, although the Windows task manager showed CPU utilization at 50+%, and Sesame memory cannibalization was steadily climbing from 60k to 500k.  I tried this several times, and a couple of those times (but not all of those times) I got a little message line in bottom left corner of Sesame that said compiling ItemQty (14), but then no more activity.

Going back into Sesame Designer and commenting out this piece of code fixed the stall.   What have I done wrong here?

#Include "sbasic_include.sbas"

If @FormViewType("SOLines") = FORM_VIEW_TYPE_TABLE
  {

    If @ToNumber(ItemQty) < 0
     {
       RGBColor(ItemQty, 255, 0, 0, 255, 255, 0)
     }
       else
         {
           RGBColor(ItemQty, 0, 0, 0, 255, 255, 255)
         }
  }
« Last Edit: May 29th, 2009 at 3:24am by lksseven »  

Larry
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: LE background color different depending on Val
Reply #3 - May 29th, 2009 at 2:40pm
Print Post Print Post  
The programming that you removed will not cause the issue by itself. Do you have other programming running at the time that is bringing up message boxes or that may be causing your form to redraw?
  
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #4 - May 29th, 2009 at 3:28pm
Print Post Print Post  
Ben,

I'll try to track it down.  I also had a piece of code that changed a LE background color on element entry and back again on element exit (when in Form view), that was causing runtime errors when the SOLines subform is programmatically changed to a Tableview for printing purposes.  I just commented that code out remotely and am waiting for the office to let me know if it's fixed.

OK, just heard from the office - it's fixed.  So something about changing an LE color that Tableview doesn't like, at least in my config.
  

Larry
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: LE background color different depending on Val
Reply #5 - May 29th, 2009 at 5:44pm
Print Post Print Post  
Changing colors should not be causing any runtime errors. What errors were you seeing?
  
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #6 - May 29th, 2009 at 6:50pm
Print Post Print Post  
Ben,

I eliminated all Orders and SOLines code that spoke of 'redrawing' (only a couple of instances existed).  The app will tolerate the first two of the following conditions in the LaunchPad element, but will not allow the Orders screen to open up if I have any code in ItemQty that speaks of changing colors (the third piece of code following), regardless of if it's OnElementChange or OnDraw:

//this piece runs fine
Launchpad::OnElementEntry
#Include "sbasic_include.sbas"

If @Mode() < 2 and @FormViewType("SOLines") = FORM_VIEW_TYPE_FORM
     {
         RGBColor(Launchpad, -1, -1, -1, 255, 255, 0)
       }

//this piece runs fine
Launchpad::OnElementExit
#Include "sbasic_include.sbas"

If @Mode() < 2 and @FormViewType("SOLines") = FORM_VIEW_TYPE_FORM
     {
         RGBColor(Launchpad, -1, -1, -1, 229, 229, 229)
       }

//this piece locks up Sesame and won't let Order screen become visible
ItemQty::OnElementChange

#Include "sbasic_include.sbas"

If @Mode() < 2 and @FormViewType("SOLines") = FORM_VIEW_TYPE_FORM
 {
   If @ToNumber(ItemQty) < 0
     {
       RGBColor(ItemQty, -1, -1, -1, 255, 255, 0)
     }
       else
         {
           RGBColor(ItemQty, -1, -1, -1, 255, 255, 255)
         }
 }
  

Larry
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: LE background color different depending on Val
Reply #7 - May 29th, 2009 at 7:31pm
Print Post Print Post  
lksseven,

Are you getting an SBasic compilation error message before it appears to freeze up on you? If you have a compilation error in your programming, the On Draw event may end up getting triggered and running continuously.

Always be sure to test your programming by using the Test => Test Program feature in the Program Editor.
  
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #8 - May 29th, 2009 at 9:53pm
Print Post Print Post  
Ben,

It tests with no errors in the Program Editor.

No SBasic compilation error message.  I click on Orders in the Main Application screen, and the Search/Update Orders tab appears at the bottom of the Sesame screen, but behind the Main Application Menu screen, and there it sits, consuming 52% of the CPU and ever increasing RAM.  I have to kill it from Task Manager.

It doesn't have to be an OnDraw event.  That piece of code will have the same effect if it's an OnElementChange event.  

Question:  If there are multiple SOLines records in this set, do I have to execute a Loop through the records to determine the value of ItemQty in each record?
« Last Edit: May 30th, 2009 at 2:23pm by lksseven »  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #9 - May 30th, 2009 at 2:45pm
Print Post Print Post  
Update:

I restored code for ItemQty back to working version, and then put the following code into ItemUoM::OnDraw  (no conditional value, just a simple 'if it's a table and in Add mode, then make background color yellow, else make bg color white'.   But Sesame screen froze (with lower left message Compiling: ItemUoM (14) .  Had to kill it with Taskmanager.

#Include "sbasic_include.sbas"

If @Mode() = 0 and @FormViewType("SOLines") = FORM_VIEW_TYPE_TABLE
 {
   RGBColor(ItemUoM, -1, -1, -1, 255, 255, 0)
 }
   else
         {
           RGBColor(ItemUoM, -1, -1, -1, 255, 255, 255)
         }
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #10 - May 30th, 2009 at 3:50pm
Print Post Print Post  
Update:   

Just for grins, I put the following code in an LE on the parent Orders form.  It was PickupField::OnFormEntry.   It had the same 'lockup/freeze' effect - when I clicked on the Orders Menu button from the Application Menu screen, the Search/Update Orders tab showed below, but the orders screen wouldn't become visible, and Sesame was then non-responsive to any input.  Had to kill it with Task Manager.

PickupField::OnFormEntry

#Include "sbasic_include.sbas"

If @Mode() < 2 and (@IsBlank(PickupField) = 0)
  {
    RGBColor(PickupField, -1, -1, -1, 252, 252, 0)
  }
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #11 - May 30th, 2009 at 4:58pm
Print Post Print Post  
Update:

Thinking to try a different db in the same app, I added the following code to element CurrentPODate in Inventory.db.  Same lockup/freeze result, with little message saying "compiling: CurrentPODate (14).

Inventory!CurrentPODate::OnDraw

#Include "sbasic_include.sbas"

If @FormViewType("Inventory") = FORM_VIEW_TYPE_TABLE
  {
    If CurrentPODate < "05/15/2009"
     {
       RGBColor(CurrentPODate, -1, -1, -1, 255, 255, 0)
     }

        else
            {
              RGBColor(CurrentPODate, -1, -1, -1, 255, 255, 255)
            }
  }
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #12 - May 31st, 2009 at 4:04pm
Print Post Print Post  
Latest update ...

My app locked up/froze with the following commented-out code in SOLines:ShockednDraw.  It seems that it doesn't want an OnDraw event even listed in the Program Editor (or else doesn't want the single blank space between the two commented out sections).   Once I deleted the SOLines:ShockednDraw event, unlocked, reconciled and re-opened the app, Orders screen came up just fine.

/*
#INCLUDE "SBASIC_INCLUDE.SBAS"

If @FormViewType("SOLines") = FORM_VIEW_TYPE_TABLE
     {   
       RGBColor(ItemUoM, -1, -1, -1, 255, 255, 0)
       ForceRedraw()
     }
      else
        {
          RGBColor(ItemUoM, -1, -1, -1, 255, 255, 255)
          ForceRedraw()
        }
   
*/ 

/*

    If @ToNumber(ItemQty) < 0
     {
       RGBColor(ItemQty, -1, -1, -1, 255, 255, 0)
     }

       else
         {
           RGBColor(ItemQty, -1, -1, -1, 255, 255, 255)
         }
    ForceRedraw()
  }
*/
  

Larry
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: LE background color different depending on Val
Reply #13 - Jun 1st, 2009 at 12:10am
Print Post Print Post  
We get it. On Draw is locking up your app. Smiley

Support will probably be requesting your application since our test apps are not locking up. It's probably a refresh loop coming from another piece of code, but they can help to track it down.
« Last Edit: Jun 1st, 2009 at 1:11am by Hammer »  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: LE background color different depending on Val
Reply #14 - Jun 1st, 2009 at 1:20am
Print Post Print Post  
Hammer,

You're not the first person to reply to me with the comment "too much information".  HaHa.  I just didn't want anyone to think I was being lazy!

I'm going to send your comment to my daughter, who has rolled her eyes over 'too much information' coming from me for many years - she'll get a good laugh out of that.
  

Larry
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print