Skip to main content

Posts

Showing posts with the label functions

How to set a variable with name and value in ColdFusion

SetVariable() - set a variable with name and value SetVariable.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>SetVariable function example: how to set a variable with name and value</title> </head> <body> <h2 style="color:Crimson">SetVariable Function Example</h2> <cfset MyID=5> <cfset Setvariable("ID" & MyID,"Jones" )> <cfset SetVariable("City","Rome")> <cfoutput> <b>ID5:</b> #ID5# <br /> <b>City:</b> #City# </cfoutput> </body> </html> More ColdFusion examples CreateUUID() - create an Universally Unique Identifier (UUID) Decrypt() - decrypt a string that is encrypted using a standard encryption technique CreateObject() - create a coldfusion object (typ...

ColdFusion - Evaluate one or more string expressions dynamically

Evaluate() - evaluate one or more string expressions dynamically from left to right Evaluate.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Evaluate function example: how to evaluate one or more string expressions dynamically from left to right</title> </head> <body> <h2 style="color:Crimson">Evaluate Function Example</h2> <cfoutput> <b>Result of expression[(10+5)*5]:</b> #Evaluate((10+5)*5)# <br /> <b>Result of expression[(10+5+5)*5]:</b> #Evaluate((10+5+5)*5)# <br /> <b>Result of expression[(10+5)/5]:</b> #Evaluate((10+5)/5)# </cfoutput> </body> </html> More ColdFusion examples CreateUUID() - create an Universally Unique Identifier (UUID) Decrypt() - decrypt a string that is encrypted using a standar...

ColdFusion - Escape any double-quotation marks in the parameter and wraps the result in double-quotation marks

DE() - escape any double-quotation marks in the parameter and wraps the result in double-quotation marks DE.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DE function example: how to escape any double-quotation marks in the parameter and wraps the result in double-quotation marks</title> </head> <body> <h2 style="color:Crimson">DE Function Example</h2> <cfquery name="qBook" datasource="cfbookclub"> SELECT BookID, Title FROM BOOKS </cfquery> <table cellpadding="0" cellspacing="0"> <tr bgcolor="Green" align="center"> <td><b>BookID</b></td> <td><b>Title</b></td> </tr> <cfloop query="qBook"> <cfoutput>...

How to get meta data for a cfc (component) in ColdFusion

GetComponentMetaData() - get metadata for a cfc GetComponentMetaData.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>GetComponentMetaData function example: how to get metadata for a cfc (coldfusion component)</title> </head> <body> <h2 style="color:Crimson">GetComponentMetaData Function Example</h2> <cfset MyComponentMetaData=GetComponentMetaData("MyComponent")> <cfdump var="#MyComponentMetaData#" label="MyComponent.cfc MetaData" > </body> </html> MyComponent.cfc <cfcomponent output="no" Author="Jones" displayname="Math"> <cffunction name="Sum" access="remote" returntype="numeric" description="Sum two numbers"> <cfargument name="Va...

CreateObject() - How to create a ColdFusion object (type component)

CreateObject() - create a coldfusion object (type component) CreateObject.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CreateObject function example: how to create a coldfusion object (type component)</title> </head> <body> <h2 style="color:Crimson">CreateObject Function Example: Component</h2> <cfset MyObject=CreateObject("component","MyComponent")> <cfoutput> <b>MyObject.Sum(10,25):</b> #MyObject.Sum(10,25)# <br /><br /> </cfoutput> <cfdump var="#GetMetaData(MyObject)#" label="MyObject" > </body> </html> MyComponent.cfc <cfcomponent output="no" Author="Jones" displayname="Math"> <cffunction name="Sum" access="remo...

ColdFusion IIF() - How to use IIF function

IIF() function IIF.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IIF function example: how to use IIF function in coldfusion</title> </head> <body> <h2 style="color:Crimson">IIF Function Example</h2> <cfset DefaultColor="HotPink"> <cfoutput> <b>Default Color</b>: #IIF(IsDefined("DefaultColor"),DE(DefaultColor),DE("Green") )# </cfoutput> </body> </html> More ColdFusion examples GenerateSecretKey() - algorithm AES GetComponentMetaData() - get meta data for a cfc DE() - escape any double-quotation marks in the parameter and wraps the result in double-quotation marks SetVariable() - set a variable with name and value

ColdFusion CreateUUID() - How to create an Universally Unique Identifier (UUID)

CreateUUID() - create an Universally Unique Identifier (UUID) CreateUUID.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CreateUUID function example: how to create an Universally Unique Identifier (UUID)</title> </head> <body> <h2 style="color:Crimson">CreateUUID Function Example</h2> <cfset UUID=CreateUUID()> <cfoutput><b>Universally Unique Identifier: #UUID#</b></cfoutput> </body> </html> More ColdFusion examples Decrypt() - decrypt a string that is encrypted using a standard encryption technique Encrypt() - encrypt a string using a specific algorithm and encoding method GenerateSecretKey() - algorithm AES

ColdFusion Fix() - How to convert a real number to an integer

Fix() - convert a real number to an integer Fix.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Fix function example: how to convert a real number to an integer</title> </head> <body> <h2 style="color:hotpink">Fix Function Example</h2> <table style="color:LightGreen; background:Green;" border="1" bordercolor="DarkGreen"> <tr> <td style="font-weight:bold">Fix</td> <td style="font-weight:bold">Output</td> </tr> <tr> <td>#Fix(3.6)#</td> <td><cfoutput>#Fix(3.6)#</cfoutput></td> </tr> <tr> <td>#Fix(3.1)#</td> <td><cfoutput>#Fix(3.1)#</cfoutput></td> </...

ColdFusion Ceiling() - Get the closest integer that is greater than a specified number

Ceiling() - get the closest integer that is greater than a specified number Ceiling.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ceiling function example: how to get the closest integer that is greater than a specified number</title> </head> <body> <h2 style="color:hotpink">Ceiling Function Example</h2> <table style="color:LightGreen; background:Green;" border="1" bordercolor="DarkGreen"> <tr> <td style="font-weight:bold">Ceilig</td> <td style="font-weight:bold">Output</td> </tr> <tr> <td>#Ceiling(5.4)#</td> <td><cfoutput>#Ceiling(5.4)#</cfoutput></td> </tr> <tr> <td>#Ceiling(6.6)#</...