cint and left function

Results 1 to 2 of 2

Thread: cint and left function

  1. #1
    Join Date
    Dec 1969

    Default cint and left function

    is there any similar function in javascript that can be used to replace the cint and left function in vbscript?<BR><BR>Its urgent, any help will be very much appreciated..

  2. #2
    Richard A. Lowe Guest

    Default Have to create one...

    ... which I did for you, CInt:<BR><BR>&lt;script language="JScript" runat="server"&gt;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// does what you probably want:<BR>&nbsp;&nbsp;&nbsp;&nbsp;function CastInt(varInput) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;return Math.round(new Number(varInput));<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR ><BR>&nbsp;&nbsp;&nbsp;&nbsp;// does what Cint really does<BR>&nbsp;&nbsp;&nbsp;&nbsp;// rounds even #&#039s down, odd<BR>&nbsp;&nbsp;&nbsp;&nbsp;// #&#039s up:<BR>&nbsp;&nbsp;&nbsp;&nbsp;function CastIntTrue(varInput) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;return ((Math.floor(varInput) % 2) == 0) ? (Math.floor(varInput)) : (Math.floor(varInput+0.5));<BR>&nbsp;&nbsp;&nbsp;& nbsp;}<BR><BR>&lt;/script&gt;<BR><BR>And Left:<BR>&lt;script language="JScript" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;func tion JSLeft(strInput, intChars) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;return strInput.slice(0, intChars);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&lt;/script&gt;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts