User-defined Conversions
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    v BEE Variables
       > BEE Variable Name
       o BEE Variable Value
       v BEE Conversions
          o Intrinsic Conversions
          o User-defined Conversions
          o To string or not to string
    > BEE Syntax
    > BEE Commands
    > Database Operation
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> BEE Variables >> BEE Conversions >> User-defined Conversions <=  =>      <  1  2  >  
Examples Conversions defined by the user

Example 1 – Simple increment:

function inc

{

   var by = "{arg%argv:1}";

   if ({#by:} == 0) var by = 1;

   var result%function = "(expr){arg%value} + {by}";

}

 

display "2" conv=inc;               // 3

display "2" conv=inc:8;             // 10

 

var a = 2 conv=inc;

display "a is {a}<br> ";             // a is 3

 

var a conv=inc;

display "a is still {a}<br> ";       // a is still 3

 

 

Example 2 – Increment by reference:

function inc

{

   var by = "{arg%argv:1}";

   if ({#by:} == 0) var by = 1;

   var result%function = "(expr){arg%value} + {by}";

 

   if ({#arg%var:} > 0)

   {

         // We need to modify the variable too

         parent "{arg%var}";

         var argVar =& "{arg%var}";

         var argVar = "{result%function}";

   }

}

 

var a = 2 conv=inc;

display "a is {a}<br> ";             // a is 3

 

var a conv=inc;

display "a is now {a}<br> ";       // a is now 4

 

 

Example 3 – Increment by multiple arguments:

function inc

{

   var by = "{arg%argv:1}";

   if ({#by:} == 0) var by = 1;

   var result%function = "(expr){arg%value} + {by}";

 

   if ({#arg%var:} > 0)

   {

         // by reference

         parent "{arg%var}";

         var argVar =& "{arg%var}";

 

         clear arg%argv:0;  // The function name is out of the loop

         foreach (arg%argv)

         {

               var by = "{foreach}";

               if ({#by:} == 0) var by = 1;

               var result%function:{foreach:key}

                  = "(expr){arg%value} + {by}";

         }

 

         if ({#arg%var:} > 0) var argVar = "(var)result%function";

   }

}

 

var a = 2 conv=inc;

display "a is {a}<br> ";             // a is 3

 

var a conv=inc;

display "a is now {a}<br> ";       // a is now 4

 

var a conv=inc:10,20,30;

display "a:{a|list}<br> ";   // a:''=>'14','1'=>'14','2'=>'24','3'=>'34'

 

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd