Very Hot Topic (More than 25 Replies) LE background color different depending on Value (Read 2999 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
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: LE background color different depending on Val
Reply #15 - Jun 1st, 2009 at 1:53pm
Print Post Print Post  
Good Morning lksseven,
Please send your design files (DSR & DDT) to support@lantica.com so that we can help you resolve this issue.
  
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 #16 - Jun 1st, 2009 at 6:10pm
Print Post Print Post  
Hi Ben,

will send them this afternoon.

Thank you!

Larry
  

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 #17 - Jun 1st, 2009 at 8:35pm
Print Post Print Post  
Larry,
We have received your files and we have started looking into your issue.


From what we are seeing in our testing here, you have multiple uses of #Include "sbasic_include.sbas"  throughout your programming. This can cause the compilation time when you first open your application to increase (which may cause Sesame to appear locked up). We found that after 5-7 minutes of compiling your programming the forms finished loading and were usable. Try removing the include statement from all of your programmed events and then add #Include "sbasic_include.sbas" in the Global Code section of your programming. The include statement does not need to appear anywhere else in your programming.
  
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 #18 - Jun 1st, 2009 at 9:17pm
Print Post Print Post  
Ben,  thanks!  Didn't know better, but now I do.  I'll make the changes tonight.

Larry
  

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 #19 - Jun 2nd, 2009 at 12:09am
Print Post Print Post  
Ben,

I removed #Include "sbasic_include.sbas" from all events and added it to Global Code for each form.

the forms load MUCH faster.

Unfortunately, any code in the ItemQty:ShockednDraw event still makes the Order screen appear to freeze/lockup.  So I /*  */  the code in the OnDraw event screen, reloaded, and the Order screen still was frozen/locked.  So I deleted the OnDraw event altogether, and then everything worked fine.

What do I try next?
  

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 #20 - Jun 2nd, 2009 at 4:10pm
Print Post Print Post  
Try the following in your ItemQty :: On Draw event. Removing the ForceRedraw() statements will at the very least decrease some of the load time and slowdowns that you were seeing in the subform.

Code
Select All
If @FormViewType("SOLines") = FORM_VIEW_TYPE_TABLE
     {
	 RGBColor(ItemUoM, -1, -1, -1, 255, 255, 0)
     }
	else
	  {
	    RGBColor(ItemUoM, -1, -1, -1, 255, 255, 255)
	  }

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

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

  
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 #21 - Jun 2nd, 2009 at 6:24pm
Print Post Print Post  
Ben,

Good morning!

I used the following code in ItemQty::OnDraw, and it froze/locked - sesame.exe was using 50% of CPU.

SOLines!ItemQty::OnDraw

// if table view (for printing purposes) and ItemQty is a negative number, then
// I want the ItemQty background to be yellow FOR only that line item that is a
// negative number, otherwise I want the background to be white

If (@FormViewType("SOLines") = FORM_VIEW_TYPE_TABLE) and (@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 #22 - Jun 2nd, 2009 at 6:36pm
Print Post Print Post  
Can you provide us some general information about your machine. General specs like the RAM, Processor, Operating System, etc.

How long do you let Sesame sit when it appears to be locked up before you tell windows to end the task?

  
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 #23 - Jun 2nd, 2009 at 8:58pm
Print Post Print Post  
Lenovo W700 laptop (2 months old), Intel Core 2 Duo CPU T9400 @ 2.53GHz.
3gb RAM, WinXP Pro, service pak 3.   My 'in operation' Sesame server is also Lenovo Tower, M57model, about 8 months old, 3gb RAM, WinXP Pro, ServPak3.
   
Task Manager shows sesame.exe using anywhere from 33mb to 66mb memory (but it doesn't seem to cannibalize more and more memory, as it was when I had #Include "sbasic_include.sbas" strewn throughout my events like a drunken sailor) , and about 50% of the CPU utilization.  I only let it go for 30 to 45 seconds or so (the time it takes me to walk outside and howl and walk back in again - haha) before killing it with Task manager.
  

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 #24 - Jun 2nd, 2009 at 9:03pm
Print Post Print Post  
Try letting it work for 5-10 minutes just to see if it picks back up and finishes loading.

We can also setup a GoToMeeting session if you like so that we can take a look at what it is doing on your machine. To schedule a meeting, email us at support@lantica.com with a time that will work for you (between 9AM and 5PM EST).
« Last Edit: Jun 3rd, 2009 at 1:18pm by Ben »  
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 #25 - Jun 2nd, 2009 at 11:39pm
Print Post Print Post  
85% breakthrough ....

I was having a nagging issue of several workstations getting sbasic runtime error messages when printing sales orders.  I was starting to suspect that these two users were blowing through the screen so quick that the code wasn't keeping up.  Couple that with your very welcome suggestion that I put #Include "sbasic_include.sbas" only in Global Code (which meant that the app loaded so much quicker) and I got to thinking ... I have Just In Time Compilation set to ON for all of my workstations because the other way was horrendously slow loading the app (due to my ignorance about #Include "sbasic_include.sbas" overuse).  So, with the vastly increased load speeds, I decided to switch off Just In Time Compilation .... I did so this evening before leaving the office (including my laptop), and the runtime errors stopped popping up.

So when I set up just now to follow your directions and let computer run for 5 or 10 minutes to see if it would finally load (having coded an OnDraw event), the app loaded with ease - no lockup, no freeze, no problem!
     So, it seems that OnDraw does not like Just In Time Compilation (at least in my app).

The other 15% yet to go ..... while the app works, the code itself did not - it does not change the background color - in tableview - of ItemQty if ItemQty is a negative number.  Where is my code off?
  

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 #26 - Jun 3rd, 2009 at 12:07am
Print Post Print Post  
lksseven wrote on Jun 2nd, 2009 at 11:39pm:
The other 15% yet to go ..... while the app works, the code itself did not - it does not change the background color - in tableview - of ItemQty if ItemQty is a negative number.  Where is my code off?

That part might not be you. Let us check it out. It may be a side effect of something we fixed in a previous version.
  

- 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 #27 - Jun 3rd, 2009 at 2:13am
Print Post Print Post  
oki dokie.  Will wait to hear.

While I was waiting, I noticed something bizarre.  I turned off Just In Time Compilation for the above reasons.  But with JIT off, upon clicking Orders (or its subform SOLines) from Application Menu, which presents the 'search/update Orders' tab.  If I hit F10 to find all records, it says 'so results returned from query'.  If I then click 'Clear Search Criteria' from Command Menu on that tab, and then hit F10, it finds all of my records.  But if I then press F7 and enter a specific search criteria (a client id, for example) it says 'no results returned from query'.

     If I change my sesame.ini file back to Just In Time Compilation: ON, then Orders and SOLines performs normally, with an initial F10 returning all of my records, F7 and specific search criteria returning correct results.

The other 6 or 7 databases in this app perform normally in both settings of Just In Time Compilation.  It's only Orders and SOLines (with which I was having the initial issue of OnDraw).

What could I have done to the code (or could it have been something I've done) that would cause Orders and SOLines to act normally with JIT on, but be on the fritz with JIT off ?  
       
Two more observations:
1)  with JIT off, when in SOLines form, I click on Simple Search, leave criteria blank and click Accept.  It finds all my records (now it's in Update mode).  If I go to the last record and then continue to press F10, it just keeps creating new blank records.
       But if JIT is on, and I go to the last record in SOLines form, and press F10, it only allows me to create one blank record.

2)  with JIT off, once I get to the Orders or SOLines form in 'search/update tab, I can't escape that tab by hitting ESC key.  I have to click 'close tab' button on Command menu
« Last Edit: Jun 3rd, 2009 at 4:42pm by lksseven »  

Larry
Back to top
IP Logged