[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => mxstu [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 3 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> ... [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => crux_online [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> Arrays/Structures in CFLOOP - Coldfusion Database Access

Arrays/Structures in CFLOOP - Coldfusion Database Access

From the code below you can see basically what I am trying to accomplish: to set up a CFLOOP from an earlier query, an insert some permutation of the RETRIEVED data into the name of the variable itself. For example, if the datum retrieved is 'fred', then the name of the variable would be 'Event.fred' or something similar. Naturally, I can entertain Array-based (or really, ANY) solutions, but structures seem more powerful and easier to use in a dynamic environment. Thanks a lot, Robert Nicholas <cfset Event=NewStruct()> <cfloop query="getEvents"> <cfset Event.[date of the event]=getEvents.EventSchedDate </cfloop>...

  1. #1

    Default Arrays/Structures in CFLOOP

    From the code below you can see basically what I am trying to accomplish: to
    set up a CFLOOP from an earlier query, an insert some permutation of the
    RETRIEVED data into the name of the variable itself.

    For example, if the datum retrieved is 'fred', then the name of the variable
    would be 'Event.fred' or something similar.

    Naturally, I can entertain Array-based (or really, ANY) solutions, but
    structures seem more powerful and easier to use in a dynamic environment.

    Thanks a lot,

    Robert Nicholas



    <cfset Event=NewStruct()>
    <cfloop query="getEvents">
    <cfset Event.[date of the event]=getEvents.EventSchedDate
    </cfloop>

    crux_online Guest

  2. #2

    Default Re: Arrays/Structures in CFLOOP

    You have to specify the rownumber, like this:
    <cfset Event.[date of the event]=getEvents.EventSchedDate[currentrow]>


    Originally posted by: crux_online
    From the code below you can see basically what I am trying to accomplish: to
    set up a CFLOOP from an earlier query, an insert some permutation of the
    RETRIEVED data into the name of the variable itself.

    For example, if the datum retrieved is 'fred', then the name of the variable
    would be 'Event.fred' or something similar.

    Naturally, I can entertain Array-based (or really, ANY) solutions, but
    structures seem more powerful and easier to use in a dynamic environment.

    Thanks a lot,

    Robert Nicholas





    Dan Bracuk Guest

  3. #3

    Default Re: Arrays/Structures in CFLOOP

    crux_online,

    I'm assuming your attached code is just psuedo-code. You already understand
    the basic idea. Exactly what problem are you are having?



    <!--- where ... "EventPerson" is column containing "Fred", etc.. --->
    <cfset Event = StructNew()>
    <cfloop query="getEvents">
    <cfset Event[EventPerson] = getEvents.EventSchedDate>
    </cfloop>
    <cfdump var="#Event#">

    mxstu Guest

  4. #4

    Default Re: Arrays/Structures in CFLOOP

    Your assumptions are sound: it was pseudocode.

    I did actually get it to work with some tinkering and it seems pretty well
    preamlined. I simply remembered a little queary parameter called #CurrentRow#
    and the light came on, so to speak.

    I'm attaching the final code. Here's a quick run-down of the purpose of the
    page:

    This page creates a dynamic calendar whose dates are calculated based on the
    current day (highlighted), whose fisrt week is always the present week (and
    always displays a 5-week span), and whose event contents are retrieved from a
    database and displayed by an icon (icon for a uniform and icon for the type of
    event). Description of the event are then listed below the calendar.

    Seems to be working wonderfully now. Now that I have decent functionality,
    eye candy ensues.

    Thanks,

    Robert Nicholas




    <cfloop query="getEvents">
    <cfset Events[currentrow] = getEvents.EventSchedDate[currentrow]>
    <cfset ToolTip[currentrow] = getEvents.EventToolTip[currentrow]>
    <cfset Time[currentrow] = getEvents.EventStartTime[currentrow]>
    <cfset Desc[currentrow] = getEvents.EventDesc[currentrow]>

    <!--- Assign the proper uniform to the 'iconUOD' variable.
    This variable with be used wherever the icon for the
    Uniform of the Day is invoked. --->
    <cfswitch expression="#LCase(getEvents.EventUOD)#">
    <cfcase value="bdu"><cfset iconUOD[currentrow]="bdu"></cfcase>
    <cfcase value="class a"><cfset iconUOD[currentrow]="a"></cfcase>
    <cfcase value="class b"><cfset iconUOD[currentrow]="b"></cfcase>
    <cfcase value="pt"><cfset iconUOD[currentrow]="pt"></cfcase>
    <cfcase value="civilian casual"><cfset iconUOD[currentrow]="civ"></cfcase>
    <cfcase value="business casual"><cfset iconUOD[currentrow]="biz"></cfcase>
    </cfswitch>

    <!--- Assign the proper icon for the day's events. --->
    <cfswitch expression="#LCase(getEvents.EventType)#">
    <cfcase value="regular meeting"><cfset iconType[currentrow]="reg"></cfcase>
    <cfcase value="field trip"><cfset iconType[currentrow]="trip"></cfcase>
    <cfcase value="award ceremony"><cfset iconType[currentrow]="award"></cfcase>
    <cfcase value="promotion"><cfset iconType[currentrow]="promo"></cfcase>
    <cfcase value="competition"><cfset iconType[currentrow]="comp"></cfcase>
    <cfcase value="test"><cfset iconType[currentrow]="test"></cfcase>
    <cfcase value="sar/cpr/fa"><cfset iconType[currentrow]="sar"></cfcase>
    <cfcase value="powered o-flight"><cfset iconType[currentrow]="pof"></cfcase>
    <cfcase value="party/celebration"><cfset
    iconType[currentrow]="party"></cfcase>
    <cfcase value="physical fitness test"><cfset
    iconType[currentrow]="pt"></cfcase>
    <cfcase value="glider o-flight"><cfset iconType[currentrow]="gof"></cfcase>
    </cfswitch>
    </cfloop>

    ...

    <!--- Insert the appropriate icon into the physical calendar.
    Hover over the UOD icon for the event's tooltip. --->
    <cfif Events[indexEvent] EQ dODBCCurrentDay>
    <img src="/img/cal.uod.#iconUOD[indexEvent]#.gif" border="0"
    title="#Time[indexEvent]#: #ToolTip[indexEvent]#" /></a>
    <img src="/img/cal.event.#iconType[indexEvent]#.gif" border="0"
    title="#Time[indexEvent]#: #ToolTip[indexEvent]#" />
    <cfif indexEvent LT getEvents.RecordCount><cfset
    indexEvent=indexEvent+1></cfif>
    </cfif>

    crux_online Guest

Similar Threads

  1. Web Services and structures
    By lusancea@gmail.com in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: March 9th, 07:21 AM
  2. Nesting Arrays within arrays.
    By JimmySlam in forum Macromedia Flash Ad Development
    Replies: 3
    Last Post: March 15th, 09:42 AM
  3. Assigning structures to arrays
    By JonathanBigelow in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: March 24th, 11:16 AM
  4. Shopping cart with arrays and structures
    By maddiel in forum Macromedia ColdFusion
    Replies: 3
    Last Post: February 25th, 05:37 PM
  5. structures vs classes
    By Gian U. Uy in forum ASP.NET Web Services
    Replies: 3
    Last Post: November 29th, 04:21 PM

Bookmarks

Posting Permissions

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