Re: [twsocket] Error when building an answer page
On 01-Set-2014 17:48, Florian Hector wrote: Way cool, this finally worked. It works, but it's pretty inefficient code. I suppose you already have a tag=value list, with the values already converted to string, so you should have a look how the AnswerPage function works, and create your own Answer method. Probably have your tag=value list implemented already in TStringIndex, and call the HtmlPageProducerFromMemory directly. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
> Supposing you have a stringlist filled this way: > > TagValueList.Values['Date']:=DateToStr(Date); > TagValueList.Values['Time']:=TimeToStr(Time); > > You can convert this list to an array of TVarRec using this code: > > setlength(tags,TagValueList.count*2); > i:=0; > while i begin > tags[i].VType:=vtPChar; > tags[i].Vpchar:=pointer(strnew(pchar(TagValueList.Names[i]))); > tags[i+1].VType:=vtPChar; > tags[i+1].Vpchar:=pointer(strnew(pchar(TagValueList.ValueFromIndex[i]))); > inc(i,2); > end; > > ClientCnx.AnswerPage(Flags,'','','status.html',nil,tags); > > for i:=low(tags) to high(tags) do > strdispose(tags[i].vpchar); Way cool, this finally worked. Thank you very much Florian -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
On 31-Ago-2014 18:12, Florian Hector wrote: No luck with all sorts of ways. When I define the tags statically at design time and step through the code, the content of the variable TAGS is much different from when it is done at runtime. Supposing you have a stringlist filled this way: TagValueList.Values['Date']:=DateToStr(Date); TagValueList.Values['Time']:=TimeToStr(Time); You can convert this list to an array of TVarRec using this code: setlength(tags,TagValueList.count*2); i:=0; while ihttp://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
> Tags[0]=Tag1 > Tags[1]=Value1 > Tags[2]=Tag2 > Tags[3]=Value2 No luck with all sorts of ways. When I define the tags statically at design time and step through the code, the content of the variable TAGS is much different from when it is done at runtime. > > Why do you need to build the tags dynamically? I try to provide a function where I can define a page with tags w/o prior knowledge of number and names of the tags. The application can hold 1, 10, 100... variables. The definition (number and names) of the variables is defined by the user, hence known at runtime, so the user can define his own template with the tags he is interested in. The template is used when creating the virtual document. At runtime, the application knows both the name and the value of all variables, all of them go into the definition of the tags when creating the virtual document and are thus available if defined in the template or not. Florian -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
On 31-Ago-2014 15:11, Florian Hector wrote: Would you have an example of how you assign a pair of values to this array of TVarRec. In pseudocode Tags[0]=Tag1 Tags[1]=Value1 Tags[2]=Tag2 Tags[3]=Value2 Why do you need to build the tags dynamically? -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
> That tags parameters needs to have an even number of elements ([Tag,Value]) > and to create that tags > parameter at runtime you have to use an *array of TVarRec* variable. Would you have an example of how you assign a pair of values to this array of TVarRec. Florian -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Error when building an answer page
On 31-Ago-2014 10:07, Florian Hector wrote: However, when I try to build the tags dynamically at runtime as string or stringlist That tags parameters needs to have an even number of elements ([Tag,Value]) and to create that tags parameter at runtime you have to use an *array of TVarRec* variable. If you aren't doing that already, this may help. https://groups.google.com/forum/#!topic/borland.public.delphi.language.delphi.general/RzD7i8eA0cE -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be