Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New type of impossible recursion
Message
From
23/11/2015 04:51:09
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
New type of impossible recursion
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01627786
Message ID:
01627786
Views:
197
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 :).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Next
Reply
Map
View

Click here to load this message in the networking platform