Talk:AJAX - Return Arrays and Structs to your JavaScript with XML: Difference between revisions

m
Amendment
m (Amendment)
m (Amendment)
Line 14: Line 14:
 
 
Is it because VDF does not ACTUALLY destroy and objects untill it gets to end_function ? because returning a handle to something you have just destroyed doesn't look quite right ? ie you are returning a handle to nothing or something that might still exist at that point ?
Is it because VDF does not ACTUALLY destroy and objects untill it gets to end_function ? because returning a handle to something you have just destroyed doesn't look quite right ? ie you are returning a handle to nothing or something that might still exist at that point ?
: Akennard - try typing "paXML" into the VDF Help Index (that's all I did, using VDF 14.0 Help) and you will get a page which includes the following: "<font color="red">''Note: This property allocates memory for the data and it is therefore important that the data be disposed of when you are done. This is done using the Free() function.''</font>" This is the clue to what is going on: you have an XML object (hoXML is a reference to this) which you later destroy, but calling paXML has a specific (and ''documented''!!!) side effect: "<font color="red">''This property <u>allocates</u> memory...''</font>" (which, IMO, makes it a function/method, not a property... but then I'm picky!) - and into that memory it then <u>copies</u> the XML of the object it was called on (although the documentation does not explicitly state this, it does clearly imply it), so it is independent of that object and does not disappear when you "Destroy" it, which is why you need to manually "Free()" the memory when you are done.
: Hence you are not returning a handle to an object you have destroyed, but a pointer to a lump of memory containing a copy of the XML that was in that object... so not so strange!  [[Image:Wink.jpg]]
: HTH.
: --[[User:Mikepeat|Mike]] 15:38, 15 January 2009 (UTC)
----
VDF has a special XmlHandle return type for returning a hoXML object and the tidying up after itself
VDF has a special XmlHandle return type for returning a hoXML object and the tidying up after itself
Is there a reason why this has not been used in this case ? eg would this work for AJAX ?
Is there a reason why this has not been used in this case ? eg would this work for AJAX ?
Line 33: Line 44:
   Send AddElement of hoRoot "propercase" (Uppercase(Left(sName,1))+lowercase(Right(sName,(length(sName)-1))))
   Send AddElement of hoRoot "propercase" (Uppercase(Left(sName,1))+lowercase(Right(sName,(length(sName)-1))))
   Function_Return hoXML  // runtime will transfer and then destroy this object because of XMLHandle return type
   Function_Return hoXML  // runtime will transfer and then destroy this object because of XMLHandle return type
  End_Function  // NameChanges
  End_Function  // NameChanges
: Akennard - try typing "paXML" into the VDF Help Index (that's all I did, using VDF 14.0 Help) and you will get a page which includes the following: "<font color="red">''Note: This property allocates memory for the data and it is therefore important that the data be disposed of when you are done. This is done using the Free() function.''</font>" This is the clue to what is going on: you have an XML object (hoXML is a reference to this) which you later destroy, but calling paXML has a specific (and ''documented''!!!) side effect: "<font color="red">''This property <u>allocates</u> memory...''</font>" (which, IMO, makes it a function/method, not a property... but then I'm picky!) - and into that memory it then <u>copies</u> the XML of the object it was called on (although the documentation does not explicitly state this, it does clearly imply it), so it is independent of that object and does not disappear when you "Destroy" it, which is why you need to manually "Free()" the memory when you are done. HTH.
: --[[User:Mikepeat|Mike]] 15:38, 15 January 2009 (UTC)


== I believe using JSon is a much better match. ==
== I believe using JSon is a much better match. ==