Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New type of impossible recursion
Message
De
24/11/2015 11:31:11
 
 
À
23/11/2015 04:51:09
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01627786
Message ID:
01627851
Vues:
132
>Working on the bestest everest method of churning html from fox, I decided the tag attributes are best handled as a simple collection. Then the style attribute would be another collection of the same kind, ergo same class just a different .toString() method. Here's what eventually worked:
>
>
DEFINE CLASS props AS COLLECTION
>	oStyle=null
>	*[2015/11/23 10:34:06] ndragan - must add it this way. Adding a member of its own class in .init
>	* or with Add Object gives "insufficient stack space"
>	PROCEDURE oStyle_access()
>	IF isnull(this.oStyle)
>		this.oStyle=CREATEOBJECT("props")
>	ENDIF
>	RETURN this.oStyle
>*---------------------------------------------------
>	PROCEDURE setAttribute(tcAttr, tcValue)
>		LOCAL o
>		IF NOT EMPTY(THIS.GETKEY(tcAttr))
>			o=THIS.ITEM(tcAttr)
>		ELSE
>			o=CREATEOBJECT("empty")
>			ADDPROPERTY(o, "name", tcAttr)
>			THIS.ADD(o,tcAttr)
>		ENDIF
>		ADDPROPERTY(o, "value", tcValue)
>*---------------------------------------------------
>	PROCEDURE GetAttribute(tcAttr)
>		TRY
>			o=THIS.ITEM(tcAttr)
>			lcVal=GETPEM(o, "value")
>		CATCH
>			lcVal=""
>		ENDTRY
>		RETURN lcVal
>
>*---------------------------------------------------
>	PROCEDURE tostring()
>		LOCAL loItem
>		LOCAL c
>		c=""
>		FOR EACH loItem IN THIS FOXOBJ
>			c = c + TEXTMERGE([ <<loItem.name>>="<<loitem.value>>"])
>		ENDFOR
>		IF THIS.oStyle.COUNT>0
>			c = c + TEXTMERGE([ style="<<this.oStyle.toStyle()>>"])
>		ENDIF
>		RETURN c
>*---------------------------------------------------
>	PROCEDURE toStyle()
>*-- dn 2015/11/20 separate version for items in the style="..."
>		LOCAL c
>		c=""
>		FOR EACH loItem IN THIS FOXOBJ
>			c = c + TEXTMERGE([<<loItem.name>>:<<loitem.value>>;])
>		ENDFOR
>		RETURN c
>
>ENDDEFINE
>
>Note the remark in the ostyle_access method. First I had a "add object oStyle as props", then removed that and had .init() with this.oStyle=createobject("props"). Both banged gloriously with "insufficient stack space", IOW I managed to have recursion before the object has finished building itself :). Now it doesn't happen every year now that I find something new that you can't do in fox :).
>
>The week has started well :).

Recursion require an end condition.
Where is the end condition here ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform