Asc

Description

Returns the ASCII value (character code) of the first character of a string. Returns 0 if string is empty.

Category

String functions

Syntax


Asc(string) 

See also

Chr

Parameters

Parameter
Description
string
A string

Example

<!--- This code illustrates ASC --->

<html>

<head>

<title>

Asc Example

</title>

</head>



<body bgcolor = silver>

<H3>Asc Example</H3>

<!--- if the character string is not empty, output its ascii value --->

<cfif IsDefined("FORM.charVals")>



  <cfif FORM.charVals is not "">

    <cfoutput>#Left(FORM.charVals,1)# = 

     #Asc(FORM.charVals)#</cfoutput>

  <cfelse>

<!--- if it is empty, output an error message --->

    <H4>Please enter a character</H4>

  </cfif>

</cfif>



<form action = "asc.cfm" method = "POST">

<P>Type in a character to see its ASCII value

<BR><input type = "Text" name = "CharVals" size = "1" MAXLENGTH = "1">

<P><input type = "Submit" name = ""> <input type = "RESET">

</FORM>



</body>

</html>    





Banner.Novgorod.Ru