AVFPhtml.HTMLTable - Two hard coded constants wrong - v3.05

Topics: Developer Forum, User Forum
Dec 10, 2007 at 7:31 PM
In the HTMLTable(), there are two numeric constants that are wrong.

Near the end of the function there is a STUFF() statement that reads:
lcHTMLtable =STUFF(lcHTMLtable, lnAtPos1, lnAtPos2 - lnAtPos1+;
LEN(lcTableTag)+9, lcHTML)

The numeric "9" is the incorrect one. In this context, lnAtPos1 is the position of the first char of the tabletag (the start of "<"), lnAtPos2 is the position of the end tabletag (the start of "<" again). So the number of chars to replace is lnAtPos2 - LnAtPos1 + len(lcTableTag) + 3

A few lines below, you are handling the "<Pages>" tag. Then you replace that with two STUFF() statements within the IF. The length of 13 chars is only right if the tag markers have been "<" and ">", but the length is incorrect if the tag markers were "<" and ">", then the length should be 7.

lnAtPos = ATC("<Pages>",lcHTMLtable)
IF lnAtPos = 0
lnAtPos = ATC("<Pages>",lcHTMLtable)
ENDIF
IF ! EMPTY(lcPages) .AND. lnAtPos > 0
lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,lcPages)+crlf
ELSE
lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,"")+crlf
ENDIF


Best regards,
Palli
Coordinator
Dec 11, 2007 at 7:45 PM
Cool! But how did you catch this - was it outputting for you incorrectly??
I've never noticed any problem but that's not to say the HTMLtable method is perfect...

Palli wrote:
In the HTMLTable(), there are two numeric constants that are wrong.

Near the end of the function there is a STUFF() statement that reads:
lcHTMLtable =STUFF(lcHTMLtable, lnAtPos1, lnAtPos2 - lnAtPos1+;
LEN(lcTableTag)+9, lcHTML)

The numeric "9" is the incorrect one. In this context, lnAtPos1 is the position of the first char of the tabletag (the start of "<"), lnAtPos2 is the position of the end tabletag (the start of "<" again). So the number of chars to replace is lnAtPos2 - LnAtPos1 + len(lcTableTag) + 3

A few lines below, you are handling the "<Pages>" tag. Then you replace that with two STUFF() statements within the IF. The length of 13 chars is only right if the tag markers have been "<" and ">", but the length is incorrect if the tag markers were "<" and ">", then the length should be 7.

lnAtPos = ATC("<Pages>",lcHTMLtable)
IF lnAtPos = 0
lnAtPos = ATC("<Pages>",lcHTMLtable)
ENDIF
IF ! EMPTY(lcPages) .AND. lnAtPos > 0
lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,lcPages)+crlf
ELSE
lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,"")+crlf
ENDIF


Best regards,
Palli

Dec 12, 2007 at 12:04 AM
I had some strange problems with the HTMLtable right from the start of my project. Could never quite figure it out, but at one point I just couldn't get one of my tables output correctly.

Finally I just gave up, as it was either that I wasn't understanding the framework correctly, or there must be an error. Sounds obvious... there must be an error :-)

Made a copy of HTMLTable method and a few others to a .PRG file, remoted "This." references and isolated the section in my HTML file that woldn't work. Just plain simply debugged the method in the debugger!

Found the "+9" error first, but I see that the other error with the Pages tag isn't displayed correctly in the discussion group, but it should be self explainatory while looking at the source code.

My suggested fix for the latter (regarding len=13) error is to put the searched for tag in a local variable and then doing lnAtPos = ATC(lcLocalVar, lcHTMLtable). Then you can do a Stuff(lcHTMLtable,lnAtpos,LEN(lcLocalVar),lcPages ....

Anyway, are there any fixes, changes, additions... in the pipes for ActiveVFP ?

Palli
Dec 12, 2007 at 12:06 AM
Edited Dec 12, 2007 at 12:07 AM
Sorry, accidentally made a double post !
Coordinator
Dec 12, 2007 at 1:33 AM
Thanks!
The updates planned for ActiveVFP are listed under the Issue Tracker section above. If you'd like to take a crack at any of them or just improve methods like HTMLtable, i could add you as a Developer.

Palli wrote:
I had some strange problems with the HTMLtable right from the start of my project. Could never quite figure it out, but at one point I just couldn't get one of my tables output correctly.

Finally I just gave up, as it was either that I wasn't understanding the framework correctly, or there must be an error. Sounds obvious... there must be an error :-)

Made a copy of HTMLTable method and a few others to a .PRG file, remoted "This." references and isolated the section in my HTML file that woldn't work. Just plain simply debugged the method in the debugger!

Found the "+9" error first, but I see that the other error with the Pages tag isn't displayed correctly in the discussion group, but it should be self explainatory while looking at the source code.

My suggested fix for the latter (regarding len=13) error is to put the searched for tag in a local variable and then doing lnAtPos = ATC(lcLocalVar, lcHTMLtable). Then you can do a Stuff(lcHTMLtable,lnAtpos,LEN(lcLocalVar),lcPages ....

Anyway, are there any fixes, changes, additions... in the pipes for ActiveVFP ?

Palli


Dec 12, 2007 at 9:03 AM
Hi !

Well, I've allready made a contribution to the HTMLTable, so worst case scenario will be that I will not contribute any more, so yes, maby it's a good idea to be added as a developer.

I will be using the framework for a few weeks now, and could be that I find something more, or get some ideas.

You probably need to send me some info on how to behave as a developer in this project, like how to set up for the source code and other setup needed :-)


Palli
Coordinator
Jan 26, 2008 at 4:22 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.