4 Replies Latest reply on Jul 13, 2017 6:33 PM by 務深56435747

    ColdFusion 2016 has modified the usage of CFloop tag.

    務深56435747

      We are migrating from ColdFusion 7 to ColdFusion 2016. When I used ColdFusion Code analyzer, I got the following error message. The specification of the code is unknown. Can anyone teach me?

       

      CFLOOP (9)

      ColdFusion 2016 has modified the usage of CFloop tag.

       

      Solution

      Check the usage of the tag CFloop.

      E:/wwwRoot/Extension/udf/Scr_UDF.cfm ⾏ 224

      ......

      <!--And sets the acquired value-operational years in array-->

      <cfloop index="date" to="#q.YM + 1#" from="#variable.nowYM#" step="-1" >

        • 1. Re: ColdFusion 2016 has modified the usage of CFloop tag.
          haxtbh Level 4

          ColdFusion Help | cfloop

           

          Cant see anything wrong with the loop you posted though.

          • 2. Re: ColdFusion 2016 has modified the usage of CFloop tag.
            務深56435747 Level 1

            Thank you for your instruction.
            I will send all contents of this file. Please confirm once again.
            Thank you.

             

             

            <cfinclude template="scr_check_UDF.cfm">

            <cfinclude template="scr_menu_UDF.cfm">

            <cfinclude template="scr_grid_UDF.cfm">

             

            <!---

            Function name: sanitizeInput

            Summary: Perform sanitization processing.

            Arguments: str: string: String to be sanitized

            Type: String: Type of sanitization

            Return value: ret: string: sanitized character string

            --->

            <cffunction name="sanitizeInput" returntype="string" access="public">

                <cfargument name="str" required="yes">

                <cfargument name="type" required="no">

                <cfset ret = arguments.str>

             

                <cfset argType = "">   

                <cfif isDefined("arguments.type") is "True">

                    <cfset argType = arguments.type>

                </cfif>

               

                <cfswitch expression=argType>

                    <cfcase value="html">

                        <cfset ret = REReplaceNoCase(ret, "<[^>]*>", "", "ALL")>

                    </cfcase>

                    <cfcase value="sql">

                        <cfset ret = REReplaceNoCase(ret, ",|'", "", "ALL")>

                    </cfcase>

                    <cfdefaultcase>

                        <cfset ret = REReplaceNoCase(ret, "<[^>]*>", "", "ALL")>

                        <cfset ret = REReplaceNoCase(ret, ",|'", "", "ALL")>

                    </cfdefaultcase>

                </cfswitch>

             

                <cfreturn ret>

            </cffunction>

             

            <!---

            Function name: chkUserAuth

            Summary: User authority check function

            Argument: str: string: Screen ID

            Return value: ret: boolean: true = Authorized false = No authorization

            --->

            <cffunction name="chkUserAuth" returntype="boolean" access="public">

                <cfargument name="str" type="string" required="yes">

             

                <cftry>

                    <cfset chkUserAtuhSql = "

                        SELECT

                            USER_ID

                        FROM

                            MA_AUTH

                        WHERE

                            USER_ID = '" & getLoginUser() & "'

                            AND SCRREP_ID = '" & str & "'

                            AND DELETE_FLG = '0'

                    ">

                    <cfquery name="rs" datasource="#request.dsn#">

                        <cfoutput>#PreserveSingleQuotes(chkUserAtuhSql)#</cfoutput>

                    </cfquery>

             

                <cfcatch>

                    <cfreturn false>

                </cfcatch>

                </cftry>

                <cfif #rs.Recordcount# EQ 0>

                    <cfreturn false>

                <cfelse>

                    <cfreturn true>

                </cfif>

               

            </cffunction>

             

            <!--- Check CSV output permission from login ID --->

            <cffunction name="getCsvAuth" returntype="boolean" access="private">

                <cfargument name="get_gid" required="yes" type="string">

               

                <cfquery name="csv_auth_rs" datasource="#request.dsn#">

                    SELECT

                        CSV_OUTPUT_AUTH_FLG

                    FROM

                        MA_AUTH

                    WHERE

                        USER_ID = '#getLoginUser()#'

                    AND SCRREP_ID = '#get_gid#'

                </cfquery>

                <cfif csv_auth_rs.recordCount EQ 0>

                    <cfreturn false>

                <cfelseif csv_auth_rs.CSV_OUTPUT_AUTH_FLG eq "1">

                    <cfreturn true>

                <cfelse>

                    <cfreturn false>

                </cfif>

            </cffunction>

             

            <!---

            Function name: getKbnList

            Summary: Acquire and return the code list of the class specified by argument from the name master

            Argument: kbn: string: category code

            : Flg_check: boolean: If TRUE, check the deletion flag

            : Str_in: string: comma separated value extraction condition

            Return value: ret: struct: result structure

            Cd: Generic type code

            Name: Generic type name 3 (Kanji abbreviation)

            --->

            <cffunction name="getKbnList" returntype="struct" access="public">

                <cfargument name="kbn" type="string" required="yes">

                <cfargument name="flg_check" type="boolean" required="no" default="true">

                <cfargument name="str_in" type="string" required="no" default="">

               

                <!--- Return structure structure --->

                <cfset retList = structnew()>

                <cfset structinsert(retList, "cd", ArrayNew(1), true)>

                <cfset structinsert(retList, "name", ArrayNew(1), true)>

               

                <!--- Set of blank lines --->

                <cfset retList.cd[1] = "">

                <cfset retList.name[1] = "">

             

                <!---If the argument is blank, it returns only blank lines--->

                <cfif arguments.kbn EQ "">

                    <cfreturn retList>

                </cfif>

               

                <cfset strCondition = "">

                <!---If an extraction condition is set, a WHERE clause is set--->

                <cfif str_in neq "">

                    <cfset strCondition = " AND A.GEN_PUR_KIND_CD IN (#str_in#)">

                </cfif>

             

                <!--- DDB search --->

                <cftry>        

                    <!--- Search records with category code argument kbn --->

                    <cfif flg_check eq true>

                        <cfquery name="getKbn" dataSource="#request.dsn#">

                            SELECT

                                A.GEN_PUR_KIND_CD AS CD,

                                A.GEN_PUR_KIND_NM_3 AS NAME

                            FROM

                                MT_NAME A

                            WHERE

                                A.CATEGORY_CD = '#kbn#'

                            AND A.DELETE_FLG = '0'

                            #strCondition#

                        </cfquery>

                    <cfelse>

                        <cfquery name="getKbn" dataSource="#request.dsn#">

                            SELECT

                                A.GEN_PUR_KIND_CD AS CD,

                                A.GEN_PUR_KIND_NM_3 AS NAME

                            FROM

                                MT_NAME A

                            WHERE

                                A.CATEGORY_CD = '#kbn#'

                                #strCondition#

                        </cfquery>

                    </cfif>

                   

                    <cfif #getKbn.recordcount# lte 0>

                        <!--- If no record was found --->

                        <cfreturn retList>

                    </cfif>

                    <cfcatch type="database">

                        <!--- Database error --->

                        <cfreturn retList>

                    </cfcatch>

                </cftry>

               

                <!--- Store acquired data in array --->

                <cfset i=1>

                <cfoutput query="getKbn">

                    <cfset i=i+1>

                    <cfset retList.cd[i] = CD>

                    <cfset retList.name[i] = NAME>

                </cfoutput>

               

                <cfreturn retList>

            </cffunction>

             

            <!---

            Function name: getTransYM

            Summary: Return processing year based on closing date master

            Argument: None

            Return value: ret: array: YYYYMM format processing year / month (character string)

            --->

            <cffunction name="getTransYM" returntype="array" access="public">

               

            <!--- Generate an array --->

            <Cfset variable.ret = arrayNew (1)>

            <!--- Get operation date --->

            <Cfset variable.nowDate = getOperationYMD ()>

            <!--- Obtain operation date --->

            <Cfset variable.nowYM = getTheMonth (variable.nowDate)>

            In the case of

            <!--- Index of Index --->

            <Cfset variable.index = 0>

            In the case of

            <Cftry>

            <!--- "Closing day master" reading --->

            <!--- Fastening day is less than current day, acquire latest closing date --->     

            <cfquery name="q" datasource="#request.dsn#" maxrows="1">

                        SELECT

                            YM

                        FROM

                            MT_TIE_DAY

                        WHERE

                            DELETE_FLG = '0'

                         AND

                            TIE_YMD < '#variable.nowDate#' 

                        ORDER BY

                            YM DESC

                    </cfquery>

             

            <!--- Data check --->

            <!--- Perform acquisition processing only when the acquired value is numeric & 6 digits --->

            <Cfif IsNumeric (# q. Y #) is true and len (# q. Y #) eq 6>

             

            <!--- Set acquisition value ~ operation year to array --->

            <Cfloop index = "date" to = "# q.YM + 1 #" from = "# variable.nowYM #" step = "- 1">

            In the case of

            <!--- Ignore except 1 to 12 in the last 2 digits --->

            <Cfif Right (date, 2) le 12 and Right (date, 2) ge 1>

            <!--- Set to array --->                

            <cfset variable.index = variable.index + 1>

                                <cfset variable.ret[variable.index] = date>                    

                            </cfif>

                                   

                        </cfloop>

             

                    </cfif>    

                           

                    <cfcatch type="database">

                        <!---If a DB exception occurs, it outputs an error in the log and returns false--->

                        <cfset variable.array = arrayNew(1)>

                        <cfset writeLog("FS0001", "SDC101.cfm", "setDistName", variable.array)>

                    </cfcatch>

                </cftry>   

               

                <!---When none of the data is registered--->

                <cfif variable.index eq 0> 

                    <!---Keep only the year of operation--->

                    <cfset variable.ret[1] = variable.nowYM>

                </cfif>

               

                <!---Return array type--->

                <cfreturn variable.ret>

               

            </cffunction>

             

            <!---

            Function name: getScrRepName

            Summary: Obtain the screen of the argument gId · the screen of the form ID · the form name

            Argument: gId: string: screen · form ID

            Return value: ret: string: screen / form name

            If the screen can not be found return null character

            --->

            <cffunction name="getScrRepName" returntype="string" access="public">

                <cfargument name="gId" required="yes">

               

                <cfset var ret = "">

             

                <!---Exit if gid is blank--->

                <cfif arguments.gId eq "">

                    <cfreturn ret>

                </cfif>

             

                <cftry>

                    <cfquery name="q" datasource="#request.dsn#">

                        SELECT

                            SCRREP_NM

                        FROM

                            MA_MENU

                        WHERE

                            SCRREP_ID = '#arguments.gId#'

                            AND DELETE_FLG = '0'

                    </cfquery>

                    <cfcatch>

                        <cfreturn ret>

                    </cfcatch>

                </cftry>

               

                <cfif q.recordcount eq 1>

                    <cfset ret = q.SCRREP_NM>

                </cfif>

               

                <cfreturn ret>

               

            </cffunction>

             

            <!----

            Function name: getLoginUser

            Summary: Retrieve the user ID of the currently logged-in user from the session variable

            Argument: None

            Return value: User ID

            --->

            <cffunction name="getLoginUser" returntype="string" access="public" output="no">

                <cfset var user_id = trim(session.user_id)>

                <cfreturn user_id>

            </cffunction>

            • 3. Re: ColdFusion 2016 has modified the usage of CFloop tag.
              BKBK Adobe Community Professional & MVP

              務深56435747  wrote

               

              <!--And sets the acquired value-operational years in array-->

              <cfloop index="date" to="#q.YM + 1#" from="#variable.nowYM#" step="-1" >

              You should replace the HTML comment with a ColdFusion comment:

               

              <!--- And sets the acquired value-operational years in array --->

              • 4. Re: ColdFusion 2016 has modified the usage of CFloop tag.
                務深56435747 Level 1

                Dear Mr.BKBK

                 

                Thank you for your solution.

                 

                I check the ColdFusion comment.

                 

                Thank you.