Normal Topic Overabundance of Code (Read 1810 times)
Zannion
Member
*
Offline



Posts: 7
Joined: May 13th, 2013
Overabundance of Code
May 14th, 2013 at 1:07pm
Print Post Print Post  
I recently stepped into an application of sesame which has had some concerns for some time.    Over the past few weeks I have had to correct these concerns to the best of my abilities, which I have successfully done except for one over-arching situation. 

I have multiple sections of codes which seem to be slowing down the server from the shear amount of coding that was put into them.  The main problem is that the coding has a minimum of documentation, so I have had to figure things out by reviewing all of the code.

In this situation, all the remaining sections of code are designed to display an error if there are empty fields within an open document.  For example:

If @Mode() = 0 Then
{
     NotifyForm(1)
     NotifyForm(2)
     NotifyForm(3)

     If @IsBlank(search phone) = "False" Then
     {
       NotifyForm(0)
     }
     Else
     {
       @MSGBox("Please check to make sure you have filled in [SEARCH PHONE].","","TRY AGAIN!")
       CNEXT
     }
     
}


The purpose again, being to inform the user that the document has necessary fields that have not been entered before an attempt at saving has been initiated.  The problem here is that there are thousands of lines of code that have this situation, with varying syntax.  Instead of Search Phone, I have applications where the fields are: Title, Last, Add1, etc...

My current project is to attempt to reduce the amount of coding used for this application as thoroughly as possible.  There is about 4,000 lines of code with this situation.  My plan is to get this down to about 200-400 lines of code if possible.  The sheer amount of codes are causing lag-like issues when clients use the fields that these blocks of code are in.

My thoughts are either an array of some form to correct this situation, and I am looking for any hints or suggestions that the users of this forum may have.

Thanks
  

Look into my eye...
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Overabundance of Code
Reply #1 - May 14th, 2013 at 1:31pm
Print Post Print Post  
Replace any repetitive code with subroutines or functions in global code. Pass arguments to the function to allow for differences like which element is being checked, etc.

When writing a function or subroutine, attempt to make it as generic as possible. Avoid "hard-coding" element names. It should be usable on any element on any form with a minimum of alterations.

Employ "TheElement" if direct element referencing (as opposed to the value in an element) must be used.

Avoid using elements when a variable will suffice. Variables are several hundred times faster than elements. If an element's value is used more than once, put it in a local variable and use that.

Use form level programming where possible, as opposed to element level, to avoid the overhead of invoking the SBasic runtime environment for each element. The form level programming and events can access all of the elements on the form, so there is rarely reason to program those elements individually.

Consolidating your code in the global code event as functions and subroutines minimizes most other event's code to a single line invoking that function (or less) and improves both run time and compile time.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Zannion
Member
*
Offline



Posts: 7
Joined: May 13th, 2013
Re: Overabundance of Code
Reply #2 - May 30th, 2013 at 4:12pm
Print Post Print Post  
I was able to successfully implement some changes to our code, yet we are noticing little to no difference on the delay when entering information into our code.  Specifically in a child form, when one is attempting to enter comment information.

What I've noticed in our code is that in the Global Code for our child forms, SetAutoComplete is turned on for the form.  Specifically the code in GLOBAL CODE, along with JOB COMMENTS :: On element entry - read as:

SetAutocomplete(JOB COMMENTS, "")

We've been told that Auto Complete for our situation is not a recommended setting, yet it must be kept on as disabling is not an option.  I have gotten permission to remove it specifically from this form in an attempt to solve the delay.  My question is as follows:

If I were to remove this code from both fields, is there a chance that this would increase the speed of entry for the job comments section?  I'm assuming that if I take it out of the JOB COMMENTS form, it must be also taken out of the GLOBAL CODES form as well. The more individuals in that section at one time the worse the delay gets.

I have been attempting to see if I can obtain for us a new computer, as this delay affects two people, one lightly and one severely.  The major concern here is for the severe individual.  Yet at this time, I must get what we have working in a positive manner.

Any help would be appreciated.
  

Look into my eye...
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Overabundance of Code
Reply #3 - May 30th, 2013 at 4:29pm
Print Post Print Post  
Hi Brian,

Zannion wrote on May 30th, 2013 at 4:12pm:
SetAutocomplete(JOB COMMENTS, "")


What that line of code does is set the list of Auto complete options for the Job Comments element to be a zero length string, so Auto Complete will not work for that element. So unless there is other code somewhere that is calling DisableAutoComplete(), I would look more at On Element Immediate Change programming on that form, or Universal Event programming. Both of which will fire every time a letter is typed on the keyboard into an element, and depending on what the code is, there are better events for the code to be placed. Universal Event in particular should not be used unless you are building a game in Sesame or need to capture the position of the mouse as it moves across the screen.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Zannion
Member
*
Offline



Posts: 7
Joined: May 13th, 2013
Re: Overabundance of Code
Reply #4 - May 30th, 2013 at 4:58pm
Print Post Print Post  
Okay, so now I understand what the "" means, thanks Ray.

Looking at both forms Element Immediate Change and Universal Event no coding is present in either form.  In fact, for the element JOB COMMENTS, there are no events other then "On Element Entry" that have any coding in them.  I am quickly coming to a loss as to what is causing the issue for the delay, and at this point I am truly wondering if its much more a hardware issue then a software issue.

For example, when I recently sat down at our newest computer, I had another person sitting at the computer that is providing to us the major list of concerns when it comes to this delay.  Sitting side by side, we both attempted to enter the same exact paragraph of information into the computer.  My entry was great, as there was absolutely no delay in the process.  The second computer had a ton of missing information.  The reason that we did it at the same time was to attempt to test it during a mock up of "high demand" on the form.  This is due to the the notation I had previously illustrated about the delay becoming more noticeable with more users in the same exact form at once.

Hence my concern about the hardware becoming an increasingly higher concern for myself at this time. 

If anyone has any other suggestions of where to look for problematic coding in the form, I am all ears.
  

Look into my eye...
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Overabundance of Code
Reply #5 - May 30th, 2013 at 6:02pm
Print Post Print Post  
Hi Brian,

Look at the Orders::On Element Immediate Change event and the Orders::Universal event. Since Orders is the name of your form, the On Element Immediate Change event for it will fire every time any element on that form is changed. And well the Universal Event is Universal.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Zannion
Member
*
Offline



Posts: 7
Joined: May 13th, 2013
Re: Overabundance of Code
Reply #6 - May 31st, 2013 at 4:00pm
Print Post Print Post  
I was able to successfully remove coding from the Orders :: Universal Event form.  With this just being completed, I have tested the problem field and have seen absolutely no change in the delay of keystroke entry. 

Now while looking at the coding for Orders :: On Element Immediate Change there is still a substantial amount of code in here, and I am truly unsure on how to proceed.  The effect of the coding has the response of providing two levels of visibility to the user.  For example:

IF JOB TYPE:1 = "SEALCOATING" THEN

{
     Visibility(AMT, 1)
     Visibility(Discount1, 1)      
}
ELSE
{
     Visibility(Discount1, 0)
}


This code continues onwards as the form progresses, with varying levels of both visibility and effects.  I guess my question comes in, is there a better place to put this coding?  With Ray's comment about cleaning up these two Events, I want to try to get the coding moved out of here to see if there is any substantial change in the delay of keystroke entry.
  

Look into my eye...
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Overabundance of Code
Reply #7 - May 31st, 2013 at 4:20pm
Print Post Print Post  
Zannion wrote on May 31st, 2013 at 4:00pm:
I guess my question comes in, is there a better place to put this coding?



Without a doubt, Yes. Since the code in that event runs every time you change an element, no matter what element you are in, it's running way more often then it needs to be.  Better places for it would be On Form Entry, and the JOB TYPE:1 on Element Change event.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Zannion
Member
*
Offline



Posts: 7
Joined: May 13th, 2013
Re: Overabundance of Code
Reply #8 - May 31st, 2013 at 5:24pm
Print Post Print Post  
Perfect.  Once I moved the remainder of coding from Orders :: On Element Immediate Change the problems seemed to have gone away.  I did some individual testing on all the computers, then produced a stress test in which all the individuals who would use the field at the same time did so.  No missing characters anymore.  I still believe that there is a lot of cleaning up to do with regards to the remainder of the code, but this removed the most pressing issue immediately.

Thanks to both Ray and Mark for the help!    Smiley
  

Look into my eye...
Back to top
 
IP Logged