Forum > General

storing string

(1/4) > >>

Medhome:
Hi All
How to store a  string into tag propertie of an object for example   in TButton.tag
Regards
Med

cdbc:
Hi

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TButton.tag:= ptrint(strnew('yourstringhere'));Regards Benny

Medhome:
Thanks. But How to retrieve ?
Med

cdbc:
Hi

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var p: pchar;begin  p:= pchar(TButton.Tag);  Caption:= string(p);  strDispose(p);end; Regards Benny

Remy Lebeau:
Here is a slightly cleaner way without resorting to StrNew()/StrDispose():


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// to store a new string...var tag: Pointer;tag := nil;string(tag) := 'yourstringhere';TButton.Tag := PtrInt(tag);

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// to retrieve the stored string...var tag: Pointer;tag := Pointer(TButton.Tag);Somestring := string(tag);

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// to update the stored string...var tag: Pointer;tag := Pointer(TButton.Tag);string(tag) := 'yourstringhere';TButton.Tag := PtrInt(tag);

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// to release the stored string when done using the Tag...var tag: Pointer;tag := Pointer(TButton.Tag);string(tag) := '';TButton.Tag := 0;

Navigation

[0] Message Index

[#] Next page

Go to full version