• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can an argument be defined outside a function?

New Here ,
Feb 01, 2007 Feb 01, 2007

Copy link to clipboard

Copied

I have several functions that all require the same cfarguments. Is there a way to define those arguments in one place and have them shared by several functions? I've looked around in the forums and so far the closest option I've found is to create a struct of arguments and deal with them from there. However, I'm still a little hazy as to what I would do with the struct once passed. Any help would be greatly appreciated.

Thanks,
--Anne
TOPICS
Advanced techniques

Views

258

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Feb 01, 2007 Feb 01, 2007
you could store those arguments in a struct...and store the struct in the application or session scope (depending on usage).

pass the struct in as "argumentcollection".

let's say your struct is in the application scope as 'myArgumentsStruct'.

<cfset myVar = myCFCInstance.myFunction(argumentcollection=application.myArgumentStruct) />

in the function itself, each key in the argumentcollection structure becomes a distinct argument.

see:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001051.htm

Votes

Translate

Translate
Guest
Feb 01, 2007 Feb 01, 2007

Copy link to clipboard

Copied

you could store those arguments in a struct...and store the struct in the application or session scope (depending on usage).

pass the struct in as "argumentcollection".

let's say your struct is in the application scope as 'myArgumentsStruct'.

<cfset myVar = myCFCInstance.myFunction(argumentcollection=application.myArgumentStruct) />

in the function itself, each key in the argumentcollection structure becomes a distinct argument.

see:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001051.htm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 01, 2007 Feb 01, 2007

Copy link to clipboard

Copied

I have never ever tried anything like this and I have no idea if it will
work. But feel free to give it a try.

arguments_inc.txt
--------
<cfargument ...>
<cfargument ...>
<cfargument ...>

aFunction.cfm
<cffunction ...>
<cfinclude template="arguments_inc.txt">
...
</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 01, 2007 Feb 01, 2007

Copy link to clipboard

Copied

Awesome, just what I was looking for. Thanks! 😃

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 01, 2007 Feb 01, 2007

Copy link to clipboard

Copied

LATEST
> I have never ever tried anything like this and I have no idea if it will
> work. But feel free to give it a try.

Bet ya five quid it doesn't ;-)

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation