Canalblog
Editer l'article Suivre ce blog Administration + Créer mon blog
Publicité
Développeur fou
26 février 2008

JScript test 2

//==============================================================================
//         PS_LPad
//------------------------------------------------------------------------------
// Description     : Left fills the input string until a specified length
// Input        : szString        -> input string to pad
//                  szChar            -> character to add
//                  nLength            -> final length of the string
// Output        :    the lpadded string
//==============================================================================
function PS_LPad(szString, szChar, nLength)
{

  try
  {
        if (szChar.length > 0)
      {
        var szLength = szString.length;   
         szString += '';    // convert to string for sure
         var slen = szString.length;
         for (var i=0; i < nLength - slen; i++)
      {
        szString = szChar + szString;
         }
    }
  }
  catch (e)
  {
      // Handle exception
  }

  return szString;   
}

Publicité
Publicité
Commentaires
Développeur fou
Publicité
Publicité