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

Two problems

Explorer ,
Aug 07, 2007 Aug 07, 2007

Copy link to clipboard

Copied

My first problem might be the easier of the two. I have this function that accepts two named arguments and 3 additional unnamed ones. Depending on the value of the 4th argument (True or False) if passed in, the 5th argument is used.
My problem is, it seems to me that if the 4th argument is passed in as False, CF quits reading the arguments. I checked the length of Arguments array in the function and it always reads 4 (including the False) but ignores everything past this value.
Is this supposed to happen?
//Searches for tagname in str with attributes in array attarr.
//Returns start tag only if startOnly is True.
//If startOnly is False, and innerHTML is passed in, checks to see if the content between start tag and end tag matches this.
function getTag(str,tagname) //attarr,startOnly,innerHTML
{
}
//function call, page holds an html page I retrieved already, attarr is defined ArrayNew(2) earlier
attarr[1][1]="name";
attarr[1][2]="myForm";
form = getTag(page,"form",attarr);//This works and finds the form.
attarr[1][1]="name";
attarr[1][2]="error";
form = getTag(form,"label",attarr,False,"That name is already used."); //This fails, function says only 4 arguments passed in.


Second problem is insane. (imagine pulling hair out in clumps, red eyed, holding half empty energy drink)
500 Null, ooopps, the dreaded.
It always occurs when I'm using a regular expression that isn't 100% greedy. Let me give an example.
Here is a basic re to match html tags.
Notice the * after [^<]. This is the greedy form that works.
<#tagname#[^>]*>(([^<]*|[<](?!/#tagname#>))*)</#tagname#>
I want to know why I can't leave this greediness out, and have it match the zero or more subexpressions instead, but more importantly, I want to know how I can get CF to turn its head and cough.
I mean, how am I supposed to find out what is going wrong when it just displays 500 Null.
I did the comment dance and narrowed it down to this part of the re
([^<]|[<](?!/#tagname#))*
To me this reads, give me a character that is not < or give me one that is < as long as /#tagname# doesn't follow.
Now give me zero or more of these characters.
Am I wrong here? And is there a way to catch 500 Nulls at all? Just in case there is a problem in one of my re's that doesn't pop up in testing, but shows up in production. I want to shut the page down softly. Not abruptly. I appreciate the help.
Sorry for being long winded, but I've spent three days on these errors without any luck.
TOPICS
Advanced techniques

Views

276

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
Explorer ,
Aug 07, 2007 Aug 07, 2007

Copy link to clipboard

Copied

Can anyone help me?

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
Guide ,
Aug 08, 2007 Aug 08, 2007

Copy link to clipboard

Copied

Just to get the ball rolling, can you post more specifics about the function? I tried a simple test and the argument length is 5, not 4. Also, have you tried using cffunction / cfargument instead?

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
Explorer ,
Aug 08, 2007 Aug 08, 2007

Copy link to clipboard

Copied

I call this function but the arraylen(arguments) gt 4) part never executes. (Correction, it executes, but value is then overwritten!!!)
This function uses the hastag function to search and then strips the tag found out.
Makes it easy to loop through the file and process each of the tags I am looking for, one at a time.

>>>OMG>>> I just realized, when I added the 5th argument to this one, I forgot to change the if to else if, so after processing once it processes this one also!!! Sorry, about that. Any help with the RE problem and 500 Null?

function removeTag(str, tagname)
{
var tag = "";
if(ArrayLen(arguments) gt 4)
{
tag=hasTag(str,tagname,arguments[3],arguments[4],arguments[5]);
}
if (ArrayLen(arguments) gt 3)
{
tag = hasTag(str,tagname,arguments[3],arguments[4]);
}
else if (ArrayLen(arguments) gt 2)
{
tag = hasTag(str,tagname,arguments[3]);
}
else
{
tag = hasTag(str,tagname);
}
if (len(tag) GT 0)
{
return REReplace(str,tag,"","ONE");
}
else
{
return "";
}
}

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
Guide ,
Aug 08, 2007 Aug 08, 2007

Copy link to clipboard

Copied

LATEST
I don't know about the 500 null error. I would check the logs to see what information they contain about the error. Stupid question but have you tried catching the error (ie cftry/cfcatch or try/catch)?

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