Is Defined and Dynamic Application Variables

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Is Defined and Dynamic Application Variables

    Hi I'm trying to create dynamic variables in the application scope and then
    check for variables existance using the Is Defined function. Basically I check
    to see if a application variable is defined if it is then I add a value to the
    existing value (creating a comma seprated list in the application scope).
    However if the variable does not yet exist I want to create it and add a value
    to it. The code I have been using is: <CFARGUMENT NAME='varA'
    REQUIRED='Yes'> <CFARGUMENT NAME='varB' REQUIRED='Yes'> <cfif Not
    IsDefined('application.grproom.room#varB#')> <cfset
    application['grp.grp#varB#'] = #varA#> <cfset message = 'Is not defined'>
    <cfelse> <cfset application['grp.grp#varB#'] =
    ListAppend(application['grp.grp#varB#'], #varA#)> <cfset message = 'Is
    Defined, new element added'> </cfif> I've tried defining and checking the
    variables in a number of methods and I know I'm not too far off getting it
    nailed, but I've hit a brickwall. Can anyone help? Thanks Matt

    Flashm@n Guest

  2. Similar Questions and Discussions

    1. Application (doc_connect/room_01) is not defined.
      Hi im trying to get the sample file doc_connect to show but i keep getting this error. Anyone know why and how i cna get around it? Here is the...
    2. Scope of variables defined in text objects
      What's the scope of a variable assigned to a text object? Its own timeline, _root, or what?
    3. Perl defined variables
      Hi, could anybody please illustrate with an example the use of the following variables : $/ $* or more specifically here is the code i have....
    4. undefined reference ... expected to be defined in a dynamic image
      I'm running a Mac: 10.3 with perl 5.8.1. I can't seem to get HTML::parser-3.35 working. Running make seems to be OK--no errors (see below). ...
    5. Global variables - application variables vs include file
      What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include...
  3. #2

    Default Re: Is Defined and Dynamic Application Variables

    You are not working with plain Application variables, rather elements of a
    structure stored in Application scope. Try something like this: <cfif Not
    StructKeyExists(Application.prgroom, '#varB#')> <cfset
    application.grp['grp#varB#'] = varA> <cfset message = 'Is not defined'>
    <cfelse> <cfset application.grp['grp#varB#'] =
    ListAppend(applicationgrp['grp#varB#'], varA)> <cfset message = 'Is Defined,
    new element added'> </cfif>

    TA-Selene Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139