Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is equivalent syntex in Asp for Coldfusion <cfparam> tag

Status
Not open for further replies.

eSP

Programmer
Jun 9, 2000
1
IN
what is equivalent syntex in Asp for Coldfusion <cfparam> tag
 
Dear eSP,<br><br>Perhaps if you explain the &lt;cfparam&gt; tag's usage and outcome I could help.<br><br>Anyone else already know this?<br><br>-pete
 
Hi eSp,<br><br>Since Cold-Fusion is tag based ..so u get differrent tags ..i.e cfout..cfin..cfif..etc..etc..coz..i havent worked more in cfm..but in asp..everything is written in <br>&lt;% ur code here %&gt;<br>..or <br>&lt;script lang=&quot;javascript or vbscript&quot; runat=server..etc..&gt; code..<br>&lt;/script&gt;<br>so if u explain what actually u want ,then it would have been a lot simpler.<br>Regards<br>Vinod
 
Hullo,<br>CFParam is ( Alaires description not mine....)<br><br><br><br><i>CFPARAM is used to test for a parameter's existence, and optionally test its data type, and provide a default value if one is not assigned. <br><br>Syntax<br>&lt;CFPARAM NAME=&quot;param_name&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;TYPE=&quot;data_type&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;DEFAULT=&quot;value&quot;&gt;<br><br>NAME<br>The name of the parameter you are testing (such as &quot;Client.Email&quot; or &quot;Cookie.BackgroundColor&quot;). If you omit the DEFAULT attribute, an error occurs if the specified parameter does not exist. <br><br>TYPE<br>Optional. The type of parameter that is required. The default value is &quot;any.&quot;<br><br><br>&nbsp;Type Values&nbsp;&nbsp;<br>Type Value&nbsp;&nbsp;Description&nbsp;&nbsp;<br>any&nbsp;&nbsp;any value.&nbsp;&nbsp;<br>array&nbsp;&nbsp;any array value.&nbsp;&nbsp;<br>boolean&nbsp;&nbsp;a Boolean value.&nbsp;&nbsp;<br>date&nbsp;&nbsp;a date-time value.&nbsp;&nbsp;<br>numeric&nbsp;&nbsp;a numeric value.&nbsp;&nbsp;<br>query&nbsp;&nbsp;a query object.&nbsp;&nbsp;<br>string&nbsp;&nbsp;a string value or a single character.&nbsp;&nbsp;<br>struct&nbsp;&nbsp;a structure.&nbsp;&nbsp;<br>UUID&nbsp;&nbsp;a Universally Unique Identifier (UUID) formatted as `XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX' where `X' stands for a hexadecimal digit (0-9 or A-F). See CreateUUID.&nbsp;&nbsp;<br>variableName&nbsp;&nbsp;a valid variable name.&nbsp;&nbsp;<br><br><br>DEFAULT<br>Optional. Default value to set the parameter to if it does not exist. <br><br>Usage<br>There are three ways to use CFPARAM: <br><br>Test for a required variable -- Use CFPARAM with only the NAME attribute to test that a required variable exists. If the variable does not exist, ColdFusion server stops processing the page and returns an error. <br>Test for a required variable and for the type of variable -- Use CFPARAM with the NAME attribute and the TYPE attribute to test that a required variable exists, and that it is of the specified type. <br>Test for an optional variable -- Use CFPARAM with both the NAME and DEFAULT attributes to test for the existence of an optional variable. If the variable exists, processing continues and the value is not changed. If the variable does not exist, it is created and set to the value of the DEFAULT attribute. </i><br><br>I presume therefore that param is a variable?<br>Wouldn't have this problem in a strongly typed language i.e. Pascal, Fortran, Bulls**t, Boll**ks..<br>New to ASP but old to VB....<br><br>I trust this may help a bit....<br><br>Gram Nez<br><A HREF=" TARGET="_new">
 
eSP (or any other contributor),

Did you find an answer?

I've been searching the web like crazy and have found no real equivalent.

I suspect one has to look separately at the main uses of CFPARAM and find a functional equivalent (if any) for each. I think the 2 main uses of CFPARAM are:
* making sure you get all the Form / URL values needed to start processing a request.
* allowing you to use optional arguments for CF custom tags (or templates called by CFMODULE).

Form / URL values
-----------------
Form values in ASP are almost as easy as CFPARAM, because Request.Form returns a zero-length string (&quot;&quot;) if there is no such form variable. So for example:
Response.Write(&quot;Dummy: |&quot; & Request.Form(&quot;myVal&quot;) & &quot;|&quot;)
displays:
Dummy: ||
URL parameters are harder work in ASP because you have to parse Response.QueryString yourself and there's no built-in functionality which returns a zero-length string if the URL parameter was not supplied. But it's not hard to write a package of general-purpose functions which returns the actual value or a null string if none found. I'm working on one which uses a Scripting Dictionary object - created by
set myDict = New Server.CreateObject(&quot;Scripting.Dictionary&quot;)
The Scripting Dictionary object provides an associative array, which is how CF stores all variables any way.

Optional arguments for &quot;sub-routines&quot;
-------------------------------------
Depends whether you script in VBSCript or Javascript, but either way you can't treat all arguments as optional the way you can in CF.
VBScript does not allow optional arguments at all.
Javascript does in part, but with the restriction that, if any argument is present, all arguments to the left of it must be present. In Javascript you can code
if (typeof optional_arg == &quot;undefined&quot;) var optional_arg = &quot;&quot;;

Or have you found anything better?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top