Recent

Author Topic: Help with HelpnDoc scripts ?  (Read 417 times)

avc_2023

  • Newbie
  • Posts: 2
Help with HelpnDoc scripts ?
« on: March 30, 2023, 07:01:06 pm »
Hi everyone.

My programming skills are quite rusty and i am trying to maintain and modify some scripts used where i work.
I'm fairly new to this software called HelpnDoc.
I'm trying to be able to export a .twt made of the list of the topics with their tags.

With the help on another forum i found the a function which should be what i'm loonking for.

GetTagsAssociatedWithTopic(const aTopicId: string): TStringDynArray;

Problem : the type.
Wheren i try in the "var" section something like
Code: Pascal  [Select][+][-]
  1. TagsArray:TStringDynArray

Code: Pascal  [Select][+][-]
  1. Unknown type : TStringDynArray

I found something here https://www.freepascal.org/docs-html/rtl/types/tstringdynarray.html but when i try to use it
Code: Pascal  [Select][+][-]
  1. Record required
  2.  
for
Code: Pascal  [Select][+][-]
  1. aTags:=HndTopicsTags.GetTagsAssociatedWithTopic(aTopicId);  

My whole code :

Code: Pascal  [Select][+][-]
  1. type
  2.     TStringDynArray = array of String;
  3. const
  4.   OUTPUT_FILE = 'C:\topics.txt';
  5. var
  6.  
  7.   aTopicId: string;
  8.   aTags: TStringDynArray;
  9.   aTagsString: string;
  10.   i : integer;
  11.   j:integer ;
  12.  
  13.   aList: TStringList;
  14.  
  15. begin
  16.  
  17.   aList := TStringList.Create;
  18.   aList.Add('Topic Caption | Help ID | Help Context | Tags');
  19.   aList.Add('---------------------------------------------');
  20.   try
  21.  
  22.     aTopicId := HndTopics.GetTopicFirst();
  23.  
  24.     while aTopicId <> '' do
  25.     begin  
  26.    
  27.         aTags:=HndTopicsTags.GetTagsAssociatedWithTopic(aTopicId);            
  28.         for i:=0 to aTags.count-1 do
  29.         Begin
  30.            aTagsString:= aTagsString + aTags[i];
  31.         end;
  32.       // Add the topic to the list
  33.       aList.Add(Format('%s | %s | %d | %s ', [
  34.         HndTopics.GetTopicCaption(aTopicId),
  35.         HndTopics.GetTopicHelpId(aTopicId),
  36.         HndTopics.GetTopicHelpContext(aTopicId),
  37.         aTagsString
  38.       ]));
  39.       aTags.free;
  40.       // Get next topic
  41.       aTopicId := HndTopics.GetTopicNext(aTopicId);
  42.     end;
  43.  
  44.     aList.SaveToFile(OUTPUT_FILE);
  45.   finally
  46.     aList.Free;
  47.   end;
  48. end.


« Last Edit: March 30, 2023, 07:04:25 pm by avc_2023 »

cdbc

  • Hero Member
  • *****
  • Posts: 1026
    • http://www.cdbc.dk
Re: Help with HelpnDoc scripts ?
« Reply #1 on: March 30, 2023, 07:32:08 pm »
Hi
With arrays, the syntax is like this:
Code: Pascal  [Select][+][-]
  1. for i:=0 to aTags.count-1 do  // <--- this is for lists etc..
  2.         Begin
  3.            aTagsString:= aTagsString + aTags[i];
  4.         end;
  5. ...
  6. aTags.free; // <--- this too is for lists...
  7.  
  8. // instead use this:
  9. for I:= low(aTags) to high(aTags) do
  10.   begin
  11.     aTagsString:= aTagsString + aTags[i];
  12.   end;
  13. ...
  14. Setlength(aTags,0);
  15.  
Hth - Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

avc_2023

  • Newbie
  • Posts: 2
Re: Help with HelpnDoc scripts ?
« Reply #2 on: March 31, 2023, 10:10:27 am »
My skills are indeed very rusty.
Thank you very much for your help.

jcmontherock

  • Full Member
  • ***
  • Posts: 234
Re: Help with HelpnDoc scripts ?
« Reply #3 on: March 31, 2023, 10:32:39 am »
You can use as well:

Insert(Value, MyArray, Length(MyArray));
Windows 11 UTF8-64 - Lazarus 3.2-64 - FPC 3.2.2

 

TinyPortal © 2005-2018