Forum > General
HelpNDoc.com and Pascal
(1/1)
paule32:
Hello,
currently, I play with the Help authoring Tool www.HelpNDoc.com and its Pascal Script Editor and Pascal Engine.
I can use TStringList, but I would like implement a own Version of this Class.
For this, I have the following Code:
--- 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";}};} ---unit GenericTemplate; interface type TVariantType = ( vtEmpty, vtBoolean, vtChar, vtInteger, vtString ); TVariant = record VarType = record vtBoolean: Boolean; vtChar: Char; vtInteger: Integer; vtString: String; end; end; type TStringNode = class(TObject) public data: string; prev, next: TStringNode; constructor Create(const p: TStringNode; const n: TStringNode); overload; constructor Create(const p: TStringNode); overload; constructor Create; overload; end; type TStringArray = class(TObject) private PNode: TStringNode; Head: TStringNode; FCount: Integer; public constructor Create(InitialSize: Integer = 0); procedure Add(const AValue: String);(* function Get(Index: Integer): String; procedure SetValue(Index: Integer; const Value: String);*) function Count: Integer; end; implementation { TStringNode } constructor TStringNode.Create;begin inherited Create; prev := nil; next := nil;end; constructor TStringNode.Create(const p: TStringNode);begin inherited Create; if p = nil then raise Exception.Create('TStringNode is nil'); prev := p; next := nil;end; constructor TStringNode.Create(const p: TStringNode; const n: TStringNode);begin inherited Create; if p = nil then raise Exception.Create('TStringNode parent is nil.'); if n = nil then raise Exception.Create('TStringNode next is nil.'); prev := p; next := n;end; { TStringArray } constructor TStringArray.Create(InitialSize: Integer);var idx: Integer;begin inherited Create; for idx := 0 to initialsize do begin Print(idx); Add(IntToStr(idx) + ': 11'); end;end; procedure TStringArray.Add(const AValue: String);var n, p: TStringNode;begin if PNode = nil then PNode := TStringNode.Create; p := PNode; n := TStringNode.Create; n.data := AValue; PNode.next := n; PNode.prev := p;end; function TStringArray.Count: Integer;var p: TStringNode;begin p := PNode; while True do begin if p.prev = nil then break; print(p.data); p := PNode.prev; end; result := FCount;end; initializationvar sa: TStringArray; Print('start...'); sa := TStringArray.Create(2); try sa.count; finally sa.Free; Print('done.'); end;end.
But when I try to "add" Strings to the Array Class, I stuck into a infinite loop when I try to read out the Elements.
So, my Question is now: how can I Add and print Elements when I use next and prev ?
The problem is, I can not use records, because I run into problems with:
--- 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";}};} ---foo = record next: foo;end;
foo will not evulate.
And I can not use Pointers like:
--- 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";}};} ---Pfoo = ^TFoo;TFoo = FoFo;
Thanks for helping hands
PascalDragon:
--- Quote from: paule32 on February 08, 2025, 05:36:17 pm ---
--- 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";}};} ---procedure TStringArray.Add(const AValue: String);var n, p: TStringNode;begin if PNode = nil then PNode := TStringNode.Create; p := PNode; n := TStringNode.Create; n.data := AValue; PNode.next := n; PNode.prev := p;end;
But when I try to "add" Strings to the Array Class, I stuck into a infinite loop when I try to read out the Elements.
So, my Question is now: how can I Add and print Elements when I use next and prev ?
--- End quote ---
Your Add method is incorrect. Also you're not using your Head field at all. Try this (not tested):
--- 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";}};} ---procedure TStringArray.Add(const AValue: String);var n, p: TStringNode;begin n := TStringNode.Create; n.Data := AValue; n.Prev := PNode; if Assigned(PNode) then PNode.Next := n; PNode := n; if not Assigned(Head) then Head := PNode;end;
--- Quote from: paule32 on February 08, 2025, 05:36:17 pm ---And I can not use Pointers like:
--- 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";}};} ---Pfoo = ^TFoo;TFoo = FoFo;
--- End quote ---
Why can't you?
paule32:
--- Quote from: PascalDragon on February 08, 2025, 06:36:05 pm ---
--- 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";}};} ---Pfoo = ^TFoo;TFoo = FoFo;
--- End quote ---
Why can't you?
[/quote]
This is by Design from the Authors of HelpNDoc - I had make a Request, but it is Weekend.
And I don't know if they provide Support, because HelpNDoc is commercial.
Maybe I should stay at doxygen ...
Navigation
[0] Message Index