0

I am new to coldfusion. I have a program I am learning to maintain, and I need help. The CF app has many .cfm pages in its app directory, and many of these start out with statements. Probably not the best practice, but need to resolve this issue first.

Example CodeFromApp.cfm, starts with:

<cfif IsDefined("Form.FieldName")>
    <cfset thisFieldName = Form.FieldName>
<cfelse IsDefined('FieldNameParm">
    <cfset thisFieldName = FieldNameParm>
</cfif>

What would be the best and easiest way to find out, which .cfm file the Form.FieldName is referencing from. I am hoping I do not have to go through 50 .cfm pages with many having thousands of line of codes and comments in them

WeJava
  • 31
  • 6
  • See if you can narrow it down by using your code editor or notepad++ to search *.cfm files for `FieldName` within a form post. – SOS Mar 07 '22 at 18:04
  • 1
    Thank you for the response. Been doing in and its a long process. I was hoping there was an advanced ways that could just help me in one shot. Do you think the form in form.fieldname could be nothing because in certain files i found the fieldname but it was not attached to any form tags – WeJava Mar 07 '22 at 18:27
  • Well there are ways to improve search expressions (regex) and with some tools you could build a list of what to search for ie `IsDefined("Form.{DynamicName}")` then feed that list into another search (find term `{DynamicName}` in files). *Do you think the form in form.fieldname could be nothing* Maybe? Anything's possible. I worked on an app that did that kind of thing ... dynamically... with evaluate() *shudders* so it never would've showed up in a search. – SOS Mar 07 '22 at 19:10
  • OT: it would have been better if they would have stayed using `form` scoped variables. All this is an example of why. – James A Mohler Mar 07 '22 at 19:22
  • Sadly a lot of the examples in the old documentation tended to gave the impression you needed to create new variables instead of just using the one you already had. At least this code doesn't loop through form.fieldnames using evaluate() like one legacy app I inherited. Oh rapture.... – SOS Mar 09 '22 at 07:37

0 Answers0