Normal Topic Certain Loops Not working in Global Code (Read 1458 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Certain Loops Not working in Global Code
Mar 25th, 2005 at 7:03pm
Print Post Print Post  
Tried to put For - Next Down to 2 Step 2 code in the Global Code as I planned to use that in various elements of the the form to check Algorithms to validate certain numbers such as DEA, Recipient Number and  Credicard numbers but it gave error, stating varient of For-Next can be used locally only. Moreover, it resulted into a lot of other errors to the extent that the code even did not recognize the names of the elements in the form.

I could not find any document stating that what cannot be used in Global Code. Are there any other limitations?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Certain Loops Not working in Global Code
Reply #1 - Mar 25th, 2005 at 7:13pm
Print Post Print Post  
Hello Bharat,

I just tried this here in 1.1.2 and it works. Could you perhaps post your code?

-Ray
  

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


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Certain Loops Not working in Global Code
Reply #2 - Mar 25th, 2005 at 7:36pm
Print Post Print Post  
var vTestString as String
Var i as Int
var vTotal1 as Int
var vTotal2 as Int
var vtemp as Double  
var vFinalTotal as Double  
var vResult as Double    



//number validation for Medicaid - Algorithm



vTestString = @Left (RecNumber, 8)
vTotal1 = 0
vTotal2 = 0
vTemp = 0


For i = 8 downto 2 Step 2
     vTemp =      @int (@Mid (vTestString, i, 1))*2
     
     If VTemp >= 10 then
         {
           vTemp = 1 + @mod (vTemp, 10)
         }
     
     //WriteLn ( "vTemp = " + vTemp)            
       
     vTotal1 = vTotal1 + vTemp
     vTemp = 0

     vTotal2 = vTotal2 + @int (@Mid (vTestString, i-1, 1))
     
     
Next

vFinalTotal = vTotal1 + vTotal2
//WriteLn ("vFinalTotal = "  + vFinalTotal)
vResult = @Mod (vFinalTotal, 10)

//Writeln ("vTestString = " + vtestString + @newline ( ) + "vTotal1 = " + vTotal1 + @newline ( ) + "VTotal2 = " + vTotal2 + @newline ( ) + "vResult = " + vResult )

/*   Just using vTotal1 and vTotal2 variables. so do not have to make more variables,
Moreover vResult is a Double and that did not  give good boolean results...
learned that better not to compare those two unless you have to.
Because of that both INT variables are compared in boolean Statement..
Worked!!!!!
*/



vTotal1 = 10 - vResult
vTotal2 = @Tonumber (@Right (RecNumber, 1))

/*
I tried to put the above code in the Global Code and it gave all kinds of error including Variant of For...Next loop cannot be used in Global Code...  RecNumber is text element of the form. The code works fine when posted in the RecNumber element on Element Exit event.
*/


If @Isnew  and (vTotal1 = vTotal2) then
       {
         If @AskUser ("Is this Medicaid Patient?", "", "")
           {
                  Ins1 = "P"
           }
       }
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Certain Loops Not working in Global Code
Reply #3 - Mar 25th, 2005 at 7:43pm
Print Post Print Post  
I am at work and using Sesame 1.1. At home I have upgraded to ver 1.2.  Did not try on ver. 1.2. Well, let me upgrade to Sesame ver. 1.2 and see how does it work in there. Will report the results soon. Thanks Ray for your feedback.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Certain Loops Not working in Global Code
Reply #4 - Mar 25th, 2005 at 8:06pm
Print Post Print Post  
Hello Bharat,

I tried your code here in 1.1.2 and in 1.1.0 and it worked. The test form I used only had a element named RecNumber on it.  Try building a new DSR and just add a RecNumber element to it and see if the same code produces the same error.

-Ray
  

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


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Certain Loops Not working in Global Code
Reply #5 - Mar 25th, 2005 at 10:17pm
Print Post Print Post  
Hi Ray,

The code did work in the Global Code. Mistake was all mine. Whatever variables are used within the loop have to be local variables (they should be inside the subroutine) and that is where I made the mistake. Sorry to give you trouble but that taught me something new. Thanks again.
  
Back to top
 
IP Logged