I think you meant to say if errors - skip to step 7 ;-)

*Bryan Stevenson*B.Comm.
President & CEO
Electric Edge Systems Group Inc. - makers of FACTS™
phone: 250.480.0642
cell: 250.920.8830
e-mail: [email protected] <mailto:[email protected]>
web: www.electricedgesystems.com <http://www.electricedgesystems.com> and www.fisheryfacts.com <http://www.fisheryfacts.com>

------------------------------------------------------------------------

Please consider the environment before printing this e-mail

-----CONFIDENTIALITY------
This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments.
On 14-11-10 12:22 PM, Jason Allen wrote:
Hi Guys,

I'm building a 'create user' CFC, and, while it works, I'm wondering if I'm approaching it correctly. I've created a compact version of the format I'm using. I basically cut out all but a single argument so the code was easier to see in full.

I have it split up into sections

1) Arguments
2) Declare local var structure
3) Declare return var structure
4) validate arguments
5) if errors, skip step 6
6) If no errors, attempt to create user
7) return results


Does this look ok?




<cffunction name="userCreate" hint="creates user" returntype="struct" output="no" access="remote" returnformat="json">
  <!--- arguments --->
<cfargument name="email" type="string" required="true" default="" hint="user's email" />


  <!--- declare local variables / non returned data --->
  <cfset var local = StructNew()>
  <cfset local.email = "#arguments.email#">
  <cfset local.userSalt = "">
  <cfset local.userSaltHash = "">
  <cfset local.folderID = "">


  <!--- declare returned variables needed --->
  <cfset userCreateResults = StructNew()>
  <cfset userCreateResults.error = 0>
  <cfset userCreateResults.userID = "">
  <cfset userCreateResults.emailNotEmptyError = 0>


  <!--- validate provided arguments --->
  <cfif trim(local.email) eq "">
    <cfset userCreateResults.error = 1>
    <cfset userCreateResults.emailNotEmptyError = 1>
  </cfif>

  <!--- Attempt to create user if no errors raised --->
  <cfif userCreateResults.error eq 0>
    <!--- do work here --->
  </cfif>


  <cfreturn userCreateResults>
</cffunction>
--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en

---
You received this message because you are subscribed to the Google Groups "Open BlueDragon" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en

--- You received this message because you are subscribed to the Google Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to