problems trying to save TDBTree and reopen with teeTreeOffic
problems trying to save TDBTree and reopen with teeTreeOffic
hi
i am modifying tDBTree objects using a script.
but i would really need to reopen them using teeTreeOffice
here is my code
TDBTree : arbre;
racine : TTreeNodeShape;
filsCodeOM : TTreeNodeShape;
...
LoadTreeFromFile(TCustomTree(arbre), lst);
arbre.NoOwnerShapes := false;
arbre.AssignParent := false;
if (arbre.Roots.Count > 0) then racine := arbre.Roots[0];
filsCodeOM := racine.AddChild(TXT_CODE_OM);
filsCodeOm.AddChild(intToStr(_codeOm));
filsCodeOm.Font.style := [fsBold];
ForceDirectories('E:\mCaron\apresScript' + nouveauPath);
SaveTreeToFil(arbre, 'E:\mCaron\apresScript'+nouveauPath+nomFichier);
...
the error message i get when i reopen the code modified tree is
error reading treeNodeShape2.text.string : invalid property value
and all i see is some sort of empty gray panel
i would really appreciate you help
gracias
mathieu caron
[email protected]
i am modifying tDBTree objects using a script.
but i would really need to reopen them using teeTreeOffice
here is my code
TDBTree : arbre;
racine : TTreeNodeShape;
filsCodeOM : TTreeNodeShape;
...
LoadTreeFromFile(TCustomTree(arbre), lst);
arbre.NoOwnerShapes := false;
arbre.AssignParent := false;
if (arbre.Roots.Count > 0) then racine := arbre.Roots[0];
filsCodeOM := racine.AddChild(TXT_CODE_OM);
filsCodeOm.AddChild(intToStr(_codeOm));
filsCodeOm.Font.style := [fsBold];
ForceDirectories('E:\mCaron\apresScript' + nouveauPath);
SaveTreeToFil(arbre, 'E:\mCaron\apresScript'+nouveauPath+nomFichier);
...
the error message i get when i reopen the code modified tree is
error reading treeNodeShape2.text.string : invalid property value
and all i see is some sort of empty gray panel
i would really appreciate you help
gracias
mathieu caron
[email protected]
hi tom
firstly, a employee at our company create the teeTrees using teeTreeOffice.
I was asked to add an other information in all our teeTrees (a unique id number). we have about 2000 .ttr files so i want to make that process in batch using a script.
we need to reopen these script modified files using teeTreeOffice because the get maintained as new scientific litterature is published (we store such info in teeTrees at our company). The indiviual that maintain the teeTrees use teeTreeOffice to do so.
TXT_CODE_OM is a simple constant containing the string 'Code_OM'
i hope this will help you help me.
gracias
mCaron
[email protected]
firstly, a employee at our company create the teeTrees using teeTreeOffice.
I was asked to add an other information in all our teeTrees (a unique id number). we have about 2000 .ttr files so i want to make that process in batch using a script.
we need to reopen these script modified files using teeTreeOffice because the get maintained as new scientific litterature is published (we store such info in teeTrees at our company). The indiviual that maintain the teeTrees use teeTreeOffice to do so.
TXT_CODE_OM is a simple constant containing the string 'Code_OM'
i hope this will help you help me.
gracias
mCaron
[email protected]
So, if I understand correctly, you just iterate over an existing tree, add some info and save it back to disk. If so, you don't need to use TDBTree, TTree should be sufficient. TDBTree is a descendant of TTree do display data from a database (eg in master-detail / parent-code situations).
Further, the loading of the in teeTreeOffice designed tree works correctly and
the error appears when you want to reload the modified inside teeTreeOffice? Am I correct in this assumption?
Which version of teeTree2 (the latest? ie the one accompanied with teeChart Pro v7.07?) are you using and which version of TeeTreeOffice?
I'll try to set up a similar code to find out what happens.
Regards,
tom
Further, the loading of the in teeTreeOffice designed tree works correctly and
the error appears when you want to reload the modified inside teeTreeOffice? Am I correct in this assumption?
Which version of teeTree2 (the latest? ie the one accompanied with teeChart Pro v7.07?) are you using and which version of TeeTreeOffice?
I'll try to set up a similar code to find out what happens.
Regards,
tom
Hi,
Could you try the following code and see if you get an error? This should give a correct result (at least on my pc).
Regards,
Tom.
Could you try the following code and see if you get an error? This should give a correct result (at least on my pc).
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeeTree, StdCtrls;
type
TForm1 = class(TForm)
Tree1: TTree;
btnLoad: TButton;
btnModify: TButton;
btnSave: TButton;
OpenDialog1: TOpenDialog;
procedure btnLoadClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure btnModifyClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnLoadClick(Sender: TObject);
begin
if OpenDialog1.Execute then begin
Tree1.Clear;
LoadTreeFromFile(TCustomTree(Tree1),OpenDialog1.FileName);
end;
end;
procedure TForm1.btnSaveClick(Sender: TObject);
var
BackupName : String;
begin
if FileExists(OpenDialog1.FileName) then
begin
BackupName := ExtractFileName(OpenDialog1.FileName);
BackupName := ChangeFileExt(BackupName, '.ttr.BAK');
DeleteFile(BackupName);
if not RenameFile(OpenDialog1.FileName, BackupName) then
raise Exception.Create('Unable to create backup file.');
SaveTreeToFile(TCustomTree(Tree1), OpenDialog1.FileName);
end;
end;
procedure TForm1.btnModifyClick(Sender: TObject);
var
i: integer;
tmpNode: TTreeNodeShape;
begin
// modify text / font
for i := 0 to Tree1.Shapes.Count - 1 do
begin
Tree1.Shapes[i].SimpleText := 'mod_of_'+Tree1.Shapes[i].SimpleText;
Tree1.Shapes[i].Font.Style := Tree1.Shapes[i].Font.Style + [fsBold];
end;
// add child to root if exists
tmpNode := nil;
if Tree1.Roots.Count > 0 then
tmpNode := Tree1.Roots[0].AddChild('new node!');
// modify new added node if exists
if (tmpNode <> nil) then
begin
tmpNode.Font.Style := tmpNode.Font.Style + [fsItalic];
tmpNode.Font.Color := clRed;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Tree1.NoOwnerShapes := false;
Tree1.AssignParent := false;
end;
end.
Tom.
hola Tom
you are quite right about the TDBTree issue. But i had already tried with a TTree and encountered the same problem.
I have also runned the code you sent me, and i still have the same problem when i try to reOpen the script modified tree using the teeTreeOffice.
I use teeTree version 2.1
and i use the version of teeTree office that was on steema's web site last tuesday.
I also use delphi 7
again, thanks for your sustained help.
mCaron
[email protected]
you are quite right about the TDBTree issue. But i had already tried with a TTree and encountered the same problem.
I have also runned the code you sent me, and i still have the same problem when i try to reOpen the script modified tree using the teeTreeOffice.
I use teeTree version 2.1
and i use the version of teeTree office that was on steema's web site last tuesday.
I also use delphi 7
again, thanks for your sustained help.
mCaron
[email protected]
mmm, this is really weird...
so you used the example code to modify a ttr, and then you reopened that one into TeeTreeOffice and you received an error? This works here without any problem...
Do you use a specific ttr? If possible please send me a ttr of yours so I can try it with that one.
Regards,
Tom.
so you used the example code to modify a ttr, and then you reopened that one into TeeTreeOffice and you received an error? This works here without any problem...
Do you use a specific ttr? If possible please send me a ttr of yours so I can try it with that one.
Regards,
Tom.
Hola Tom
i will send you a teeTree built using an early version of teeTreeOffice (the teeTree was built in november 2002)
i ain't sure i have a good email address though.
thanks
mathieu caron
[email protected]
i will send you a teeTree built using an early version of teeTreeOffice (the teeTree was built in november 2002)
i ain't sure i have a good email address though.
thanks
mathieu caron
[email protected]
tom @ steema . comi ain't sure i have a good email address though
Code: Select all
the teeTree was built in november 2002