Discussion:
[fpc-pascal] Directory Tree
James Richters via fpc-pascal
2021-04-06 10:29:13 UTC
Permalink
Does FPC include any tools to display a directory tree, similar to the way
files and folders are normally displayed, but I want to make my own custom
entries. Have the branches expand and collapse etc..
It doesn't have to be graphical, it can be text based.
Or Am I going to be better off going graphical with Lazarus for something
like this?

James
Tomas Hajny via fpc-pascal
2021-04-06 10:43:39 UTC
Permalink
On 2021-04-06 12:29, James Richters via fpc-pascal wrote:
> Does FPC include any tools to display a directory tree, similar to the
> way
> files and folders are normally displayed, but I want to make my own
> custom
> entries. Have the branches expand and collapse etc..
> It doesn't have to be graphical, it can be text based.
> Or Am I going to be better off going graphical with Lazarus for
> something
> like this?

Lazarus shall be a more appropriate choice for a graphical output. If
talking about text output, FPC package FV (FreeVision) contains an
object TDirListBox which allows traversing the directory tree, but it
doesn't provide a generic feature of collapsing / expanding (you can
expand just one directory).

Tomas
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://list
James Richters via fpc-pascal
2021-04-06 12:43:11 UTC
Permalink
Is there any documentation or a sample program for TDirListBox? I tried doing a search but only found a page that showed it's functions and procedures, but no real explanation on what they are supposed to do.
James

>FPC package FV (FreeVision) contains an object TDirListBox which allows traversing the directory tree, but it doesn't provide a generic feature of collapsing / expanding (you can expand just one directory).

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mai
Tomas Hajny via fpc-pascal
2021-04-06 13:41:11 UTC
Permalink
On 2021-04-06 14:43, James Richters wrote:
> Is there any documentation or a sample program for TDirListBox? I
> tried doing a search but only found a page that showed it's functions
> and procedures, but no real explanation on what they are supposed to
> do.

The functionality is used within the text mode IDE (sources are in
package IDE). In particular TChDirDialog (still part of FV, in
particular) is invoked using File / ChDir and it contains TDirListBox as
one of its subcomponents. The respective implementation is in the
include file fpmfile.inc (search for PChDirDialog). It's rather simple
(but it might be enhanced in a possible descendent, of course).

Tomas
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.fr
Jean SUZINEAU via fpc-pascal
2021-04-06 12:45:30 UTC
Permalink
As far as I understand, you are searching for a general tree component
like TTreeView in Lazarus, but for FreeVision, running in text mode in
console ?


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.
James Richters via fpc-pascal
2021-04-06 17:12:50 UTC
Permalink
I'm developing a new application where the user will need to select items from a tree structure.. I'm trying to figure out how to do the tree at all, and allow the user to select multiple files and/or folders. If the tree is going to be too complicated in text mode, then maybe I'll have to figure out Lazarus and go that way. I haven't even started the project yet, but this tree selection with the ability to expand or collapse branches is going to be a big part of it, so I'm trying to see what's available.

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Tuesday, April 6, 2021 8:46 AM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

As far as I understand, you are searching for a general tree component like TTreeView in Lazarus, but for FreeVision, running in text mode in console ?


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.f
James Richters via fpc-pascal
2021-04-08 01:04:22 UTC
Permalink
It looks like Lazarus is going to be the best way. I've been looking at TTreeView... but I'm not sure I can make it do what I want. I need to select multiple items in the tree at the same time, and then get a list of what has been selected. Is there a way to add checkboxes to the tree with TTreeView? Or is there a better tree object I should look at?

I am also wondering if there is some convenient method of saving a tree to some kind of data file, and later restoring the data file to the tree. It seems that since trees are all over the place that maybe there is already a built in way to load a data file that somehow designates the hierarchical order.

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of James Richters via fpc-pascal
Sent: Tuesday, April 6, 2021 1:13 PM
To: 'FPC-Pascal users discussions' <fpc-***@lists.freepascal.org>
Cc: James Richters <***@productionautomation.net>; 'Jean SUZINEAU' <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

I'm developing a new application where the user will need to select items from a tree structure.. I'm trying to figure out how to do the tree at all, and allow the user to select multiple files and/or folders. If the tree is going to be too complicated in text mode, then maybe I'll have to figure out Lazarus and go that way. I haven't even started the project yet, but this tree selection with the ability to expand or collapse branches is going to be a big part of it, so I'm trying to see what's available.

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Tuesday, April 6, 2021 8:46 AM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

As far as I understand, you are searching for a general tree component like TTreeView in Lazarus, but for FreeVision, running in text mode in console ?


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mail
Jean SUZINEAU via fpc-pascal
2021-04-08 10:55:32 UTC
Permalink
If you just select files, as Bart stated in another message, I think
TShellTreeView will be more adequate and easier than TTreeView (actually
TShellTreeView is a file tree specific descendent TTreeView).

In TTreeView (and TShellTreeView) you can enable multiselection by
adding tvoAllowMultiSelect in Options set (something like "with
TreeView1 do Options:=Options+[tvoAllowMultiSelect];"   or better by
just checking Options/tvoAllowMultiSelect in the Object inspector)

https://wiki.freepascal.org/TTreeView#Example_of_using_Multiple_Node_Selection_for_Multiple_User_Selections

If you want checkboxes, I think it's possible with TVirtualStringTree
from the VirtualTreeView package, it may be a bit harder to implement
(as far as  I remember you need your own data structure to store the
status of the tree) :

https://wiki.freepascal.org/VirtualTreeview

https://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus#Checkbox

VirtualTreeView package is included in Lazarus v2.0+, but I'm not sure
it's installed by default: if you don't find a tab "Virtual controls" in
your components, you may need to go to Package menu/Install packages,
select virtualtreeview_package 5.5.3.1 for installation and rebuild
Lazarus.

Here you should enable multiselection with something like

with VirtualStringTree1.TreeOptions do
SelectionOptions:=SelectionOptions+[toMultiSelect];

or by checking TreeOptions/SelectionOptions/toMultiSelect in the Object
inspector when your VirtualStringTree1 is selected.

(I've used VirtualTreeView a while ago, I didn't test checkboxes today)

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.fr
James Richters via fpc-pascal
2021-04-08 13:06:12 UTC
Permalink
The data I'm trying to display in the tree is a list of filename, but they aren't the names of the files on the disk, they are modified to include the time they take to run on a CNC machine. What I have is an INI file with a list like this:
[Files]
M:\Project1\File1=8:32
M:\Project1\File2=7:43
M:\Project1\File3=2:15
M:\Project2\Component1\Part1=5:32
M:\Project2\Component1\Part2=8:32
...

I want to display all these in a tree including run time appended at the end... I could just read the INI file as a text file and replace all the = with spaces. I need the to allow the user to open and collapse branches of the tree, Select either individual branches or separate files, and remember they are selected even if a branch is collapsed.. then when they hit a button, I get a TstringList of the selected files.. then I can just process the string list to generate a cut list and extract all the run times and give the user a total runtime needed.

The selections don't have to be checkboxes... things could just get highlighted and stay highlighted while other things are selected

I'm trying to keep this simple, as I have very little experience with Lazarus, or any GUI programming... I have 30+ years of Pascal, but only did very small simple projects with Lazarus.

I went to:
https://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus Where it states:
"The tutorial/docs can be downloaded from http://www.soft-gems.net. Below someone would find only the quick way to use VirtualTreeview on Lazarus, not explanations. For explanations and lots of other functions/methods, get the official documents and the tutorial."
But the link for the tutorial / docs doesn't have anything about VirtualTreeview anymore. Any idea if the full documentation exists anywhere?


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/list
Jean SUZINEAU via fpc-pascal
2021-04-09 23:35:55 UTC
Permalink
(I re-send my mail with different sender, it seem the first one has been
blocked by orange)

I made a short example based on TTreeView with your data at :

https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/tools/FileTree

You just need to download all the files , open project FileTree.lpi in
Lazarus and hit F9.

You can multi-select with Ctrl+Click and see you select with "Get
Selection" button.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailma
James Richters via fpc-pascal
2021-04-11 02:27:02 UTC
Permalink
Jean,
Thank you very much for the example! That gives me a great start and I really appreciate the effort you put in.
Thanks for re-sending it, the first one never came though.

I was able to replace the sample INI file with some of the real data and it all came in very nicely!

I'm curious if there is a way that I can make the selections with a normal left click.. or better yet make left-click toggle the selection?
So... the same as ctrl-click wihtout holding down control
I know the normal way you make multiple selections in Windows is with CTRL-Click, so I don't know is there is a way to change this that isn't super complicated.

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Friday, April 9, 2021 7:36 PM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@sfr.fr>
Subject: Re: [fpc-pascal] Directory Tree

(I re-send my mail with different sender, it seem the first one has been blocked by orange)

I made a short example based on TTreeView with your data at :

https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/tools/FileTree

You just need to download all the files , open project FileTree.lpi in Lazarus and hit F9.

You can multi-select with Ctrl+Click and see you select with "Get Selection" button.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepasca
Jean SUZINEAU via fpc-pascal
2021-04-11 13:23:26 UTC
Permalink
Indeed, I think it's difficult (if possible) to change the behaviour of
the multiselection this way.

The TTreeview.MultiSelectStyle property allows you to change from
CtrL+Click to Shift+Click.

https://lazarus-ccr.sourceforge.io/docs/lcl/comctrls/tmultiselectstyle.html

To make the multi selection with just a left click, I think the best way
would be to use the TVirtualTreeView with checkboxes.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas
James Richters via fpc-pascal
2021-04-11 15:29:26 UTC
Permalink
I had a feeling it wouldn't be easy to change, but thought I would ask. I like the selected items to be highlighted as they are in your TTreeview example.

I'm confused by your reference to slFiles.Names and slFiles.ValueFromIndex I am trying to see how those got defined. I see slFiles is a TStringList, I thought a TStringList was strictly a list of strings, but this seems to be more like a list of records, but don't see how the records were ever defined.. and I didn't know this was something you could even do with TStringList. In fact I like the records a lot better than just strings, but I'm trying to figure out how it was accomplished.

I'm also trying to figure out where the tree data is stored and if I can modify it? Once the tree is built, I would like to go through and modifiy all the parent names with the total times of all the children under the parent. Is this even possible with TTreeView? Or is this another reason I might use something else? Or will I have to re-build the input file to include the totals somehow?

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Sunday, April 11, 2021 9:23 AM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

Indeed, I think it's difficult (if possible) to change the behaviour of the multiselection this way.

The TTreeview.MultiSelectStyle property allows you to change from
CtrL+Click to Shift+Click.

https://lazarus-ccr.sourceforge.io/docs/lcl/comctrls/tmultiselectstyle.html

To make the multi selection with just a left click, I think the best way would be to use the TVirtualTreeView with checkboxes.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/c
Jean SUZINEAU via fpc-pascal
2021-04-11 18:22:33 UTC
Permalink
TStringList works pretty much like an inifile section.
The index corresponds to the line number in you text block.
The Names property corresponds to the part of the line before the '=' char.
The ValueFromIndex property corresponds to the part of the line after
the '=' char.
So if you line i contains "M:\Project1\File1=8:32", Names[i] will
returns "M:\Project1\File1" and ValueFromIndex returns "8:32"
The text block (property Text) is viewed like a kind of list of virtual
records "name=value"

You can iterate the nodes in the TreeView and change their text.

I have updated the example with a VirtualTreeView on a new form (you
should download all the files in a different directory).
It's more complex to implement, but with checkboxes you just need a
simple click.



_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/
Jean SUZINEAU via fpc-pascal
2021-04-11 22:53:29 UTC
Permalink
I have updated the VirtualTreeView example with sub-totals of time.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fp
James Richters via fpc-pascal
2021-04-13 11:50:06 UTC
Permalink
I tried to make a fork of your repository but I could not change off the master branch,, I always get an error: Checkout Failed Cannot checkout to invalid path 'tools/text_glCAPI\jsLignes.Exclus.txt' I suspect the / in the path is the problem because I am on Windows and it can only use \ for the path.. but I don't know how to fix it, so I just made my own repository of this so I can use GitHub.
The current version is at https://github.com/Zaaphod/FileTree

I noticed the time was in hours and minutes, but it's supposed to be in minutes and seconds, but sometimes it's in hours and minutes and seconds, so I tried to fix this.. it seems to be fixed ok for the totals, but to fix it I had to put the extra 0: in front of all my times so they are 0:03:20 instead of 3:20 I was able to display it the way I want in the totals, but I don't see how to change how it's displayed in the files.. so they are displaying with the extra 0: now.

Also my input INI File data is not sorted... so I sorted the Tstring list, that seemed to have worked.

But I noticed the VirtualTreeView is not building the tree correctly. I am getting
M:
Project 1
File 1
File 2
File 3
Project2
Component1
Part1
Part2
Project3
Part1
Part2
Part3
Part4
Part5
Part6
Part7

It should be
M:
Project 1
File 1
File 2
File 3
Project2
Component1
Part1
Part2
Project3
Part1
Part2
Part3
Part4
Part5
Part6
Part7

The TTreeView is correct. Any ideas why this is? I'm not sure if I broke something when I tried to fix the time to minutes and seconds... or if it has to do with the INI file not being sorted...

The program takes a while to load with a large datafile, is there a way to put up some kind of screen immediately, even just a box that says loading... just to let the user know the program was started so they don’t try to start it again? Or even more fun.. have a bargraph showing the progress through the INI file 😊 (something I have absoilutly no idea how to accomplish)

Thanks again for the help with this!

James


-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Sunday, April 11, 2021 6:53 PM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

I have updated the VirtualTreeView example with sub-totals of time.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pasc
Jean SUZINEAU via fpc-pascal
2021-04-13 16:34:51 UTC
Permalink
Le 13/04/2021 à 13:50, James Richters via fpc-pascal a écrit :
> I tried to make a fork of your repository but I could not change off the master branch,, I always get an error: Checkout Failed Cannot checkout to invalid path 'tools/text_glCAPI\jsLignes.Exclus.txt' I suspect the / in the path is the problem because I am on Windows and it can only use \ for the path.. but I don't know how to fix it, so I just made my own repository of this so I can use GitHub.
> The current version is at https://github.com/Zaaphod/FileTree
I've removed this file. I work  both with Linux and Windows, most of the
time it's ok, but it can happen when by mistake I commit some files with
weird names that can cause some havoc in git in Windows ... For example
the same file name but with differences in char case:

'tools/jsFichiers/JSFICHIERS_Resultat_du.txt'
'tools/jsFichiers/jsFichiers_Resultat_du.txt'

> I noticed the time was in hours and minutes, but it's supposed to be in minutes and seconds, but sometimes it's in hours and minutes and seconds, so I tried to fix this.. it seems to be fixed ok for the totals, but to fix it I had to put the extra 0: in front of all my times so they are 0:03:20 instead of 3:20 I was able to display it the way I want in the totals, but I don't see how to change how it's displayed in the files.. so they are displaying with the extra 0: now.

I've added a few lines to handle this.
Conversion from datetime to string  is in TTreeData.SetdValue, and
conversion from string to datetime is in TTreeData.SetValue.

> But I noticed the VirtualTreeView is not building the tree correctly. I am getting
I made an error in TfFileVirtualTree.vst_addnode_from_key_value:Recursif.
With "slNodes.AddObject( sCle, TObject(Parent));" , M:\Project1\File2
ended up in M: instead of M:\Project1
Corrected with : slNodes.AddObject( sCle, TObject(Node));
> The program takes a while to load with a large datafile, is there a way to put up some kind of screen immediately, even just a box that says loading... just to let the user know the program was started so they don’t try to start it again? Or even more fun.. have a bargraph showing the progress through the INI file 😊 (something I have absoilutly no idea how to accomplish)

I have added a gauge and a buttton to trigger the processing.

I find the execution relatively slow on Windows, I can see the
progression of the gauge.
On Ubuntu the result appears instantly, I can't see the progression of
the gauge ( and my linux machine is less powerful than my windows machine).

> Thanks again for the help with this!
With pleasure. I couldn't do this all the time, but it happens I have a
bit of free time for this these days.
James Richters via fpc-pascal
2021-04-14 11:06:03 UTC
Permalink
>I've removed this file. I work both with Linux and Windows, most of the time it's ok
I still can’t get off the Master branch on my windows machine. I deleted everything, re-forked it, re-cloned it,
and I still can’t check out any branch other than Master… It’s not that important I just re-downloaded all the files
from the github website.. but it’s tedious that way, I have to look at each file, then click on Raw then save as,
then get rid of the .txt it wants to put at the end..

>I've added a few lines to handle this.
>Conversion from datetime to string is in TTreeData.SetdValue, and conversion from string to datetime is in TTreeData.SetValue.
Thank you, that works better than what I was trying to do and now it displays the way I would like and the totals also come out correct.

>I have added a gauge and a buttton to trigger the processing.
Thanks, that works great!

>I find the execution relatively slow on Windows, I can see the progression of the gauge.
>On Ubuntu the result appears instantly, I can't see the progression of the gauge ( and my linux machine is less powerful than my windows machine
The real INI file has over 4000 entries in it, so it takes about 30 seconds to load, so the gauge is really helpful.


I added a Load Time edit box, Total Run time, and total including loading needed in the report… Yay I managed to do something on my own!
I also cleared the old tree when a new file was loaded.. so I managed to do two things 😊
I wanted my run time to be just minutes and seconds, so I made your procedure that fixes the time format into a function and used that for my edit box as well.
Since I still can't change branches on your repository, I updated mine
https://github.com/Zaaphod/FileTree

But now I have more questions…. while I can understand the pascal code… I find that I am still a bit lost on how things work, so I really appreciate the help.

I would like the initial display of the tree to be expanded one level.. so just like I hit the + in front of M: so I thought, how hard could that be? ...
well since I don't even see where hitting the + expands a level, and don't know the command to expand it or how to identify that first level.. I find I'm lost again
I've been going through Code Explorer and Object Inspector trying to figure out how this might be done, but I don't see how to find a command to expand a branch.

I also thought I would display the output in another tree in the right side of the split.. maybe a TTreeView Tree since it won't need checkboxes, and it could be just displayed already expanded all the way out.
o I thought I would start by making function TfFileVirtualTree.Get_Checked add the nodes to TTreeView so I tried to put
tv_addnode_from_key_value( td.Key, td.Value);
right before
Formate_Liste( Result, #13#10, td.Key+' '+td.Value);

Well it couldn't find tv_addnode_from_key_value() because it's in ufFileTree.Pas but I don't understand why it can't find it, because ufFileTRee is in the uses section of ufFileVirtualTree.
I did move procedure tv_addnode_from_key_value( _Key, _Value: String); from private to public.. but it still can't find it. I'm not really sure how to get data from one of the .PAS files into the other.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freep
Jean SUZINEAU via fpc-pascal
2021-04-15 00:11:46 UTC
Permalink
Le 14/04/2021 à 13:06, James Richters via fpc-pascal a écrit :
> I still can’t get off the Master branch on my windows machine. I deleted everything, re-forked it, re-cloned it,
I finally found on my linux machine a 'test_gICAPI\jsLignes.Exclus.txt'
file right in tools directory, and removed it. It has been generated by
a delphi program (with \ hardcoded for file path separator) that I
quickly recompile with lazarus under linux. The  \ is an escape sequence
in linux file names.
It seems it isn't a problem for TortoiseGit  on my Windows machine, he
just ignores it.
It should work for you now. I've tested several time checking out the
whole repository and switching to the TjsDataContexe branch
> I added a Load Time edit box, Total Run time, and total including loading needed in the report… Yay I managed to do something on my own!
> I also cleared the old tree when a new file was loaded.. so I managed to do two things 😊
> I wanted my run time to be just minutes and seconds, so I made your procedure that fixes the time format into a function and used that for my edit box as well.
> Since I still can't change branches on your repository, I updated mine
> https://github.com/Zaaphod/FileTree
>
> But now I have more questions…. while I can understand the pascal code… I find that I am still a bit lost on how things work, so I really appreciate the help.
>
> I would like the initial display of the tree to be expanded one level.. so just like I hit the + in front of M: so I thought, how hard could that be? ...
I have added a procedure vst_expand_first_level; for this .
> I also thought I would display the output in another tree in the right side of the split.. maybe a TTreeView Tree since it won't need checkboxes, and it could be just displayed already expanded all the way out.
> o I thought I would start by making function TfFileVirtualTree.Get_Checked add the nodes to TTreeView so I tried to put
> tv_addnode_from_key_value( td.Key, td.Value);
> right before
> Formate_Liste( Result, #13#10, td.Key+' '+td.Value);
>
> Well it couldn't find tv_addnode_from_key_value() because it's in ufFileTree.Pas but I don't understand why it can't find it, because ufFileTRee is in the uses section of ufFileVirtualTree.
> I did move procedure tv_addnode_from_key_value( _Key, _Value: String); from private to public.. but it still can't find it. I'm not really sure how to get data from one of the .PAS files into the other.

Even in public, you would have needed to call it as
fFileTree.tv_addnode_from_key_value , but it will have worked on the
TreeView  from fFileTree, which is not what you want. You can consider a
bit  a class as a record. If tv_addnode_from_key_value is defined in a
class TfFileTree, you can only call it on an instance of TfFileTree, in
this case fFileTree, the same way you would access to something defined
in a record.

Well, this lead me to a big refactoring. I move most of the code from
ufFileTree to  uFileTree.

I didn't put it in the interface of the unit, but you could now
eventually use procedure TreeView_addnode_from_key_value from uFileTree
for this.

I did the same for ufFileVirtualTree, creating a unit uFileVirtualTree
with a class ThVirtualStringTree dedicated to the handling of a
TVirtualStringTree.

This way I could add another VirtualTreeView with no checkboxs to
display the results. I think it's easier to use a VirtualTreeView to
manage your time sums.
The ThVirtualStringTree class allows to reuse the exact same code for
the result tree with time sums, and it allows reduce the complexity and
the amount of code in ufFileVirtualTree.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org
James Richters via fpc-pascal
2021-04-15 13:31:19 UTC
Permalink
>I finally found on my linux machine a 'test_gICAPI\jsLignes.Exclus.txt'
>...
>It should work for you now. I've tested several time checking out the whole repository and switching to the TjsDataContexe branch
It does work, but not perfectly. I'm using GitKracken and Github desktop. I am able to change to the TjsDataContexe branch now, but when I do, a lot of files show up in staged files as being removed, and I can't unstage them.. when I try, their case changes.. so an example is:
jsWorks/Generateur_de_code/04_Parametres/PROJECT.Details.txt if try to unstage the deleted file, it changes to
jsWorks/Generateur_de_code/04_Parametres/Project.Details.txt
there are 21 files like this all in jsWorks/Generateur_de_code/04_Parametres

>This way I could add another VirtualTreeView with no checkboxs to display the results. I think it's easier to use a VirtualTreeView to manage your time sums.
>The ThVirtualStringTree class allows to reuse the exact same code for the result tree with time sums, and it allows reduce the complexity and the amount of code in ufFileVirtualTree.
The two TVirtualStringTrees are very nice and keeping the file list above was a great idea.

A few questions, I hope you don't mind:

How did you make the TVirtualStringTree open the first level? I've been looking to see how you did it but I don't see how that was done.
I would like to have the second TVirtualStringTree expanded all the way out.

Is there a way to export the file list and the second TVirtualStringTree to a PDF file?

I would like to save settings to an INI file, things like window size, divider positions, ect.. I have done this with INI files in my console apps, I just write out every variable I want to save and read them back in.. but I'm curious if Lazarus is more sophisticated.. maybe it has a way to save all settings for a form by itself? Or do I do it the same way as my console app and save each variable myself?
Where is the proper place to load the INI file, where it would happen before the forms are displayed, and where is the proper place to save the INI file right before the program is closed?

Thanks again!

James

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.
Jean SUZINEAU via fpc-pascal
2021-04-15 16:20:11 UTC
Permalink
Le 15/04/2021 à 15:31, James Richters via fpc-pascal a écrit :
>
> How did you make the TVirtualStringTree open the first level? I've been looking to see how you did it but I don't see how that was done.
unit uFileVirtualTree, line 360,  method
ThVirtualStringTree.vst_expand_first_level;
> I would like to have the second TVirtualStringTree expanded all the way out.
it's easier, just : vst.FullExpand;
You'll find it line 373, method ThVirtualStringTree.vst_expand_full;

> Is there a way to export the file list and the second TVirtualStringTree to a PDF file?
As far as I know, there is no way to directly export it. I will have a
look if I have some time.
> I would like to save settings to an INI file, things like window size, divider positions, ect.. I have done this with INI files in my console apps, I just write out every variable I want to save and read them back in.. but I'm curious if Lazarus is more sophisticated.. maybe it has a way to save all settings for a form by itself? Or do I do it the same way as my console app and save each variable myself?
> Where is the proper place to load the INI file, where it would happen before the forms are displayed, and where is the proper place to save the INI file right before the program is closed?
From tab "Misc", just drop a TIniPropStorage on your form. You need to
set the ini filename in the component.
Then in the properties of the form, you'll find the SessionProperties
property with a "..." button on the right. This opens a dialog which
allows you to configure which properties of which components you want to
persist.

I have added this , configured for a "Configuration.ini" file and
"fFileTree" section.

The following link is for TXMLPropStorage, but it work nearly the same
for TIniPropStorage. Just read the first paragraph "Using
TForm.SessionProperties and TXMLPropStorage"
https://wiki.freepascal.org/Remember_form_position_and_size#Using_TForm.SessionProperties_and_TXMLPropStorage
James Richters via fpc-pascal
2021-04-15 18:16:34 UTC
Permalink
Thanks for the explanations and fixing your sample program. I thought there would probably be an easy way to save settings in an Ini File

>>Is there a way to export the file list and the second TVirtualStringTree to a PDF file?
>As far as I know, there is no way to directly export it. I will have a look if I have some time.
It doesn't have to be a PDF, it could be an image file, or even a text file...maybe I can just make a text file of the output and use box characters to draw the tree. It seems like I should be able to get the branches of the treedata somehow and just do a writeln to a file with the right formatting.

James


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listin
Jean SUZINEAU via fpc-pascal
2021-04-16 22:22:50 UTC
Permalink
Le 15/04/2021 à 20:16, James Richters via fpc-pascal a écrit :
> It doesn't have to be a PDF, it could be an image file, or even a text
> file...maybe I can just make a text file of the output and use box
> characters to draw the tree. It seems like I should be able to get the
> branches of the treedata somehow and just do a writeln to a file with
> the right formatting.

I have added a text rendering of the tree, it's saved in a text file
Result.txt.

The rendering code is in unit uFileVirtualTree, function
ThVirtualStringTree.render_as_text. It's called  in ufFileVirtualTree in
procedure TfFileVirtualTree.bGetCheckedClick:
     m.Lines .Text:= slResult.Text+#13#10+hvstResult.render_as_text;
     m.Lines .SaveToFile('Result.txt');

In function ThVirtualStringTree.render_as_text I used 3 constants for
the chars used for drawing the tree outline:
           vertical_line_char='|';
           horizontal_line_char='-';
           angle_char='*';
           crossing_char='L';
You can tune this to your needs.

I have added to a rendering as numbered list in an odt file, the text
file format for Libre Office and Open Office. The "template"
FileTree.odt is duplicated with a temp name in the user temp directory,
and opened in the software register in windows for opening odt files by
the function OpenDocument() of Lazarus. Depending on your installation
it can be open in Libre Office/OpenOffice or in MS Word (sometimes the
rendering is not perfect in Word).

Before recompiling the project, you will need to open first in Lazarus
the package pascal_o_r_mapping\02_Units\OD_DelphiReportEngine_Units.lpk
in order to make Lazarus know where it is.
If for some reason you can't load this package, you can remove it from
the dependency  panel of the project inspector, and in unit
ufFileVirtualTree, comment out in the use clause the unit
uFileVirtualTree_odt, and comment out in procedure
TfFileVirtualTree.bGetCheckedClick the line:
     OpenDocument( FileVirtualTree_odt( 'FileTree.odt', hvstResult));

I've considered making a screenshot of virtual tree component but if the
whole opened tree doesn't fit in the screen it will not work.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinf
James Richters via fpc-pascal
2021-04-17 20:16:38 UTC
Permalink
I tried
vertical_line_char=#179;
horizontal_line_char=#196;
angle_char=#192;
crossing_char=#195;

which are the appropriate ASCII box characters...

but it produces:
M: = 32:34
????Project1 = 18:30
? ????File1 = 8:32
? ????File2 = 7:43
? ????File3 = 2:15
????Project2 = 14:04
????Component1 = 14:04
????Part1 = 5:32
????Part2 = 8:32

I also tried
vertical_line_char=chr(179);
horizontal_line_char=chr(196);
angle_char=chr(192);
crossing_char=chr(195);

then I thought they must be Unicode.. so I tried the Unicode box characters:
vertical_line_char=$2502;
horizontal_line_char=$2500;
angle_char=$2514;
crossing_char=$251C;
but that gave me errors saying my constants were out of range and must be between 0 and 255... so if they have to be between 0 and 255, then they should be ACSII characters.. .so my original characters should have worked... so maybe it's just my text editor that's the problem...

is there a way we can maybe make it rich text format so the font can be specified? Then I could specify Consolas which is a fixed width font and get the box characters from that... or maybe there is a way to do this with the ODT file.

The ODT file opens in MS Word, but it doesn't draw the tree, it has text Like:
1
1.1 M: 32:34
1.1.1 Project1 18:30
1.1.1.1 File1 8:32
1.1.1.2 File2 7:43

Any ideas how to get box characters to work?

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Friday, April 16, 2021 6:23 PM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

Le 15/04/2021 à 20:16, James Richters via fpc-pascal a écrit :
> It doesn't have to be a PDF, it could be an image file, or even a text
> file...maybe I can just make a text file of the output and use box
> characters to draw the tree. It seems like I should be able to get the
> branches of the treedata somehow and just do a writeln to a file with
> the right formatting.

I have added a text rendering of the tree, it's saved in a text file Result.txt.

The rendering code is in unit uFileVirtualTree, function ThVirtualStringTree.render_as_text. It's called in ufFileVirtualTree in procedure TfFileVirtualTree.bGetCheckedClick:
m.Lines .Text:= slResult.Text+#13#10+hvstResult.render_as_text;
m.Lines .SaveToFile('Result.txt');

In function ThVirtualStringTree.render_as_text I used 3 constants for the chars used for drawing the tree outline:
vertical_line_char='|';
horizontal_line_char='-';
angle_char='*';
crossing_char='L';
You can tune this to your needs.

I have added to a rendering as numbered list in an odt file, the text file format for Libre Office and Open Office. The "template"
FileTree.odt is duplicated with a temp name in the user temp directory, and opened in the software register in windows for opening odt files by the function OpenDocument() of Lazarus. Depending on your installation it can be open in Libre Office/OpenOffice or in MS Word (sometimes the rendering is not perfect in Word).

Before recompiling the project, you will need to open first in Lazarus the package pascal_o_r_mapping\02_Units\OD_DelphiReportEngine_Units.lpk
in order to make Lazarus know where it is.
If for some reason you can't load this package, you can remove it from the dependency panel of the project inspector, and in unit ufFileVirtualTree, comment out in the use clause the unit uFileVirtualTree_odt, and comment out in procedure TfFileVirtualTree.bGetCheckedClick the line:
OpenDocument( FileVirtualTree_odt( 'FileTree.odt', hvstResult));

I've considered making a screenshot of virtual tree component but if the whole opened tree doesn't fit in the screen it will not work.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://li
Jean SUZINEAU via fpc-pascal
2021-04-18 00:07:04 UTC
Permalink
In Unicode/UTF8 "char" can be represented by several bytes so my code
won't work.

It seems you use page code 850 (here in France we are in 1252 which
doesn't have the box chars).

In unit uFileVirtualTree line 469, I have added   type String850= type
String(850);
declared the local variable s of String850 on line 488,

and changed on line 533 the default encoding of the Stringlist to 850 by
sl.DefaultEncoding:= TEncoding.GetEncoding(850);

It seems to be sufficient to get the box characters. I didn't dig
further but it seems to work either on Windows and Linux and in text
file generated.

In the ODT file I used a numbered list but  I think it will be difficult
to get something closer to a tree.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/
James Richters via fpc-pascal
2021-04-18 14:10:12 UTC
Permalink
Thanks for figuring that out.

I get uFileVirtualTree.pas(533,9) Error: identifier idents no member "DefaultEncoding"
For line: sl.DefaultEncoding:= TEncoding.GetEncoding(850);

If I just comment out that line, it works fine for me, because I'm codepage 850 anyway, but that doesn't help anyone else who may not be on 850

I’m getting this now: (not sure if the box characters will come though everyone’s email but they look right on my email)

M: = 32:34
├───Project1 = 18:30
│ │───File1 = 8:32
│ ├───File2 = 7:43
│ └───File3 = 2:15
└───Project2 = 14:04
└───Component1 = 14:04
├───Part1 = 5:32
└───Part2 = 8:32

It has the incorrect character in front of File1, It’s a vertical_line_char instead of a crossing_char.

I get the same thing on my large ini file.. and there is a pattern
 the last two files on a branch are always correct, and everything above that are not.. they are using the vertical line instead of a crossing character.. so if there are 7 files in the branch, the first 5 will be vertical lines , the 6th one will be the correct crossing character and the 7th will be the correct angle character.

Thank you again for the help!

James
-----Original Message-----
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Saturday, April 17, 2021 8:07 PM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

In Unicode/UTF8 "char" can be represented by several bytes so my code won't work.

It seems you use page code 850 (here in France we are in 1252 which doesn't have the box chars).

In unit uFileVirtualTree line 469, I have added type String850= type String(850); declared the local variable s of String850 on line 488,

and changed on line 533 the default encoding of the Stringlist to 850 by sl.DefaultEncoding:= TEncoding.GetEncoding(850);

It seems to be sufficient to get the box characters. I didn't dig further but it seems to work either on Windows and Linux and in text file generated.

In the ODT file I used a numbered list but I think it will be difficult to get something closer to a tree.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org <mailto:fpc-***@lists.freepascal.org> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Jean SUZINEAU via fpc-pascal
2021-04-18 15:07:26 UTC
Permalink
Le 18/04/2021 à 16:10, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree I getuFileVirtualTree.pas(533,9)
> Error: identifier idents no member "DefaultEncoding"
It seems, using svn blame, that DefaultEncoding has been added in
FreePascal source trunk on the svn server on June 4th 2019.

I don't know the version number of the fpc release following this date
but it's likely your lazarus/freepascal is older than mine.

I use currently Lazarus 2.0.12 / fpc 3.2.0.

> It has the incorrect character in front of File1,   It’s a
> vertical_line_char instead of a crossing_char.
I have corrected this point, it should work now.
James Richters via fpc-pascal
2021-04-18 15:22:47 UTC
Permalink
>I use currently Lazarus 2.0.12 / fpc 3.2.0.
I have Lazarus 2.04 / fpc 3.04 I have fpc 3.2.0 in another directory. It should be easy enough for me to re-install Lazarus. Thanks for figuring that out!
>I have corrected this point, it should work now.
Yes it looks fixed even in my large data file. Thank you.

I figured out how to make a pdf file, but I don’t know how to implement it
 if we can just have a button to print result.txt
 then I could just change the printer to Microsoft Print to PDF which is included with Widows 10
.

James
Jean SUZINEAU via fpc-pascal
2021-04-21 21:46:22 UTC
Permalink
Le 18/04/2021 à 17:22, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
> I figured out how to make a pdf file, but I don’t know how to
> implement it
 if we can just have a button to print result.txt
 then I
> could just change the printer to Microsoft Print to PDF which is
> included with Widows 10
.
There is a Freepascal utility for converting a text file to pdf.
Supposing your lazarus is installed  at c:\lazarus, it 'll be at
C:\lazarus\fpc\3.2.0\source\packages\fcl-report\demos\txt2pdf.lpi
It doesn't display the correct chars if you compile and execute it
directly on Result.txt on the command line.

But I've included the source code from this project and modified the
code to produce the pdf.
I've had trouble with the fonts but it seems to works reasonably well
with DejaVuSans.
It's not the ideal font, but box characters are displayed relatively
correctly.
I'm not 100% sure it will work for you.
James Richters via fpc-pascal
2021-04-22 20:17:12 UTC
Permalink
>But I've included the source code from this project and modified the code to produce the pdf.
>I've had trouble with the fonts but it seems to works reasonably well with DejaVuSans.
>It's not the ideal font, but box characters are displayed relatively correctly.
>I'm not 100% sure it will work for you.

My system could not find DejaVuSans, but I found it in the code and changed it to Consolas which is always included with Windows and is a nice clear monospaced font with nice box characters.
It’s almost perfect the only issue is that there is too much space between the lines, so the verticals don’t touch the way they are supposed it.. it’s not quite double spaced, more like 1-1/4 or 1-3/8 spaced.. if it was single spaced it would be perfect. I don’t know how to control the spacing between lines. I made the font bigger but there was still a gap. If I could close that gap it would be perfect.

Is there an easy way to send a page break between the file list and the tree?

James
Jean SUZINEAU via fpc-pascal
2021-04-23 00:01:27 UTC
Permalink
Le 22/04/2021 à 22:17, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
> My system could not find DejaVuSans,

You can find it in
C:\lazarus\fpc\3.2.0\source\packages\fcl-report\demos\fonts.

May be you don't need to install the font, just add on the line below
where you changed the font:

gTTFontCache.SearchPath.Add('C:\lazarus\fpc\3.2.0\source\packages\fcl-report\demos\fonts\');

> but I found it in the code and changed it to Consolas which is always
> included with Windows and is a nice clear monospaced font with nice
> box characters.
Notice it shouldn't be the name displayed for the font by Windows, but
its Postscript name, which is buried somewhere in the ttf file, for
example CourierNewPSMT for Courier New.
>
> It’s almost perfectthe only issue is that there is too much space
> between the lines, so the verticals don’t touch the way they are
> supposed it.. it’s not quite double spaced, more like 1-1/4 or 1-3/8
> spaced.. if it was single spaced it would be perfect.I don’t know how
> to control the spacing between lines.I made the font bigger but there
> was still a gap.If I could close that gap it would be perfect.
>
> Is there an easy way to send a page break between the file list and
> the tree?
>
I'm not an expert of fcl-report but allowing to Michael Van Canneyt
response to "fpreport: can not use two ObjectLists as datasource in one
report" on 18/03/2021, I think this would be difficult. It think it
would need 2 distinct databands which seems to be not possible.
James Richters via fpc-pascal
2021-04-23 09:08:51 UTC
Permalink
Now if I type new text in the ODT document, it’s Consolas, but the actual text in the document is still Liberation Serif
 and it doesn’t align, if I select all the text and change it to Consolas it’s fine.. I tried making a new template with Word I get a warning that some things won’t be saved in ODT format.. and then it comes up with Calibri. Maybe it’s an issue with Word. Maybe I’ll have to install open office to make the template.

I found out my error was happening because I didn’t close the template in Word.

The PDF Files have Consolas in them now, but I’m still getting too much space between the lines. I fiddled around with the settings under //Actual line but nothing I change seems to control the line spacing, it’s like it’s 1-1/2 line spaced, instead of just single spaced.

Instead of page breaks, how about just two separate PDF files? One with the tree and one with the file list?

I’ve been trying to clear the old file when Load from file is pressed with a new file. I tried added slFiles.Clear and vst.Clear in ThVirtualStringTree.Load.fromFile, but I get an exception External Sigsegv I think it has to do with an index that is set to the old data size, but I’m not sure how to re-set everything.

I’ve also been trying to save the last used INI file in Configuration.ini and just load that when the program starts. Is there a way to make it run load from file as soon as the program is open, but after the screen is up so I can still see the load bar?

I’ve also been trying to combine Get Checked Items with get selected items.. so one button gets all items that are either checked or selected, but doesn’t create duplicate entries.
I tried to make a pull request of what I’ve been trying to do with configuration.ini and the combined get checked and selected, but I don’t know if it can be merged because there are a few files I had to commit that had the same name, but the cases were different
 I had to commit them with one name and then commit them again with the other name to get past that or I couldn’t do anything with it.

Thanks for your help

James
Jean SUZINEAU via fpc-pascal
2021-04-23 12:31:57 UTC
Permalink
Le 23/04/2021 à 11:08, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
>
> Now if I type new text in the ODT document, it’s Consolas, but the
> actual text in the document is still Liberation Serif
 and it doesn’t
> align, if I select all the text and change it to Consolas it’s fine..
> I tried making a new template with Word I get a warning that some
> things won’tbe saved in ODT format.. and then it comes up with
> Calibri.Maybe it’s an issue with Word.Maybe I’ll have to install open
> office to make the template.
>
> I found out my error was happening because I didn’t close the template
> in Word.
>
May be toot that a handle stays open when I copy the template to a new
file in the temp directory. I'm not sure.


> The PDF Files have Consolas in them now, but I’m still getting too
> much space between the lines. I fiddled around with the settings under
> //Actual line but nothing I change seems to control the line spacing,
> it’s like it’s 1-1/2 line spaced, instead of just single spaced.
>
> Instead of page breaks,how about just two separate PDF files?One with
> the tree and one with the file list?
>
> I’ve been trying to clear the old file when Load from file is pressed
> with a new file.I tried added slFiles.Clear and vst.Clear in
> ThVirtualStringTree.Load.fromFile, but I get an exception External
> Sigsegv I think it has to do with an index that is set to the old data
> size, but I’m not sure how to re-set everything.
>
> I’ve also been trying to save the last used INI file in Configuration.ini
>
I've added this.
>
> and just load that when the program starts.Is there a way to make it
> run load from file as soon as the program is open, but after the
> screen is up so I can still see the load bar?
>
> I’ve also been trying to combine Get Checked Items with get selected
> items.. so one button gets all items that are either checked or
> selected, but doesn’t create duplicate entries.
>
> I tried to make a pull request of what I’ve been trying to do with
> configuration.ini and the combined get checked and selected, but I
> don’t know if it can be merged because there are a few files I had to
> commit that had the same name, but the cases were different
 I had to
> commit them with one name and then commit them again with the other
> name to get past that or I couldn’t do anything with it.
>
I've added a checked or selected function.

The items are not duplicated and you can click the button Get Checked
twice, memory is properly re-initialized.
James Richters via fpc-pascal
2021-04-23 17:56:16 UTC
Permalink
Get Checked or Selected works great, but if I push it twice, the second time I get:
Unable to open file
C:\Users\James\AppData\Local\Temp\FiC152.odt

But I did make sure to close word and the PDF file before pushing it a second time.

I tried to change formatDateTime to include Days, because many selections go well over 24 hours and it was just leaving the days off... so instead of showing 2days, 3:14:54 it’s just showing 3:14:54
So I changed format date to d:h:m:s but for some reason the totals of the branches are coming up with 30 days even though the totals are nowhere near even one day. I don’t see where the 30 days could possibly be coming from.

James

From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Friday, April 23, 2021 8:32 AM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

Le 23/04/2021 à 11:08, James Richters via fpc-pascal a écrit :
Now if I type new text in the ODT document, it’s Consolas, but the actual text in the document is still Liberation Serif
 and it doesn’t align, if I select all the text and change it to Consolas it’s fine.. I tried making a new template with Word I get a warning that some things won’t be saved in ODT format.. and then it comes up with Calibri. Maybe it’s an issue with Word. Maybe I’ll have to install open office to make the template.

I found out my error was happening because I didn’t close the template in Word.
May be toot that a handle stays open when I copy the template to a new file in the temp directory. I'm not sure.


The PDF Files have Consolas in them now, but I’m still getting too much space between the lines. I fiddled around with the settings under //Actual line but nothing I change seems to control the line spacing, it’s like it’s 1-1/2 line spaced, instead of just single spaced.

Instead of page breaks, how about just two separate PDF files? One with the tree and one with the file list?

I’ve been trying to clear the old file when Load from file is pressed with a new file. I tried added slFiles.Clear and vst.Clear in ThVirtualStringTree.Load.fromFile, but I get an exception External Sigsegv I think it has to do with an index that is set to the old data size, but I’m not sure how to re-set everything.

I’ve also been trying to save the last used INI file in Configuration.ini
I've added this.


and just load that when the program starts. Is there a way to make it run load from file as soon as the program is open, but after the screen is up so I can still see the load bar?

I’ve also been trying to combine Get Checked Items with get selected items.. so one button gets all items that are either checked or selected, but doesn’t create duplicate entries.
I tried to make a pull request of what I’ve been trying to do with configuration.ini and the combined get checked and selected, but I don’t know if it can be merged because there are a few files I had to commit that had the same name, but the cases were different
 I had to commit them with one name and then commit them again with the other name to get past that or I couldn’t do anything with it.
I've added a checked or selected function.
The items are not duplicated and you can click the button Get Checked twice, memory is properly re-initialized.
Jean SUZINEAU via fpc-pascal
2021-04-24 13:38:52 UTC
Permalink
Le 23/04/2021 à 19:56, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
>
> Get Checked or Selected works great, but if I push it twice, the
> second time I get:
>
> Unable to open file
>
> C:\Users\James\AppData\Local\Temp\FiC152.odt
>
> But I did make sure to close word and the PDF file before pushing it a
> second time.
>
Yes, it's a very interesting bug that I'm currently investigating. May
be I don't use the temp directory correctly.
When making the output, I start by copying the template file to another
filename/filepath.
When I use my code to generate the new filename in the temp directory
(Nom:= OD_Temporaire.Nouveau_ODT(Prefixe);),
on the second time, the system doesn't find the source file for the copy
('FileVirtualTree_txt_to_odt.odt') and the copy fails.
But the source file isn't deleted, it continues to be visible in File
Explorer, you can open it in LibreOffice.
And this happens either if , instead of using the CopyFile from
lazutils/FileUtils.pas,  I use a home made "MyCopyFile" function coded
with BlockRead/BlockWrite or even using command line cmd.exe / xcopy to
do the job.

But if I copy the template to a file in the exe directory (just Nom:=
'temp_'+IntToStr(temp)+'.odt'; Inc(temp);), it works ...

> I tried to change formatDateTime to include Days, because many
> selections go well over 24 hours and it was just leaving the days
> off... so instead of showing 2days, 3:14:54 it’s just showing 3:14:54
>
> So I changed format date to d:h:m:s but for some reason the totals of
> the branches are coming up with 30 days even though the totals are
> nowhere near even one day.I don’t see where the 30 days could possibly
> be coming from.
>
I didn't had time to work on this for now. I think it's a bit too much
complicated for FormatDateTime, it would be safer to decode the datetime
value in a special function (something like days:= int(datetime);
hours:= frac(datetime)*24; minutes:= frac(hours)*60 ... )
James Richters via fpc-pascal
2021-04-25 00:54:21 UTC
Permalink
I’ve been trying make “Load from file” happen automatically when the program starts.. I would like it to happen after configuration.ini restores the file name and also after the form is on the screen so I can see the load bargraph.

I tried putting it in Panel1 OnEnter but the form doesn’t have the buttons on it yet when it does the load.. and it is also doing the load when I push a button.. which is not what I want to happen. Any idea how to do the load once automatically after the screen is up so I can see the load progress bar and after all the buttons are on the form?

James
Jean SUZINEAU via fpc-pascal
2021-04-25 18:00:25 UTC
Permalink
Le 25/04/2021 à 02:54, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
>
> I’ve been trying make “Load from file”happen automatically when the
> program starts.. I would like it to happen after configuration.ini
> restores the file name and also after the form is on the screen so I
> can see the load bargraph.
>
> I tried putting it in Panel1 OnEnter but the form doesn’t have the
> buttons on it yet when it does the load.. and it is also doing the
> load when I push a button.. which is not what I want to happen.Any
> idea how to do the load once automatically after the screen is up so I
> can see the load progress bar and after all the buttons are on the form?
>
The persistence of configuration is managed by the ips:TIniPropStorage
component. Digging a bit , I found that TIniPropStorage has an event
OnRestoreProperties which fired after the configuration is restored
(Ctrl+Click on TIniPropStorage, then on  OnRestoreProperties, which
leads you do TCustomPropertyStorage, where you'll find with a search on
FOnRestoringProperties that FOnRestoringProperties is called in
procedure TCustomPropertyStorage.Restore after restoring properties).

I added LoadFromFile in this event.

I have extracted the pdf generation to a unit uText_to_PDF with a class
TText_to_PDF to make a pdf from a string. You can even use it in a
console app.
3 pdf are generated now: List, Tree, List+Tree.

I added a page break between list and tree in the odt.
James Richters via fpc-pascal
2021-04-24 14:01:19 UTC
Permalink
I was able to fix the spacing on the PDF file so there are no more gaps between the box characters.
I had to change both:
DB.Layout.Height:=4; // 0.4 cm.
DB.StretchMode:=smDontStretch;

So now that the PDF file looks correct, I don’t need the open office document because it never needs to be editable.

I have a date time routine for one of my big console projects that displays days, hours, minutes and seconds and takes off any leading zeros for days and hours from a date/time variable. I’ll see if I can bring that routine over and get it to work.

James
From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Saturday, April 24, 2021 9:39 AM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

Le 23/04/2021 à 19:56, James Richters via fpc-pascal a écrit :
Get Checked or Selected works great, but if I push it twice, the second time I get:
Unable to open file
C:\Users\James\AppData\Local\Temp\FiC152.odt

But I did make sure to close word and the PDF file before pushing it a second time.
Yes, it's a very interesting bug that I'm currently investigating. May be I don't use the temp directory correctly.
When making the output, I start by copying the template file to another filename/filepath.
When I use my code to generate the new filename in the temp directory (Nom:= OD_Temporaire.Nouveau_ODT(Prefixe);),
on the second time, the system doesn't find the source file for the copy ('FileVirtualTree_txt_to_odt.odt') and the copy fails.
But the source file isn't deleted, it continues to be visible in File Explorer, you can open it in LibreOffice.
And this happens either if , instead of using the CopyFile from lazutils/FileUtils.pas, I use a home made "MyCopyFile" function coded with BlockRead/BlockWrite or even using command line cmd.exe / xcopy to do the job.
But if I copy the template to a file in the exe directory (just Nom:= 'temp_'+IntToStr(temp)+'.odt'; Inc(temp);), it works ...
I tried to change formatDateTime to include Days, because many selections go well over 24 hours and it was just leaving the days off... so instead of showing 2days, 3:14:54 it’s just showing 3:14:54
So I changed format date to d:h:m:s but for some reason the totals of the branches are coming up with 30 days even though the totals are nowhere near even one day. I don’t see where the 30 days could possibly be coming from.
I didn't had time to work on this for now. I think it's a bit too much complicated for FormatDateTime, it would be safer to decode the datetime value in a special function (something like days:= int(datetime); hours:= frac(datetime)*24; minutes:= frac(hours)*60 ... )
James Richters via fpc-pascal
2021-04-25 13:24:24 UTC
Permalink
I fixed the time totals to show days correctly with this:

procedure TTreeData.SetdValue( _dValue: TDateTime);
begin
FdValue:= _dValue;
FValue:='';
If FdValue>=2 Then
FValue:= Format ('%d Days ',[Trunc(FdValue)])
Else
If FdValue>=1 Then
FValue:= Format ('%d Day ',[Trunc(FdValue)]);
If (FValue<>'') OR (HourOf(FdValue)>0) Then
FValue:=FValue+Format ('%.1d:',[HourOf(FdValue)]);
If (FValue='') Then
FValue:=Format ('%.1d:',[MinuteOf(FdValue)])
Else
FValue:=FValue+Format ('%.2d:',[MinuteOf(FdValue)]);
FValue:=FValue+Format ('%.2d',[SeconDof(FdValue)]);
end;

I made a pull request to your repository on Github with it

James
Jean SUZINEAU via fpc-pascal
2021-04-25 18:07:44 UTC
Permalink
Le 25/04/2021 à 15:24, James Richters via fpc-pascal a écrit :
> RE: [fpc-pascal] Directory Tree
>
> I fixed the time totals to show days correctly with this:
>
I didn't use your pull request because I don't know yet how to handle it.

I have delete some files which differed only by case. After committing
from linux, the pull on windows deleted all the files but I could revert
them on next commit from windows to get them back in correct case. It
seems to be stable now.

I used your code for days to make a function Duration_from_DateTime(
_DateTime: TDateTime): String;
I added on main form a button "Test" with a few test cases.
Let me know if it's ok for you.
James Richters via fpc-pascal
2021-04-25 19:30:38 UTC
Permalink
>I added LoadFromFile in this event.
That was the first thing I tried, but the problem is, this happens before anything is put on the screen.. so when I run the program with an Ini file with 4000 entries in it, there is a good 30 second delay, and then the screen is shown with everything loaded.

So I tried putting it in various places in the form, but then it runs additionally when I don’t want it to.

The problem I’m having is understanding the sequence of things (if there even is one) with my console programs, I specifically determine the exact order I want things to run, but this is more just a collection of things that all run at the same time.. well they don’t run at the same time, it’s an illusion, computers only do one thing at a time.. but I don’t understand how this illusion is controlled…how can I order it to show form1, show the buttons, show the load bar graph… get everything on the screen, THEN load the last used file? I can’t really use config.ini, because in order to get everything on the screen in the proper size and position, the configuration would have had to be read in already.. so before anything is displayed.. I want the load to happen after everything is displayed. I supposed I can maybe launch a timer to wait 1 second to get everything on the screen then load the files, but I don’t even know where to put the timer.

>I have extracted the pdf generation to a unit uText_to_PDF with a class TText_to_PDF to make a pdf from a string. You can even use it in a console app.
>3 pdf are generated now: List, Tree, List+Tree.
The PDF Files look great, separate PDF files is really better in my opinion anyway. That is awesome that I can make text to pdf in a console app! Thanks for making that a separate unit.


>I’m I have delete some files which differed only by case. After committing from linux, the pull on windows deleted all the files but I could revert them on next commit from windows to get them back in correct case.
>It seems to be stable now.
I'll try another pull request of something simple just to see if it will work.

>I used your code for days to make a function Duration_from_DateTime( _DateTime: TDateTime): String;
>I added on main form a button "Test" with a few test cases
>Let me know if it's ok for you. still not getting a page break using word to open the odt file.
The duration looks great, all the test cases look great too.
I'm not getting the page break in word either.

James

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.fre
Jean SUZINEAU via fpc-pascal
2021-04-25 22:59:29 UTC
Permalink
Le 25/04/2021 à 21:30, James Richters via fpc-pascal a écrit :
> >I added LoadFromFile in this event.
> That was the first thing I tried, but the problem is, this happens before anything is put on the screen.. so when I run the program with an Ini file with 4000 entries in it, there is a good 30 second delay, and then the screen is shown with everything loaded.
>
> So I tried putting it in various places in the form, but then it runs additionally when I don’t want it to.
>
> The problem I’m having is understanding the sequence of things (if there even is one) with my console programs, I specifically determine the exact order I want things to run, but this is more just a collection of things that all run at the same time.. well they don’t run at the same time, it’s an illusion, computers only do one thing at a time.. but I don’t understand how this illusion is controlled…how can I order it to show form1, show the buttons, show the load bar graph… get everything on the screen, THEN load the last used file? I can’t really use config.ini, because in order to get everything on the screen in the proper size and position, the configuration would have had to be read in already.. so before anything is displayed.. I want the load to happen after everything is displayed. I supposed I can maybe launch a timer to wait 1 second to get everything on the screen then load the files, but I don’t even know where to put the timer.

I'm not an expert of that, but let's say that since the good old time of
Windows 3.1, your Windows app is based on a so-called "message loop".
The main part of your app just register a callback for processing a
message. There are hundreds of different kind of messages ( from the
Windows emulator in linux:
https://wiki.winehq.org/List_Of_Windows_Messages )

Windows kernel is running the loop and sometimes calls your callback to
repaint a window, set the focus, notify you of a mouse move ....
You can still make your own callback (
https://docs.microsoft.com/en-us/windows/win32/winmsg/using-window-procedures
).
But it's so complex that in practice we uses base classes like
TApplication and TForm to do all the basic code of the windows app.
In the times of Windows 3.1 made for single task  processors, I think
there were a single message loop for all the system, shared by all the
apps. If you took too much time processing one of your messages you
could hang up the system. It was non-preemptive multitasking.
With Windows 95 and 32 bits it began to use the multitasking capability
of the processor, it began to be preemptive multitasking, you couldn't
lock the system with an infinite loop, just your program.
With the advent of multicore processors, I think that now you can have
really several assembler instructions running in parallel
(https://en.wikipedia.org/wiki/Multi-core_processor).
In some cases you can accelerate your program by running several threads
in parallel with the TThread class for example.

Most of your components (TEdit, TButton) are child windows hosted in the
form parent window and they receive their own messages for painting,
mouse, ...

I have moved the LoadFromFile to a Timer event just fired on creation of
the Form with 10ms. When the message of the timer arrives,  usually all
the loading an painting is already done, their messages have been posted
before in the message queue.

> I'm not getting the page break in word either.
May be the template is not up to date ? I think that after type
Ctrl+Enter in the template Libre Office adds a parameter for allowing
soft page breaks.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bi
James Richters via fpc-pascal
2021-04-25 23:16:35 UTC
Permalink
Thanks for the explanation... phew, what a lot of stuff... no wonder I like my console programs so much 😃 For critical timing applications I have a lot more control of exactly when things happen... but this project is helping me appreciate the benefits of a GUI application. I just need to learn how to think differently (non sequentially) for the most part doing things on events makes sense to me, it's just when I run into wanting to do something at a certain time that I get confused.

>I have moved the LoadFromFile to a Timer event just fired on creation of the Form with 10ms. When the message of the timer arrives,
> usually all the loading an painting is already done, their messages have been posted before in the message queue.
The timer is working GREAT, I thought a timer would work, I just didn't know how to implement it.

>> I'm not getting the page break in word either.
>May be the template is not up to date ? I think that after type
>Ctrl+Enter in the template Libre Office adds a parameter for allowing
>soft page breaks.

Maybe I'll install open office and see if it's just a word for windows issue.

James
James Richters via fpc-pascal
2021-05-01 13:27:27 UTC
Permalink
I’ve been trying to save more things to the configuration.ini file, I’ve managed to save my Load Time Variable
 I was just trying to change SessionProperties myself, but it wouldn’t work if I tried that.. but if I used object inspector and click ed on SessionProperties and added it to the list with that, it worked. I don’t understand why it only works if I pick it from the list in object inspector
 but at least it works now.

but now I’m trying to save the widths of the columns for the two VirtualStringTrees.

I see the widths in the object inspector under TVirtualStringTree > Header > Columns Then if I click on the 2 Items I get 0 – File and 1 – Time, and If I click on one of those I get properties for vst.TVTHeader.Columns[0].width
But when I go to SessionProperteis to add that to the list, all I see is vst.header but no way to get the array elements. If I try to add vst.header it crashes with an exception about the properties. If I try to add vst.TVTHeader.Columns[0].width myself to the end of SessionProperties in ufFileVirtualTree.lfm it doesn’t save or restore it. I don’t get an entry for it in configuration.ini at all.

Any ideas how to save and restore the column widths for VirtualStrinTrees in the ini file?

James
Jean SUZINEAU via fpc-pascal
2021-05-01 21:12:51 UTC
Permalink
Sorry, I didn' had time this week to have a look to your last additions.

Le 01/05/2021 à 15:27, James Richters via fpc-pascal a écrit :
> Any ideas how to save and restore the column widths for
> VirtualStrinTrees in the ini file?

I imagine it can be done through the events of the IniProperty Storage.

If it doesn't work, in last resort, you can do that using TINIFile to
access directly the ini file.
Jean SUZINEAU via fpc-pascal
2021-05-02 01:02:55 UTC
Permalink
Le 01/05/2021 à 15:27, James Richters via fpc-pascal a écrit :
> Any ideas how to save and restore the column widths for
> VirtualStrinTrees in the ini file?
Done with the events and methods of TIniPropStorage.
James Richters via fpc-pascal
2021-05-02 13:14:01 UTC
Permalink
>>Any ideas how to save and restore the column widths for VirtualStrinTrees in the ini file?
> Done with the events and methods of TIniPropStorage.

Thanks, I see how that works now.
I see you cleaned it all up and made pull down menus.
For some reason, the timer isn’t delaying the initial load anymore
 I’m back to having a long delay while it loads and then the form is displayed with a large data file.. but I see the timer is still there. I increased the amount of time on the timer, but it still loads before the screen is displayed.

James
James Richters via fpc-pascal
2021-05-02 13:48:21 UTC
Permalink
>For some reason, the timer isn’t delaying the initial load anymore
 I’m back to having a long delay while it loads and then the form is displayed with a large data file.. but I see the timer is still there. I increased the amount of time on the timer, but it still loads before the screen is displayed.

I tracked it down and fixed it
 It was loading when the file name changed, and I guess the ini file changed the file name, so it loaded
 before the screen was up.. so I fixed it by only loading if the timer was disabled:

procedure TfFileVirtualTree.eFileNameChange(Sender: TObject);
begin
If Not(tFirst.Enabled) Then
Load_from_File;
end;

James

From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of James Richters via fpc-pascal
Sent: Sunday, May 2, 2021 9:14 AM
To: 'FPC-Pascal users discussions' <fpc-***@lists.freepascal.org>
Cc: James Richters <***@productionautomation.net>; 'Jean SUZINEAU' <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

>>Any ideas how to save and restore the column widths for VirtualStrinTrees in the ini file?
> Done with the events and methods of TIniPropStorage.

Thanks, I see how that works now.
I see you cleaned it all up and made pull down menus.
For some reason, the timer isn’t delaying the initial load anymore
 I’m back to having a long delay while it loads and then the form is displayed with a large data file.. but I see the timer is still there. I increased the amount of time on the timer, but it still loads before the screen is displayed.

James
James Richters via fpc-pascal
2021-05-02 21:42:34 UTC
Permalink
I’ve been making progress with learning how to make some modifications myself to this project, I’ve been pushing them to Github.

I added a custom report title, I have if functioning the way I want it to.. just pulling the report title from the INI file and saving it in a variable, then putting the contents of the variable in the report,
But I’m thinking I didn’t really define the variable the way it would normally be done with Lazarus. I just stuck a Report_Title : String; variable in the uText_to_PDF.pas unit
 it works fine and that’s the way I would do it in a console application, but I’m thinking I should have made the variable part of the TText_to_PDF class
 I tried to put it under public, but that did not work so I just made it a unit variable.

Is there a better way I should have defined this variable?

James
Jean SUZINEAU via fpc-pascal
2021-05-03 07:16:19 UTC
Permalink
Le 02/05/2021 à 23:42, James Richters via fpc-pascal a écrit :
> But I’m thinking I didn’t really define the variable the way it would
> normally be done with Lazarus.
Just for notice: classes and objects are not particular to Lazarus, it's
plain Object Pascal, understood by Freepascal and Delphi whatever the
context( console, graphic/Lazarus or javascript/pas2js)
> Is there a better way I should have defined this variable?
Defining it in public in TText_to_PDF is a good idea.
(Sorry, I've renamed a lot of things)
James Richters via fpc-pascal
2021-05-03 11:55:12 UTC
Permalink
>Just for notice: classes and objects are not particular to Lazarus, it's plain Object Pascal, understood by Freepascal and Delphi whatever the context( console, graphic/Lazarus or javascript/pas2js)
I have some classes and objects in my console programs, but they are there to get some new features to work and are mixed it with my turbo pascal code. I never really fully understood them.. only a vague idea of how they work.
>Defining it in public in TText_to_PDF is a good idea.
I tried putting it under the destructor in public
 above the private variables, but it wouldn’t compile there I thought it would have to be above all the functions and procedures
 and there is no Var for variables and there are two public and two private definitions, I don’t really understand what’s going on
 Can I just mix up variables with functions and procedures since there is no Var declaration? Or is there an order that must be followed?

>(Sorry, I've renamed a lot of things)
Thanks, I’m still trying to pick up the naming conventions. For some reason all my form changes got reset. I merged them back in and pushed it. I made the background of the information boxes white, not invisible that’s why I set them to ‘ ‘ at the beginning.. so the white boxes would be visible. I also padded the text in the boxes with spaces so the white background would make a border around the text. I also re-arranged a lot of things, added horizontal scroll bars and shut off word wrap on the results panel.. removed extra buttons we don’t need now with the menu, etc.. Let me know what you think of my form design.

Any idea how I change the format of M.Text=’[Date]’; in uText_To_PDF.pas ? It shows up 2021-05-03 (Which I actually like better because it sorts properly) but here in the USA 05-03-2021 is customary. I don’t see where [Date] gets filled in with the date or how to define the format of it. I think I could make my own date format, but I don’t want to over-complicate things.

Thank you for the help.

James
Jean SUZINEAU via fpc-pascal
2021-05-03 18:15:20 UTC
Permalink
Le 03/05/2021 à 13:55, James Richters via fpc-pascal a écrit :
> >Defining it in public in TText_to_PDF is a good idea.
>
> I tried putting it under the destructor in public
 above the private
> variables, but it wouldn’t compile thereI thought it would have to be
> above all the functions and procedures
 and there is no Var for
> variables and there are two public and two private definitions, I
> don’t really understand what’s going on
Can I just mix up variables
> with functions and procedures since there is no Var declaration?Or is
> there an order that must be followed?
>
Yes, the destructor is a special procedure, so it doesn't work. (it's
the same for constructor which is a special function).

You can put any number of public/private /protected sections.
Usually for each specific aspect of my class, I add:
- at first level a comment with the aspect.
- Then right below a  "private" section for the internal stuff of the
aspect, not useful from outside the class
- eventually a "protected" section ( like private but can be accessed
from child classes)
- a "public" section for stuff useful from outside the class.
- you can have a "published" section, kind of "super public", mainly for
components in the ide palette , rtti, and when you need to discover
properties of an object at run time.
 (this works for classes defined with "class end", for old style, kind
of record with methods defined with "object end", "published" doesn't work).

> >(Sorry, I've renamed a lot of things)
>
> Thanks, I’m still trying to pick up the naming conventions.For some
> reason all my form changes got reset.I merged them back in and pushed
> it.I made the background of the information boxes white, not invisible
> that’s why I set them to ‘‘ at the beginning.. so the white boxes
> would be visible.I also padded the text in the boxes with spaces so
> the white background would make a border around the text.I also
> re-arranged a lot of things, added horizontal scroll bars and shut off
> word wrap on the results panel.. removed extra buttons we don’t need
> now with the menu, etc..Let me know what you think of my form design.
>
It's nice. I keep my original design mainly because my "main"screen on
linux has a lower resolution.
>
> Any idea how I change the format of M.Text=’[Date]’; in
> uText_To_PDF.pas ?It shows up 2021-05-03(Which I actually like better
> because it sorts properly)but here in the USA 05-03-2021 is
> customary.I don’t see where [Date] gets filled in with the date or how
> to define the format of it.I think I could make my own date format,
> but I don’t want to over-complicate things.
>
'[Date]' is decoded in unit fpreport TFPReportCustomMemo.ParseText; and
expanded in TFPReportCustomMemo.ExpandExpressions; using method
TFPReportElement.ExpressionResultToString wich uses virtual function
TFPReportElement.GetDateTimeFormat for getting the datetime format.
You just need to declare a subclass of TFPReportMemo which overrides
GetDateTimeFormat. I 've adde a  "TfprmText_to_PDF = class(
TFPReportMemo)" in uText_to_PDF for this.

In the unit test I've added a generation of a 10000 lines inifile for
testing. This lead me to change some things to improve the loading speed.
James Richters via fpc-pascal
2021-05-03 23:55:04 UTC
Permalink
Thanks for the explanation of classes.

I didn’t realize I ended up making it so big, I was trying to keep it able to fit on a 1280 x 1024 screen.. I guess 1280x1024 is less of a percentage of my 4K screen than I thought. The 2 rows is much nicer. Some of my machine times and run times get quite long if it’s over 10 days.. so the second row helps make room for them.

Thanks for fixing the dates

The loading speed has improved quite a bit on my windows 10 machines.

I had an issue with the fonts being different sizes on one of my windows 10 machines.. but I found if I shut off ParentFont everything is the right size on the other machine.

I’ve been noticing odd behavior in Lazarus.. if I stop the program and modify the form, then hit the green arrow
 none of my for modifications are shown.. it’s still using the old form.. but if I use the pull down menus to build the project, then I get my new form. Is this normal or do I have some setting messed up in Lazarus?

I copied all the relevant files to another computer to see how they would run
 and I noticed that after I run the program, it creates and etc directory, and inside it there is a file called _Configuration.ini which contains one section: [Options] and one entry under that: Chemin_Global=

Any idea what’s causing this?

James
Jean SUZINEAU via fpc-pascal
2021-05-13 20:55:45 UTC
Permalink
Le 04/05/2021 à 01:55, James Richters via fpc-pascal a écrit :
>
> I’ve been noticing odd behavior in Lazarus.. if I stop the program and
> modify the form, then hit the green arrow
 none of my for
> modifications are shown.. it’s still using the old form.. but if I use
> the pull down menus to build the project, then I get my new form.Is
> this normal or do I have some setting messed up in Lazarus?
>
Very difficult to reproduce for me.
May be you tried to open the lfm file in the editor and tried to modify
it by hand ? It's the only way I could get that.
In Delphi 7, when you choose to open the dfm in the text editor, Delphi
7 asked you to close the pas file before and  the visual designers.

> I copied all the relevant files to another computer to see how they
> would run
 and I noticed that after I run the program, it creates and
> etc directory, and inside it there is a file called _Configuration.ini
> which contains one section: [Options] and one entry under that:
> Chemin_Global=
>
I have split the unit uEXE_INI (subdirectory pascal_o_r_mapping/02_Units
) and moved the code causing the creation of this entry in a new unit
uEXE_INI_Global.

Subdirectory etc is where I usually stores the configuration files.
Maybe I will move Configuration.ini to etc/INIPropStorage.ini
James Richters via fpc-pascal
2021-05-13 23:32:21 UTC
Permalink
>I have split the unit uEXE_INI (subdirectory pascal_o_r_mapping/02_Units ) and moved the code causing the creation of this entry in a new unit uEXE_INI_Global.
Thank you, it is not creating this other file anymore.
James
James Richters via fpc-pascal
2021-04-25 21:29:53 UTC
Permalink
>I'll try another pull request of something simple just to see if it will work.
I made another pull request on GitHub, https://github.com/jsuzineau/pascal_o_r_mapping/pull/3

This one is an attempt to add some text boxes and to use them to display the totals and to get a time variable that represents how long it takes to unload/reload the machine. I have the total times working, but I get errors that my variables are not found when I try to use the textboxes. I'm trying to access them with things like eMachineTime.Text := Duration_From_DateTime(Total_Machine_Time);
I'm not sure what I'm doing wrong.. maybe it's the way I re-named the text box from edit1 ?? Any ideas what I'm doing wrong?

James

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bi
Jean SUZINEAU via fpc-pascal
2021-04-21 22:21:26 UTC
Permalink
Another way of seeing is to generate and odt file with the generated text.

You get a slightly better rendering because I could define Courier New
as default font in the new template: FileVirtualTree_txt_to_odt.odt

From the OpenOffice "File" menu, you can generate a pdf file.

There is a way too, to execute LibreOffice/OpenOffice from command line
to convert directly the odt to pdf.

I have some code for this at
https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/OOo/uOD.pas,
in methods
- function TOD.Executable_soffice: String;
- function TOD.Format_Sortie_from_(_Nom_ODT: String): String;
-function TOD.PDF_from_(_Nom_ODT: String): String;

but it can't be used as is for the current case.
James Richters via fpc-pascal
2021-04-22 21:17:21 UTC
Permalink
For some reason the ODT file wants to know if I want to translate it from French, and while the font is “Courier New” for anything I would type into the document, the font of the text itself is “Liberation Serif”
If I change the font manually to “Courier New” I get gaps in the vertical lines, but if I change it to “Consolas” there are no gaps and it looks perfect.

So I thought I should be able to just save a template with the font set to “Consolas” and the spacing set to “No Spacing” which is basically single spacing it..
Well when I save it like that, when I try to run it I get:
Unable to Open File: C:\Users\James\AppData\Local\Temp\Fi8004.odt
Press OK and risk data corruption or press abort to kill the program

I think it must have something to do with using Microsoft Word to save the template.
James


From: fpc-pascal <fpc-pascal-***@lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Wednesday, April 21, 2021 6:21 PM
To: fpc-***@lists.freepascal.org
Cc: Jean SUZINEAU <***@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

Another way of seeing is to generate and odt file with the generated text.
You get a slightly better rendering because I could define Courier New as default font in the new template: FileVirtualTree_txt_to_odt.odt
From the OpenOffice "File" menu, you can generate a pdf file.
There is a way too, to execute LibreOffice/OpenOffice from command line to convert directly the odt to pdf.
I have some code for this at https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/OOo/uOD.pas, in methods
- function TOD.Executable_soffice: String;
- function TOD.Format_Sortie_from_(_Nom_ODT: String): String;
- function TOD.PDF_from_(_Nom_ODT: String): String;
but it can't be used as is for the current case.
Jean SUZINEAU via fpc-pascal
2021-04-22 23:36:29 UTC
Permalink
Le 22/04/2021 à 23:17, James Richters via fpc-pascal a écrit :
>
> For some reason the ODT file wants to know if I want to translate it
> from French, and while the font is “Courier New” for anything I would
> type into the document, the font of the text itself is “Liberation Serif”
>
> If I change the font manually to “Courier New” I get gaps in the
> vertical lines,but if I change it to “Consolas” there are no gaps and
> it looks perfect.
>
Basically, I think you should replace the FileVirtualTree_txt_to_odt.odt
by one created on your machine.

Just create an empty document in Word and save it in odt format as
FileVirtualTree_txt_to_odt.odt.

To change the font, don't modify it directly in the paragraph, but
modify the default style,
change  the font of the default style to the one which fits the best for
you.

Eventually, you could make a style with a specific name, and specify it
in the pascal code.

I have changed the font of the default style to Consolas. It works on my
Windows machine, but not on Ubuntu.

I have switched the language to English US too.

> So I thought I should be able to just save a template with the font
> set to “Consolas” and the spacing set to “No Spacing” which is
> basically single spacing it..
>
> Well when I save it like that, when I try to run it I get:
>
> Unable to Open File: C:\Users\James\AppData\Local\Temp\Fi8004.odt
>
> Press OK and risk data corruption or press abort to kill the program
>
> I think it must have something to do with using Microsoft Word to save
> the template.
>
May be the file was already opened ? or the template broken ? (saved in
docx format instead of odt ?)
James Richters via fpc-pascal
2021-04-19 12:30:02 UTC
Permalink
I updated Lazarus to Lazarus 2.0.12 / fpc 3.2.0 and that indeed did fix the default encoding error.
James
Bart via fpc-pascal
2021-04-06 16:53:56 UTC
Permalink
On Tue, Apr 6, 2021 at 12:29 PM James Richters via fpc-pascal
<fpc-***@lists.freepascal.org> wrote:

> Or Am I going to be better off going graphical with Lazarus for something like this?

TShellTreeView in Lazarus should do exactly what you want.
It's not console though.


--
Bart
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://
Loading...