Script

Definition about Scope of variable and function in nexacro

var9

Script used in naxacor uses JavaScript spec as standard, so JavaScript can be used for various user and source.
Variable Scope is a way to define available variable to access from current location.
In case there is in Scope, It is possible to access variable and read/write.
In case there is outside Scope, It is impossible to access variable.
Variable is separated into two type.

Global Variable : This Variable is defined outside Function , so this can be accessed anywhere. Local Variable : This Variable is defined inside Function, so this can be accessed inside Function.

When function is defined like this.getName = function(){…} in form, In case variable is defined using var in function block, This variable has local scope which is can be referenced in this.getName function.

This variable is avaliable when related funtion runs. Otherwise this variable is avaliable in running context. And When function is ended, this variable becomes a garbage collection.

We use "this" keyword to all variables and functions in instance of related form in nexacro. so this makes less mistakes.
You have to define context of related variables or functions  using "this" keyword to be only referred to running form in nexacro.

Global variable is used in all location in program. So this variable is always loaded in memory.
Local variable is used in limited location, so this variable is extinguished after ending.
JavaScript is functional language, Most local variables are used inside function. When function is finished the local variable is extinguished automatically.

When Scope is not defined, global variable is stacked on memory. So this influence performance.

When Scope is not defined, Variant is handled as Global. So Scope should be defined when Variant is used.

nexacro uses the same configuration of Scope of HTML5, So In case there is Variant which is not defined Scope in ADL/FDL/XJS Script, the variant is treated as top member of Global.

Scope must be defined. (this/this.parent/application) Property/Function/Variant etc should be used with this, parent or application

Example)

var9

In case Scope and Var is not defined outside Function, this treated as member of global. We recommend not to use this.

When Var is defined without Scope outside Function, This is handled as not a member of form. We recommend not to use this. (This is treated as variable of form script)

var9

Please use Mothod with this,parent or application.
(In case there is undefined method, Global member method will be run except method of Form.

var9

Please Global Variant of FDL uses with this, parent or application.
(If there is undefined Global Variant, this will be treated variant of script not member of Form.)

var9

We provide LookUp method for difficult situation to define Scope, but this causes performance degradation.
(Object LookUp, Method LookUp)

var7

This is test result according to each variable scope how much performance is different.

var7

Firefox 26.0 Version standart

Condition

local variable J increase

this.j increase

application.j increase

5회 평균치(ms)

33.75

100.75

220

This result number is gained by abnormal and inordinate test (this result gotten by thirty million test). so this is difficult to apply to developing system equally.

eval

By using the eval function we can run the original script code dynamically.
var dataset = eval("this." + obj.binddataset);

Can we run a script dynamically?

Breaking line Character(New Line Character) Processing

Handling new line characters using Script

Newline character can be expressed by using the \n.

np_Script_Newline_0

this.Button00_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
 this.stNewLine.set_text('aple' +  String.fromCharCode(10) + 'Strawberries');
}
this.Button01_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
 this.taNewLine.set_value('aple' +  String.fromCharCode(10) + 'Strawberries');
}
this.Button02_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
 this.ds_data.setColumn(0,"Column0",'aple' +  String.fromCharCode(10) + 'Strawberries'); 
}

String.fromCharCode (10): refers to the newline character.

I would like to know how to handle the newline character.

Source Location

Sample_Script\np_Script_Newline.xfdl

Number & Math

By using the script we can implement number conversion and operation related functions.

Changing ASCII code to HEX value

Using charCodeAt, fromCharCode methods we can convert ASCII Code to Hex code and Hex Code to ASCII code.

Script_Number_AsciiToHex_0

Reference Detail

charCodeAt

This method is used to return integer value corresponding Unicode Character at the specified index.

fromCharCode

This method returns the character string of Unicode value.

Main Source Content

this.fn_doAsciiHex = function(sValue, sType)
{
    var sHex   = "0123456789ABCDEF";
    var sAscii = ' !"#$%&'+"'"+'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ['+'\\'+']^_`abcdefghijklmnopqrstuvwxyz{|}';
    var sRtn   = "";
    if (sType == "A2H")
    {
        var sLet, nPos, h16, h1;
        for (var i = 0; i < sValue.length; i++)
        {
            sLet  = sValue.charAt(i);
            nPos  = sAscii.indexOf(sLet) + 32;
            h16   = Math.floor(nPos / 16);
            h1    = nPos % 16;
            
            sRtn += sHex.charAt(h16) + sHex.charAt(h1);
        }
    }
    if (sType == "H2A")
    {
        for (var i = 0; i < sValue.length; i++)
        {
            var sLet1 = sValue.charAt(2 * i);
            var sLet2 = sValue.charAt(2 * i + 1);
            var sVal  = sHex.indexOf(sLet1) * 16 + sHex.indexOf(sLet2);
            
            sRtn += sAscii.charAt(sVal - 32);
        }
    }
    return sRtn;
}

Ascill, HEX

Source Location

Sample\Sample_Script\np_Script_Number_AsciiToHex.xfdl

Numeric Number format check

Using the charAt method we can verify the number format of input string.

Script_Number_CheckNumber_0

Reference Detail

charAt

This method returns the character corresponding to the specified index

Number format, charAt

Source Location

Sample\Sample_Script\np_Script_Number_CheckNumber.xfdl

Changing the RGB color code

Using parseInt method RGB color values can be converted to HEX Code and HEX Code can be converted into RGB values in script.

Script_Number_HexToRGB_0

Reference Details

paseInt

This method returns integer value after convertion string to integer.

charAt

This method is used to return the character corresponding to the specified index.

Clicking on the execute button, the background color of the screen will be changed.

RGB, HEX

Source Location

Sample\Sample_Script\np_Script_Number_HexToRGB.xfdl

Converting Base of different types format

Using toString method we can write script to convert object into decimal, hexadecimal and binary numbers.

Script_Number_NumberFormat_0

Reference Details

toString

It is Method to return a text string which indicates a object.

essence, toString

Source Location

Sample\Sample_Script\np_Script_Number_NumberFormat.xfdl

Checking the range of the Number

Using toNumber method we can verify if the input number in the specified range of numbers then return true otherwise return false.

Script_Number_NumberRange_0

It is verification for value of input0 exists within the range of input1 and input2.

Reference Details

toNumber

This method is used to convert input value to number.

Range check, toNumber

Source Location

Sample\Sample_Script\np_Script_Number_NumberRange.xfdl

Calculating Percentage

Using Math object we can calculate percentage of input values.

Script_Number_Percentage_0

Reference Detail

Math

Mathematical functions and related constants are defined in the object.

round

It is Method to return a closest integer or a fixed point real number by rounding a given formula.

Percentage, round

Source Location

Sample\Sample_Script\np_Script_Number_Percentage.xfdl

Processing numeric values to round

Script_Number_Round_0

Reference Data

round

This method returns the rounded integer value.

round

Source Location

Sample\Sample_Script\np_Script_Number_Round.xfdl

Converting input String type number to integer type

parseInt Method returns integer which is transformed from a text string.

Script_Number_StringToInteger_0

parseInt, Integer

Source Location

Sample\Sample_Script\np_Script_Number_StringToInteger.xfdl

String

It is Method to operate a text string and designate a document form or determine a partial text string in a text string or designate a position.

Getting sub string from the input string as much we want

substr method returns a partial text string which begins at designated position and has designated length.

Script_String_CharIndex_0

Reference Details

substr

substr method returns a partial text string which begins at designated position and has designated length.

Mid, substr

Source Location

Sample\Sample_Script\np_Script_String_CharIndex.xfdl

Returning the length of the String

Using length method we can get string length.

Script_String_CharLength_1

Main Source Content

function fn_charLength(sString) 
{
  var sString = sString.toString();
  var nCnt    = 0;
  for (var i = 0; i < sString.length; i++)
  {
    if (sString.charCodeAt(i) > 127)
    {
      nCnt += 2;
    } 
    else 
    {
      nCnt += 1;
    }
  }
  return nCnt;
}

Korean character is 2 bytes. We can verify using Unicode to process Korean characters.

Reference Details

charCodeAt

It is Method to return an integer to indicate unicode encoding of a text in a designated position.

Source Location

Sample\Sample_Script\np_Script_String_CharLength.xfdl

Checking characters and numbers

Using charCodeAt we can verify characters and numbers.

Script_String_CheckAlpaNum_0

Reference Details

charCodeAt

It is Method to return an integer to indicate unicode encoding of a text in a designated position.

charCodeAt

Source Location

Sample\Sample_Script\np_Script_String_CheckAlpaNum.xfdl

Checking Korean and special characters

Using charAt method we can check the Korean and special characters.

Script_String_CheckChar_0

Reference Details

indexOf

indexOf method returns a text position from which a partial text string begins in string object.
lastIndexOf method returns a case that a partial text string lastly appears in string object.

charCodeAt

It is Method to return an integer to indicate unicode encoding of a text in a designated position.

charAt

This method returns character at the specified index.

indexOf, charCodeAt

Source Location

Sample\Sample_Script\np_Script_String_CheckChar.xfdl

Eliminate duplicate data in the array

Using the split method we can implement script to eliminate duplicate values from the array.

Script_String_Distinct_0

Reference Details

split

It is Method to return arrangement of a text string which is generated when a text string is divided into many partial text strings.

Array, Duplication

Source Location

Sample\Sample_Script\np_Script_String_Distinct.xfdl

Converting full-width characters to half-width characters

Using charCodeAt method we can convert full-width characters to half width characters.

Script_String_FullToHalf_0

Main Source Content

function fn_fullToHalf(sFull)
{
   …Skip
  for (var i = 0; i < sFull.length; i++)
  {
    sChar = sFull.charCodeAt(i);
    if (sChar == 12288)
    {
      sHalf += unescape("%20");
    }
    else if ((sChar >= 65281) && (sChar <= 65374))
    {
      sHalf += unescape("%" + (sChar-65248).toString(16));
    }
    else
    {
      sHalf += sFull.charAt(i);
    }
  return sHalf;
}

Reference Details

unescape

It is Method to decode String object which is encoded by escape method.

charCodeAt, unescape

Source Location

Sample\Sample_Script\np_Script_String_FullToHalf.xfdl

Half-width character to full-width character conversion

Using charCodeAt method, we can convert Half-width character to full-width character.

Script_String_HalfToFull_0

Reference Details

Main source content

function fn_halfToFull(sHalf)
{
   …Skip
  for (var i = 0; i < sHalf.length; i++) 
  {
    if ((sHalf.charCodeAt(i) >= 32) && (sHalf.charCodeAt(i) <= 126)) 
    {
    … Skip
      {
        sChar = sHalf.charCodeAt(i) + 65248;
      }
    }
    … Skip
    sFull = sFull + String.fromCharCode(sChar);
  }
  return sFull;
}

Reference Details

fromCharCode

It is Method to return a text string out of various unicode text values.

charCodeAt, unescape

Source Location

Sample\Sample_Script\np_Script_String_HalfToFull.xfdl

Creating Korean ↔ Unicode converter

Using JavaScript regular expressions we can create Korean to Unicode and Unicode to Korean converter.

Script_String_HanGulToUnicode_0

Main Source Content

Reference Details

escape

This method is used to convert into Unicode.

unescape

It is Method to decode String object which is encoded by escape method.

Source Location

Sample_Script\np_Script_String_HanGulToUnicode.xfdl

Filling other characters to specified length in the String

Using padLeft and padRight methods we can fill the specified characters to the specified length of String.

Script_String_LpadRpad_0

Main source content

this.fn_lpad = function(sString, nSize, sPadChar)
{
    var sRtn = "";
 if (sPadChar != null)
 {
  sRtn = sString.padLeft(nSize, sPadChar);
 }
 else if (sPadChar == null)
 {
  sRtn = sString.padLeft(nSize, " ");
 }
    return sRtn;
}
this.fn_rpad = function(sString, nSize, sPadChar)
{
    var sRtn = "";
 if (sPadChar != null)
 {
  sRtn = sString.padRight(nSize, sPadChar);
 }
 else if (sPadChar == null)
 {
  sRtn = sString.padRight(nSize, " ");
 }
    return sRtn;    
}

padLeft, padRight

Source Location

Sample\Sample_Script\np_Script_String_LpadRpad.xfdl

Checking null value to return balnk

If the input data is null or undefined we can return blank value using script.

Script_String_NullToEmpty_0

Reference Details

isNaN

It is Method to indicate which value is NaN(not number) which is an appointed value.

null, undefined, NaN

Source Location

Sample\Sample_Script\np_Script_String_NullToEmpty.xfdl

Converting Number to Korean Character

Using charAt method, we can convert integer to Korean or Chinese Character.

Script_String_NumberToString_0

charAt

Source Location

Sample\Sample_Script\np_Script_String_NumberToString.xfdl

Inserting Hall Quotes(') in the String

Using substr method we can insert Hall Quotes(') in the String.

Script_String_Quote_0

Single quotation

Source Location

Sample\Sample_Script\np_Script_String_Quote.xfdl

Remove hyphen(-) from String

Using replace method we can remove hyphon(-) from string.

Script_String_RemoveHyphen_0

hyphen, replace

Source Location

Sample\Sample_Script\np_Script_String_RemoveHyphen.xfdl

Creating array by separating string

Script_String_StringToAarray_0

Source Location

Sample\Sample_Script\np_Script_String_StringToAarray.xfdl

Returning value after removing blanks

substr method is used to cut the string as desired size, and returns it as an array.

Script_String_Trim_0

Source Location

Sample\Sample_Script\np_Script_String_Trim.xfdl

Date

Using Script we can represent Date related processing.

Calculating the difference between two dates

Script_Date_CalculateDate_0

Can we calculate difference between two dates?

Date

Source Location

Sample\Sample_Script\np_Script_Date_CalculateDate.xfdl

Calculating time difference

We can calculate time difference using Date object.

Script_Date_CalculateTime_0

Main source content

this.fn_calculateDate = function(sDateS, sDateE, sGbn) 
{
    var nMonth = 0; // Calculated the number of months
    var nYear  = 0; // Calculated the number of years
    var nRtn   = 0; // The return value of the month
        
    if (sGbn == "M")
    {
        if (parseInt(sDateS) <= parseInt(sDateE))
        {
            nYear  = parseInt(sDateE.substr(0,4))- parseInt(sDateS.substr(0,4)) ;
            nMonth = parseInt(sDateE.substr(4,2))- parseInt(sDateS.substr(4,2));
            nRtn   = (12 * nYear) + nMonth;
        }
    }
    else
    {    
        var dFrom = new Date(sDateE.substring(0,4),  sDateE.substring(4,6)-1, sDateE.substring(6,8)
                            ,sDateE.substring(8,10), sDateE.substring(10,12), sDateE.substring(12,14));
        var dTo   = new Date(sDateS.substring(0,4),  sDateS.substring(4,6)-1, sDateS.substring(6,8)
                            ,sDateS.substring(8,10), sDateS.substring(10,12), sDateS.substring(12,14));      
        nRtn = parseInt((dFrom - dTo)/(1000*60*60*24));
    }
    return nRtn;
}

Date, getTime

Source Location

Sample\Sample_Script\np_Script_Date_CalculateTime.xfdl

Validation check for input dates

Using toNumber method we can verify the date format.

Script_Date_CheckDate_0

Main Source Content

this.fn_checkDate = function(sDate) 
{
    var nYear  = Number(sDate.toString().substr(0,4));
    var nMonth = Number(sDate.toString().substr(4,2));
    var nDate  = Number(sDate.toString().substr(6,2));
    if ( nMonth > 12 || nMonth < 1)
    {
       return false;
    }
    
    switch (nMonth) 
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            if (nDate > 31 || nDate < 1)
            {
                return false;
            }
            break;
        case 4: 
        case 6: 
        case 9: 
        case 11:  
            if (nDate > 30 || nDate < 1)
            {
                return false;
            }                               
            break;
        case 2:   
            if (((nYear % 4 == 0) && (nYear % 100 != 0)) || (nYear % 400 == 0))
            {
                if (nDate > 29 || nDate < 1)
                {
                    return false;
                }
            }
            else
            {
                if (nDate > 28 || nDate < 1)
                {
                    return false;
                }
            }                              
            break;            
        default:
            break;
    }    
    return true;
}

toNumber, leap year

Source Location

Sample\Sample_Script\np_Script_Date_CheckDate.xfdl

Checking for leap year

Using leap year calculation we can verify leap year if that year has 29 Feb.

Script_Date_CheckLeapYear_0

Main Source Content

this.fn_checkLeapYear = function(sDate) 
{
    var bRtn = false;
    var nY   = parseInt(sDate.substring(0,4));
    if ((nY % 4) == 0) 
    {
        if ((nY % 100) != 0 || (nY % 400) == 0) 
        {
            bRtn = true;
        }
    } 
    return bRtn;
}

Leap year

Source Location

Sample\Sample_Script\np_Script_Date_CheckLeapYear.xfdl

Time validation check

Using Number method we can check validation for time.

Script_Date_CheckTime_0

Main Source Content

this.fn_checkTime = function(sTime) 
{
    var nHH = Number(sTime.toString().substr(0,2));
    var nMM = Number(sTime.toString().substr(2,2));
    var nSS = Number(sTime.toString().substr(4,2));
    if (nHH > 24 || nHH < 0)
    {
      return false;
    }    
    
    if (nMM > 59 || nMM < 0)
    {
      return false;
    }
    
    if (nSS > 59 || nSS < 0)
    {
      return false;
    }  
    
    return true;
}

Number

Source Location

Sample\Sample_Script\np_Script_Date_CheckTime.xfdl

Converting Date to String

Using Date object we can convert Date into String.

Script_Date_DateToString_0

Main Source Content

this.fn_dateToString = function(dDate) 
{
    var sRtn =  (new Date(dDate)).getFullYear()
             + ((new Date(dDate)).getMonth()+1).toString().padLeft(2, "0")
             + ((new Date(dDate)).getDate()).toString().padLeft(2, "0");  
              
    return sRtn;
}

Date

Source Location

Sample\Sample_Script\np_Script_Date_DateToString.xfdl

Year and month validation check

Using number method we can check validation for year and month.

Script_Date_CheckYearMonth_0

Main source content

this.fn_checkYearMonth = function(sDate) 
{
    var nYear  = Number(sDate.toString().substr(0,4));
    var nMonth = Number(sDate.toString().substr(4,2));
    if ( nMonth > 12 || nMonth < 1)
    {
      return false;
    }    
      return true;
}

Number

Source Location

Sample\Sample_Script\np_Script_Date_CheckYearMonth.xfdl

Today's date and current time searching

We can get current date and time using Date object.

Script_Date_DateTime_0

Main source content

this.fn_dateTime = function() 
{
    var dDate = new Date();     
    var sRtn =  dDate.getFullYear()
          + (dDate.getMonth()+1).toString().padLeft(2, "0")
          +  dDate.getDate().toString().padLeft(2, "0")
          +  dDate.getHours().toString().padLeft(2, "0")
          +  dDate.getMinutes().toString().padLeft(2, "0")
          +  dDate.getSeconds().toString().padLeft(2, "0");
    return sRtn;
}

Date

Source Location

Sample\Sample_Script\np_Script_Date_DateTime.xfdl

Finding day name from input date

Using Date object we can find day name from input date.

Script_Date_HanGulWeek_0

Main Source Content

this.fn_hanGulWeek = function(sDate) 
{
    var dDate    = new Date(parseInt(sDate.substr(0,4))
        , parseInt(sDate.substr(4,2))-1
        , parseInt(sDate.substr(6,2)));
    var sDay     = dDate.getDay();
    var arrweek  = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");  
    var sRtn     = arrweek[sDay];
    return sRtn;
}

Date

Source Location

Sample\Sample_Script\np_Script_Date_HanGulWeek.xfdl

Finding last day of month from the input date

Using Date object we can find the last day of the month from input date.

Script_Date_LastDay_0

Main source content

this.fn_lastDay = function(sDate) 
{
    var dDate = "";
    sDate = sDate.trim();
    
 if (sDate == null || sDate == "" || sDate == "undefined")  
 {
        // Taking date after one month from today and calculating  today's date
     dDate = (new Date()).addMonth(1);
     dDate = (new Date(dDate)).addDate((new Date(dDate)).getDate()*-1);
    }
    else 
    {
        // picking next month's first day from the input date
     dDate = new Date(parseInt(sDate.substr(0,4)), parseInt(sDate.substr(4,2)), 1);
     dDate = dDate.addDate(-1); 
    }
    var sRtn =  (new Date(dDate)).getFullYear()
             + ((new Date(dDate)).getMonth()+1).toString().padLeft(2, "0")
             + ((new Date(dDate)).getDate()).toString().padLeft(2, "0");  
   
    return sRtn;
}

Date

Source Location

Sample\Sample_Script\np_Script_Date_LastDay.xfdl

Lunar to Solar Conversion

We are changing input Lunar year to solar year.

Script_Date_LunarToSolar_0

parseInt

Source Location

Sample\Sample_Script\np_Script_Date_LunarToSolar.xfdl

Converting Solar to Lunar

Here is a conversion from input Solar year to Lunar year.

Script_Date_SolarToLunar_3

parseInt

Source Location

Sample\Sample_Script\np_Script_Date_SolarToLunar.xfdl

Finding the date range corresponding to input week

Using date object we can calculate the date range corresponding to input week.

Script_Date_WeekOfYear_0

Main Source Content

/*
 * File Name   : Script_Date_WeekOfYear
 * Description : Finding the date interval corresponding to input week
 */
/*  Button Click  */
this.btn_execute_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
 var sRtn = this.fn_weekOfYear(this.edt_input0.value, this.edt_input1.value);
 this.edt_output.set_value(sRtn);
}
/*
 * Function Name : fn_weekOfYear
 * Description   : Finding the date interval corresponding to input week
 * Parameter     : Year, Week
 * Return        : Applying(from ~ to)
 * Example       : fn_weekOfYear(2012, 52);
 */
this.fn_weekOfYear = function(sYYYY, sWeek)
{
    var dDate = new Date(parseInt(sYYYY), 0, 1);
    var nDay  = dDate.getDay();     //0 = Sunday ~ 6 = Saturday    
    
 if (nDay != 0)
 {
  dDate = new Date(dDate.addDate(-nDay));
 } 
 var nWeekS = dDate.addDate(7 * (sWeek-1));
    var nWeekE = dDate.addDate(6); 
    
    var sRtn  =  (new Date(nWeekS)).getFullYear()
              + ((new Date(nWeekS)).getMonth()+1).toString().padLeft(2, "0")
              + ((new Date(nWeekS)).getDate()).toString().padLeft(2, "0")  
              + " ~ "    
              +  (new Date(nWeekE)).getFullYear()
              + ((new Date(nWeekE)).getMonth()+1).toString().padLeft(2, "0")
              + ((new Date(nWeekE)).getDate()).toString().padLeft(2, "0");
 return sRtn;
}

Date

Source Location

Sample\Sample_Script\np_Script_Date_WeekOfYear.xfdl

System

Verifying the function on the screen

Using typeof function we can verify the existence of particular function.

Script_System_ExistFunction_0

Main Source Content

/*
 * File Name   : Script_System_ExistFunction
 * Discription : Verifying the function on the screen
 */
this.btn_execute_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
    var sRtn = this.fn_existFunction(this.edt_input.value);
 this.edt_output.set_value(sRtn);
}
/*
 * Function Name : fn_checkTelNo
 * Discription   : Verifying the function on the screen
 * Parameter     : Function
 * Return        : true, false
 * Example       : fn_existFunction("fn_test");
 */
this.fn_existFunction = function(sValue)
{
 //Check the function if input value is undefined
 if (this[sValue] == undefined) 
 {
   return false;
 } 
 else 
 {
  // "fn_test" Checking the type of  function
  this.alert("function checking is             "+typeof(this[sValue]));
  if (typeof(this[sValue]) == "function")
  {
   return true;
  }
  else
  {
   return false;
  }
 }
}
/*
 * Function Name   : fn_test
 * Discription : Checking function if it exists on screen or not
 */
this.fn_test1 = function()
{ 
}

typeOf, function

Source Location

Sample\Sample_Script\np_Script_System_ExistFunction.xfdl

Obtaining list of components of Form

We can obtain list of components on screen using form's property and arrays.

Script_System_FormComponentList_0

Reference Detail

components

This property is used to access list of components from the form.

Main source content

this.fn_getFormComponentList = function()
{
 var arrCompList = this.components;
 for(var i=0; i<arrCompList.length;i++)
 {
  this.ds_data.addRow();
  this.ds_data.setColumn(i, "DATA" ,arrCompList[i].name);
 } 
}

Components, component list

Source Location

Sample\Sample_Script\np_Script_System_FormComponentList.xfdl

Verifying value of current screen ID

Using formurl property, we can obtain current screen filename.

Script_System_FormID_0

Main source content

/*
 * File Name   : Script_System_FormID
 * Description : Finding current screen file name
 */
 
/*  Button Click  */
this.btn_execute_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
 var sRtn = this.fn_formID(); 
 this.edt_output.set_value(sRtn);
}
/*
 * Function Name : fn_formID
 * Description   : Finding current screen file name
 * Parameter     : 
 * Return        : Form ID
 * Example       : fn_formID();
 */
this.fn_formID = function() 
{
 var sUrl   = this.getOwnerFrame().formurl;
 var nStart = 0;
 var nIndex = sUrl.indexOf("::");
 if ( nIndex > - 1)
 {
    nStart = nIndex + 2;
 }
 
 var nEnd    = sUrl.indexOf(".xfdl");
 var sFromId = sUrl.substring(nStart, nEnd); 
    
 //In case if you have sub folder
 if (sFromId.indexOf("\\") > -1)
 {
  var arPath = sFromId.split("\\"); 
  sFromId    = arPath[arPath.length - 1];
 }
 return sFromId;
}

formurl, getOwnerFrame

Source Location

Sample\Sample_Script\np_Script_System_FormID.xfdl

User Function

Rather than using particular API we are providing samples using script.
User Function may be different according to customer, so we request to use after verification.

Sorting Array

Using sort method we can sort the array.

Script_User_ArraySort_0

Sort

Source Location

Sample\Sample_Script\np_Script_User_ArraySort.xfdl

Using the two-dimensional array

Script_User_TwoDemensionArray_0

Source Location

Sample\Sample_Script\np_Script_User_TwoDemensionArray.xfdl

Checking company registration number

Script_User_CheckBRN

Source Location

Sample\Sample_Script\np_Script_User_CheckBRN.xfdl

Checking Business Registration Number

Script_User_CheckCRN_0

Source Location

Sample\Sample_Script\np_Script_User_CheckCRN.xfdl

Checking Electronic mail (e-mail) Validity

Script_User_CheckEmail_0

Source Location

Sample\Sample_Script\np_Script_User_CheckEmail.xfdl

Checking Null in the input values

Script_User_CheckNull_0

Source Location

Sample\Sample_Script\Script_User_CheckNull.xfdl

Checking Social Security Number

Script_User_CheckSSN_0

Source Location

Sample\Sample_Script\np_Script_User_CheckSSN.xfdl

Finding Gender from Social Security Number

Script_User_SSNToGender_0

Source Location

Sample\Script\np_Script_User_SSNToGender.xfdl

Implementing the decode function

Script_User_Decode_0

Source Location

Sample\Sample_Script\np_Script_User_Decode.xfdl

Implementation of the ternary operator

Script_User_Iif_0

Source Location

Sample\Sample_Script\np_Script_User_Iif.xfdl

Including common script

Script_User_IncludeScript_0

Source Location

Sample\Sample_Script\np_Script_User_IncludeScript.xfdl

Converting undefined to ""

Script_User_UndefineToNull_0

Source Location

Sample\Sample_Script\np_Script_User_UndefineToNull.xfdl

Calculating age.

Script_User_WestenAge_0

Source Location

Sample\Sample_Script\np_Script_User_WestenAge.xfdl