Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Repeated calls to custom class method causes Page Fault
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Repeated calls to custom class method causes Page Fault
Divers
Thread ID:
00184056
Message ID:
00184056
Vues:
74
I have created a custom class to return html code as text for an input tag for use in creating html pages for a web server.

I'm sure I could find a class that does this job for me, or I could use standard VFP classes to produce the code and save them as HTML. But this is a learning excersize as well, and I'd sure like to know where I screwed this up.

OK, I create an object from the class as such:

oText1 = CreateObject("HtmlClass.Input") && create an instance
oText1.Type = "TEXT" && Assign input tag type
oText1.Text = "Text Value" && assign input tag value
oText1.FieldName = "TEXT1" && assign input tag name
? oText1.Html() && returns the html code for the complete tag
? oText1.Html() && CAUSES AN INVALID PAGE FAULT

Now for the great part of the excersize: It naturally causes VFP to unload, AND it causes a memory leak. When I restart VFP a few times and do the above, the computer will no longer have enough memory left to load _any_ applications, and I am forced to restart the machine.

Any ideas?

Here's the operative piece, I hope it's not too much (or too little) information:

FUNCTION Html
PRIVATE cHtmlCode, cOutput, nError, cErrMessage
cHtmlCode = ""
cOutput = ""
WITH This
IF !EMPTY(.Controlsource)
.Value = EVAL(.Controlsource)
ENDIF
IF TYPE(".Caption") # "C"
.Caption = " "
ENDIF
cHtmlCode = CRLF +;
TAB + [ .HtmlAttr("NAME", .FieldName) +;
.HtmlAttr("TYPE", .Type)
DO CASE
CASE UPPER(.TYPE) = "CHECKBOX"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text)
CASE UPPER(.TYPE) = "HIDDEN"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text)
CASE UPPER(.TYPE) = "IMAGE"
cHtmlCode = cHtmlCode + .HtmlAttr("Src", .Src)
CASE UPPER(.TYPE) = "PASSWORD"
cHtmlCode = cHtmlCode + .HtmlAttr("Size", .Size) + ;
.HtmlAttr("MaxLength", .MaxLength)
CASE UPPER(.TYPE) = "RADIO"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text)
CASE UPPER(.TYPE) = "RESET"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text)
CASE UPPER(.TYPE) = "SUBMIT"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text)
CASE UPPER(.TYPE) = "TEXT"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text) + ;
.HtmlAttr("Size", .Size) + ;
.HtmlAttr("MaxLength", .MaxLength)
CASE UPPER(.TYPE) = "TEXTAREA"
cHtmlCode = cHtmlCode + .HtmlAttr("Value", .Text) + ;
.HtmlAttr("MaxLength", .MaxLength) + ;
.HtmlAttr("Cols", .Cols) + .HtmlAttr("Rows", .Rows)
CASE UPPER(.TYPE) = "FILE"
*!* This is a Netscape-only feature and not implemented here.
ENDCASE
cHtmlCode = cHtmlCode + [>] + CRLF
IF TYPE(".Caption") = "C"
cHtmlCode = cHtmlCode + .Caption + CRLF
ENDIF
DO CASE
CASE cOutput = "M" && Output dest. is Memo
REPLACE (pcHtmlOut) WITH EVAL(pcHtmlOut) + cHtmlCode
CASE cOutput = "C" && Output dest. is variable
STORE EVAL(pcHtmlOut) + cHtmlCode TO (pcHtmlOut)
CASE cOutput = "R" && Output dest. is calling program
RETURN cHtmlCode
ENDCASE
ENDWITH

FUNCTION HtmlAttr
PARAMETERS cAttributeName, vValue

cAttrString = ""
cAttrString = [ %AttrName%="%vValue%"]
cAttrString = STRTRAN(cAttrString, "%AttrName%", cAttributeName)
cAttrString = STRTRAN(cAttrString, "%vValue%", TRANS(vValue) )

RETURN cAttrString
JMB Multimedia--creators of top-quality database-driven web sites and multimedia presentations.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform