Im having trouble saving/loading everything typed in a TRichEdit. It only will save and load the first line in the box...
Ive tried it using "Lines" and "Text" and both give me the same result. Any advice?
Im having trouble saving/loading everything typed in a TRichEdit. It only will save and load the first line in the box...
Ive tried it using "Lines" and "Text" and both give me the same result. Any advice?
METAL HEAD FOR LIFE!!!
Want to add a new line?
RichEdit.Lines.Add('Line x');
Want to modify a line?
RichEdit.Lines[x] := 'hello!';
Want to save the contents of the RichEdit?
RichEdit.Lines.SaveToFile('C:\something.rtf');
Want to load the contents of a file into a RichEdit?
RichEdit.Lines.LoadFromFile('C:\something.rtf');
Not sure what you really meant, so if you can clarify a few things for me? Thanks
![]()
You may contact me with any concerns you have.
Are you a victim of harassment? Please notify me or any other staff member.
| SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |
how exactly are you planning on doing it? and posting your code would be helpful.
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
@Dans the Man
would that save/load work with an INI?
EDIT: It doesn't compile... Unknown identifier 'SAVETOFILE'
@Dan Cardin
Im using the Write/Read INI procedures to save and load all my vars...
SCAR Code:procedure SaveSettings;
var
i,e,z: Integer;
begin
WriteINI('Clients','ClientTabs Length',IntToStr(GetArrayLength(ClientTabs)),AppPath + FileName);
WriteINI('Clients','DateTabs Length',IntToStr(GetArrayLength(ClientTabs)),AppPath + FileName);
for i := 0 to High(ClientTabs) do
WriteINI('Clients','DateTabs['+IntToStr(i)+']'+' Length',IntToStr(GetArrayLength(DateTabs[i])),AppPath + FileName);
for i := 0 to High(ClientTabs) do
WriteINI('Clients','ClientTabs['+IntToStr(i)+']',ClientTabs[i].Caption,AppPath + FileName);
{for i := 0 to High(Notes) do // This is my TRichEdit.
WriteINI('Clients',Notes['+IntToStr(i)+']',Notes[i].Text,AppPath + FileName);}
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
WriteINI('Clients','DateTabs['+IntToStr(i)+']['+IntToStr(e)+']',DateTabs[i][e].Caption,AppPath + FileName);
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
for z := 0 to High(SetList[i][e]) do
WriteINI('Clients','SetList['+IntToStr(i)+']['+IntToStr(e)+']['+IntToStr(z)+']',SetList[i][e][z].Text,AppPath + FileName);
end;
Function LoadSettings: Boolean;
var
i,e,z,w,x: Integer;
begin
if(ReadINI('Clients','ClientTabs Length',AppPath + FileName) = '')then
begin
Result := False;
Exit;
end;
SetArrayLength(ClientTabs,StrToInt(ReadINI('Clients','ClientTabs Length',AppPath + FileName)));
NumberOfClients := GetArrayLength(ClientTabs);
SetArrayLength(DateTabs,StrToInt(ReadINI('Clients','DateTabs Length',AppPath + FileName)));
for i := 0 to High(DateTabs) do
SetArrayLength(DateTabs[i],StrToInt(ReadINI('Clients','DateTabs['+IntToStr(i)+']'+' Length',AppPath + FileName)));
SetArrayLength(SubTabs,GetArrayLength(ClientTabs)*2);
SetArrayLength(Notes,GetArrayLength(ClientTabs));
SetArrayLength(ClientControl,GetArrayLength(ClientTabs));
SetArrayLength(DateControl,GetArrayLength(ClientTabs));
SetArrayLength(SetList,GetArrayLength(ClientTabs));
for i := 0 to High(SetList) do
begin
SetArrayLength(SetList[i],GetArrayLength(DateTabs[i]));
for e := 0 to High(SetList[i]) do
SetArrayLength(SetList[i][e],27);
end;
SetArrayLength(RepList,GetArrayLength(ClientTabs));
for i := 0 to High(RepList) do
begin
SetArrayLength(RepList[i],GetArrayLength(DateTabs[i]));
for e := 0 to High(RepList[i]) do
SetArrayLength(RepList[i][e],27);
end;
SetArrayLength(SetLabel,9);
SetArrayLength(ExerciseList,GetArrayLength(ClientTabs));
for i := 0 to High(ExerciseList) do
SetArrayLength(ExerciseList[i],GetArrayLength(DateTabs[i]));
SetArrayLength(EButton,GetArrayLength(ClientTabs));
for i := 0 to High(EButton) do
SetArrayLength(EButton[i],GetArrayLength(DateTabs[i]));
SetArrayLength(EEButton,GetArrayLength(ClientTabs));
for i := 0 to High(EEButton) do
SetArrayLength(EEButton[i],GetArrayLength(DateTabs[i]));
for i := 0 to High(ClientTabs) do
begin
ClientTabs[i] := TTabSheet.Create(frmdesign);
ClientTabs[i].PageControl := PageControl[1];
ClientTabs[i].OnShow := @Identify;
end;
for i := 0 to High(ClientControl) do
begin
ClientControl[i] := TPageControl.Create(frmdesign);
with ClientControl[i] do
begin
Parent := ClientTabs[i];
Left := 5;
Top := 5;
Width := 660;
Height := 725;
TabOrder := 0;
end;
end;
e := 0;
x := 0;
for i := 0 to High(SubTabs) do
begin
SubTabs[i] := TTabSheet.Create(frmdesign);
with SubTabs[i] do
begin
case i of
0+e:
begin
PageControl := ClientControl[x];
Caption := 'Workouts';
end;
1+e:
begin
PageControl := ClientControl[x];
Caption := 'Notes';
e := e + 2;
x := x + 1;
end;
end;
end;
end;
{for i := 0 to High(Notes) do //My TRichEdit
begin
Notes[i] := TRichEdit.Create(frmDesign);
with Notes[i] do
begin
Parent := SubTabs[i+1]
Top := 5;
Left := 5;
Width := 600;
Height := 700;
Text := (ReadINI('Clients','Notes['+IntToStr(i)+']',AppPath + FileName));
end;
end; }
e := 0;
for i := 0 to High(DateControl) do
begin
DateControl[i] := TPageControl.Create(frmdesign);
with DateControl[i] do
begin
Parent := SubTabs[e];
Left := 5;
Top := 5;
Width := 650;
Height := 725;
TabOrder := 0;
end;
e := e + 2;
end;
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
begin
DateTabs[i][e] := TTabSheet.Create(frmdesign);
with DateTabs[i][e] do
begin
PageControl := DateControl[i];
Caption := 'Date';
OnShow := @ID;
end;
end;
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
begin
x := 5;
for z := 0 to 8 do
begin
if z > 0 then
x := 0;
SetLabel[z] := TLabel.Create(frmdesign);
with SetLabel[z] do
begin
Parent := DateTabs[i][e]
Left := 7;
Top := x + z*69;
case z of
0: Caption := 'Warm Up';
1,2,3,4,5,6,7: Caption := 'Set ' + IntToStr(z);
8: Caption := 'Cool Down';
end;
with Font do
begin
Name := 'Ms Sans Serif';
Color := clBlack;
//Style := [fsBold];
end;
end;
end;
end;
w := 0;
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
begin
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
w := w + 7;
SetList[i][e][z] := TEdit.Create(frmdesign);
with SetList[i][e][z] do
begin
Parent := DateTabs[i][e];
Left := 75;
Top :=(z*20) + w;
Width := 200;
Height := 15;
OnClick := @Selected;
end;
end;
w := 0;
end;
for i := 0 to High(RepList) do
for w := 0 to High(RepList[i]) do
begin
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
RepList[i][w][z] := TEdit.Create(frmdesign);
with RepList[i][w][z] do
begin
Parent := DateTabs[i][w];
Left := 250;
Top :=(z*20) + e;
Width := 100;
Height := 15;
end;
end;
e := 0;
end;
for i := 0 to High(ExerciseList) do
for e := 0 to High(ExerciseList[i]) do
begin
ExerciseList[i][e] := TListBox.Create(frmdesign);
with ExerciseList[i][e] do
begin
Parent := DateTabs[i][e];
Left := 400;
Top := 30;
Width := 200;
Height := 570;
Color := clWhite;
OnDblClick := @FillEdits;
end;
end;
for i := 0 to High(EButton) do
for e := 0 to High(EButton[i]) do
begin
EButton[i][e] := TButton.Create(frmdesign);
with EButton[i][e] do
begin
Parent := DateTabs[i][e];
Left := 400;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
for i := 0 to High(EEButton) do
for e := 0 to High(EEButton[i]) do
begin
EEButton[i][e] := TButton.Create(frmdesign);
with EEButton[i][e] do
begin
Parent := DateTabs[i][e];
Left := 500;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
for i := 0 to High(ClientTabs) do
ClientTabs[i].Caption := ReadINI('Clients','ClientTabs['+IntToStr(i)+']',AppPath + FileName);
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
DateTabs[i][e]. Caption := ReadINI('Clients','DateTabs['+IntToStr(i)+']['+IntToStr(e)+']',AppPath + FileName);
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
for z := 0 to High(SetList[i][e]) do
SetList[i][e][z].Text := ReadINI('Clients','SetList['+IntToStr(i)+']['+IntToStr(e)+']['+IntToStr(z)+']',AppPath + FileName);
Result := True;
end;
EDIT: Oh yeah, its an Array of TRichEdit btw. Ill need each TRichEdit in the array to load its own unique text.
METAL HEAD FOR LIFE!!!
you're missing a ' before Notes['+IntToStr(i) are you not? but other than that, i cannot see a problem. I just tried it on my own test thing and it works fine.
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
indeed, mine loads the whole thing. Might i see the entire script, so i can test it myself?
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
hmm. I tested with a writeln and all the lines will come up there... just wont load them into the actual TRichEdit. I think it might have to do with the ReadINI proc. Not sure tho.
Heres the whole script:
SCAR Code:program New;
var
frmDesign : TForm;
Main: TMainMenu;
Menu: array of array of TMenuItem;
Names,Exercises: array of TStringArray;
PageControl,ClientControl,DateControl: array of TPageControl;
MainTabs,ClientTabs,SubTabs: array of TTabSheet;
DateTabs: array of array of TTabSheet;
AddButtons,DeleteButtons: array of TButton;
SetList,RepList: array of array of array of TEdit;
SetLabel: array of TLabel;
Notes: array of TRichEdit;
ExerciseList: array of array of TListBox;
EButton,EEButton: array of array of TButton;
MasterList: TListBox;
PMenu,PMenu2: TPopupMenu;
PMenuList,PMenuList2: array of TMenuItem;
var
PrintFrm: TForm;
PrintEdit: TRichEdit;
PrintButton: TButton;
var
NumberOfClients,CurrentTab,CurrentList,CurrentSet: Integer;
ClientNames: TStringArray;
ClientDates: array of array of String;
TR: TRect;
var
v: TVariantArray;
const
FileName = 'Client.INI';
procedure Identify(Sender: TObject);
var
i,z: Integer;
begin
for i := 0 to High(ClientTabs) do
for z := 0 to High(SubTabs) do
case Sender of
ClientTabs[i]: CurrentTab := i;
//SubTabs[z]: Writeln('SubTab ' + IntToStr(z));
end;
Writeln('Current Tab: ' + IntToStr(CurrentTab));
end;
Procedure ID(Sender: TObject);
var
i,l: Integer;
begin
for l := 0 to High(DateTabs) do
begin
for i := 0 to High(DateTabs[l]) do
begin
case Sender of
DateTabs[l][i]: CurrentList := i;
end;
end;
end;
Writeln('Current List: ' + IntToStr(CurrentList));
end;
procedure Selected(Sender: TObject);
var
i,e,z: Integer;
begin
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
for z := 0 to 26 do
case Sender of
SetList[i][e][z]: CurrentSet := z;
end;
end;
procedure FillEdits(Sender: TObject);
var
i,z,w: Integer;
begin
i := CurrentTab;
w := CurrentList;
if SetList[i][w][CurrentSet].Text = '' then
begin
SetList[i][w][CurrentSet].Text := ExerciseList[i][w].Items.Strings[ExerciseList[i][w].ItemIndex];
Exit;
end;
for z := 0 to 26 do
begin
if SetList[i][w][z].Text = '' then
begin
SetList[i][w][z].Text := ExerciseList[i][w].Items.Strings[ExerciseList[i][w].ItemIndex];
Exit;
end;
end;
end;
procedure PopUp(Sender: TObject);
var
x,y,i,w: Integer;
begin
i := CurrentTab;
w := CurrentList;
GetMousePos(x,y);
case Sender of
EButton[i][w]: PMenu.Popup(x,y);
EEButton[i][w]: PMenu2.Popup(x,y);
end;
end;
procedure SaveSettings;
var
i,e,z: Integer;
begin
WriteINI('Clients','ClientTabs Length',IntToStr(GetArrayLength(ClientTabs)),AppPath + FileName);
WriteINI('Clients','DateTabs Length',IntToStr(GetArrayLength(ClientTabs)),AppPath + FileName);
for i := 0 to High(ClientTabs) do
WriteINI('Clients','DateTabs['+IntToStr(i)+']'+' Length',IntToStr(GetArrayLength(DateTabs[i])),AppPath + FileName);
for i := 0 to High(ClientTabs) do
WriteINI('Clients','ClientTabs['+IntToStr(i)+']',ClientTabs[i].Caption,AppPath + FileName);
for i := 0 to High(Notes) do // This is my TRichEdit.
begin
WriteINI('Clients','Notes['+IntToStr(i)+']',Notes[i].Text,AppPath + FileName);
Writeln(Notes[i].Text);
end;
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
WriteINI('Clients','DateTabs['+IntToStr(i)+']['+IntToStr(e)+']',DateTabs[i][e].Caption,AppPath + FileName);
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
for z := 0 to High(SetList[i][e]) do
WriteINI('Clients','SetList['+IntToStr(i)+']['+IntToStr(e)+']['+IntToStr(z)+']',SetList[i][e][z].Text,AppPath + FileName);
end;
Function LoadSettings: Boolean;
var
i,e,z,w,x: Integer;
begin
if(ReadINI('Clients','ClientTabs Length',AppPath + FileName) = '')then
begin
Result := False;
Exit;
end;
SetArrayLength(ClientTabs,StrToInt(ReadINI('Clients','ClientTabs Length',AppPath + FileName)));
NumberOfClients := GetArrayLength(ClientTabs);
SetArrayLength(DateTabs,StrToInt(ReadINI('Clients','DateTabs Length',AppPath + FileName)));
for i := 0 to High(DateTabs) do
SetArrayLength(DateTabs[i],StrToInt(ReadINI('Clients','DateTabs['+IntToStr(i)+']'+' Length',AppPath + FileName)));
SetArrayLength(SubTabs,GetArrayLength(ClientTabs)*2);
SetArrayLength(Notes,GetArrayLength(ClientTabs));
SetArrayLength(ClientControl,GetArrayLength(ClientTabs));
SetArrayLength(DateControl,GetArrayLength(ClientTabs));
SetArrayLength(SetList,GetArrayLength(ClientTabs));
for i := 0 to High(SetList) do
begin
SetArrayLength(SetList[i],GetArrayLength(DateTabs[i]));
for e := 0 to High(SetList[i]) do
SetArrayLength(SetList[i][e],27);
end;
SetArrayLength(RepList,GetArrayLength(ClientTabs));
for i := 0 to High(RepList) do
begin
SetArrayLength(RepList[i],GetArrayLength(DateTabs[i]));
for e := 0 to High(RepList[i]) do
SetArrayLength(RepList[i][e],27);
end;
SetArrayLength(SetLabel,9);
SetArrayLength(ExerciseList,GetArrayLength(ClientTabs));
for i := 0 to High(ExerciseList) do
SetArrayLength(ExerciseList[i],GetArrayLength(DateTabs[i]));
SetArrayLength(EButton,GetArrayLength(ClientTabs));
for i := 0 to High(EButton) do
SetArrayLength(EButton[i],GetArrayLength(DateTabs[i]));
SetArrayLength(EEButton,GetArrayLength(ClientTabs));
for i := 0 to High(EEButton) do
SetArrayLength(EEButton[i],GetArrayLength(DateTabs[i]));
for i := 0 to High(ClientTabs) do
begin
ClientTabs[i] := TTabSheet.Create(frmdesign);
ClientTabs[i].PageControl := PageControl[1];
ClientTabs[i].OnShow := @Identify;
end;
for i := 0 to High(ClientControl) do
begin
ClientControl[i] := TPageControl.Create(frmdesign);
with ClientControl[i] do
begin
Parent := ClientTabs[i];
Left := 5;
Top := 5;
Width := 660;
Height := 725;
TabOrder := 0;
end;
end;
e := 0;
x := 0;
for i := 0 to High(SubTabs) do
begin
SubTabs[i] := TTabSheet.Create(frmdesign);
with SubTabs[i] do
begin
case i of
0+e:
begin
PageControl := ClientControl[x];
Caption := 'Workouts';
end;
1+e:
begin
PageControl := ClientControl[x];
Caption := 'Notes';
e := e + 2;
x := x + 1;
end;
end;
end;
end;
for i := 0 to High(Notes) do //My TRichEdit
begin
Notes[i] := TRichEdit.Create(frmDesign);
with Notes[i] do
begin
Parent := SubTabs[i+1]
Top := 5;
Left := 5;
Width := 600;
Height := 700;
Text := ReadINI('Clients','Notes['+IntToStr(i)+']',AppPath + FileName);
end;
end;
e := 0;
for i := 0 to High(DateControl) do
begin
DateControl[i] := TPageControl.Create(frmdesign);
with DateControl[i] do
begin
Parent := SubTabs[e];
Left := 5;
Top := 5;
Width := 650;
Height := 725;
TabOrder := 0;
end;
e := e + 2;
end;
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
begin
DateTabs[i][e] := TTabSheet.Create(frmdesign);
with DateTabs[i][e] do
begin
PageControl := DateControl[i];
Caption := 'Date';
OnShow := @ID;
end;
end;
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
begin
x := 5;
for z := 0 to 8 do
begin
if z > 0 then
x := 0;
SetLabel[z] := TLabel.Create(frmdesign);
with SetLabel[z] do
begin
Parent := DateTabs[i][e]
Left := 7;
Top := x + z*69;
case z of
0: Caption := 'Warm Up';
1,2,3,4,5,6,7: Caption := 'Set ' + IntToStr(z);
8: Caption := 'Cool Down';
end;
with Font do
begin
Name := 'Ms Sans Serif';
Color := clBlack;
//Style := [fsBold];
end;
end;
end;
end;
w := 0;
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
begin
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
w := w + 7;
SetList[i][e][z] := TEdit.Create(frmdesign);
with SetList[i][e][z] do
begin
Parent := DateTabs[i][e];
Left := 75;
Top :=(z*20) + w;
Width := 200;
Height := 15;
OnClick := @Selected;
end;
end;
w := 0;
end;
for i := 0 to High(RepList) do
for w := 0 to High(RepList[i]) do
begin
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
RepList[i][w][z] := TEdit.Create(frmdesign);
with RepList[i][w][z] do
begin
Parent := DateTabs[i][w];
Left := 250;
Top :=(z*20) + e;
Width := 100;
Height := 15;
end;
end;
e := 0;
end;
for i := 0 to High(ExerciseList) do
for e := 0 to High(ExerciseList[i]) do
begin
ExerciseList[i][e] := TListBox.Create(frmdesign);
with ExerciseList[i][e] do
begin
Parent := DateTabs[i][e];
Left := 400;
Top := 30;
Width := 200;
Height := 570;
Color := clWhite;
OnDblClick := @FillEdits;
end;
end;
for i := 0 to High(EButton) do
for e := 0 to High(EButton[i]) do
begin
EButton[i][e] := TButton.Create(frmdesign);
with EButton[i][e] do
begin
Parent := DateTabs[i][e];
Left := 400;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
for i := 0 to High(EEButton) do
for e := 0 to High(EEButton[i]) do
begin
EEButton[i][e] := TButton.Create(frmdesign);
with EEButton[i][e] do
begin
Parent := DateTabs[i][e];
Left := 500;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
for i := 0 to High(ClientTabs) do
ClientTabs[i].Caption := ReadINI('Clients','ClientTabs['+IntToStr(i)+']',AppPath + FileName);
for i := 0 to High(DateTabs) do
for e := 0 to High(DateTabs[i]) do
DateTabs[i][e]. Caption := ReadINI('Clients','DateTabs['+IntToStr(i)+']['+IntToStr(e)+']',AppPath + FileName);
for i := 0 to High(SetList) do
for e := 0 to High(SetList[i]) do
for z := 0 to High(SetList[i][e]) do
SetList[i][e][z].Text := ReadINI('Clients','SetList['+IntToStr(i)+']['+IntToStr(e)+']['+IntToStr(z)+']',AppPath + FileName);
Result := True;
end;
procedure PrintIt(Sender: TObject);
begin
PrintEdit.Print('Workout');
PrintFrm.ModalResult := mrOK;
end;
procedure InitForm2;
var
i: Integer;
x: String;
begin
PrintFrm := CreateForm;
with PrintFrm do
begin
Position := poScreenCenter;
Width := 400;
Height := 725;
Caption := 'PrintFrm';
end;
PrintEdit := TRichEdit.Create(PrintFrm);
with PrintEdit do
begin
Parent := PrintFrm;
Top := 0;
Left := 0;
Width := 383;
Height := 650;
Font.Name := 'Tempus Sans ITC'
Font.Size := 10;
Font.Style := [fsBold];
Lines.Add('Client: ' + ClientTabs[CurrentTab].Caption);
Lines.Add('Date: ' + DateTabs[CurrentTab][CurrentList].Caption);
for i := 0 to High(SetList[CurrentTab][CurrentList])do
begin
if((i mod 3) = 0)then
Lines.Add('-----------------------------------------------------');
x := SetList[CurrentTab][CurrentList][i].Text;
if(x = '')then
Continue;
Lines.Add(x + ' ' + RepList[CurrentTab][CurrentList][i].Text);
end;
end;
PrintButton := TButton.Create(PrintFrm);
with PrintButton do
begin
Parent := PrintFrm;
Top := 650;
Left := 150;
Width := 60;
Height := 30;
Caption := 'Print';
OnClick := @PrintIt;
end;
end;
procedure ShowFormModal2;
begin
PrintFrm.showmodal;
end;
procedure PrintForm(Sender: TObject);
begin
GetSelf.WindowState := wsMinimized;
try
setarraylength(V, 0);
ThreadSafeCall('InitForm2', v);
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal2', v);
finally
FreeForm(PrintFrm);
except
WriteLn('FAIL');
end;
end;
procedure MenuSelect(Sender: TObject);
var
i,w: Integer;
begin
i := CurrentTab;
w := CurrentList;
case Sender of
Menu[0][3]: PrintForm(Menu[0][3]);
Menu[0][4]: SaveSettings;
Menu[1][1]:
begin
SetArrayLength(ClientNames,GetArrayLength(ClientTabs));
if InputQuery('Client Name','Enter name',ClientNames[i]) then
ClientTabs[i].Caption := ClientNames[i];
end;
Menu[1][2]:
begin
SetArrayLength(ClientDates,GetArrayLength(ClientTabs));
SetArrayLength(ClientDates[i],GetArrayLength(DateTabs[i]));
if(InputQuery('New Session','Enter date',ClientDates[i][w]))then
DateTabs[i][w].Caption := ClientDates[i][w];
end;
end;
end;
procedure MenuClick(Sender: TObject);
var
i,z,w,e: Integer;
begin
i := CurrentTab;
w := CurrentList;
ExerciseList[i][w].Clear;
SetArrayLength(Exercises,10);
Exercises[0] := ['','a','b','c','d','e'];
Exercises[1] := ['','f','g','h','i','j'];
Exercises[2] := ['','k','l','m','n','o'];
Exercises[3] := ['','p','q','r','s','t'];
Exercises[4] := ['','u','v','w','x','y'];
Exercises[5] := ['','z','1','2','3','4'];
Exercises[6] := ['','5','6','7','8','9'];
Exercises[7] := ['','10','I','II','III','IV'];
Exercises[8] := ['','V','VI','VII','VIII','IX'];
Exercises[9] := ['','X','XI','XII','XIII','XIV'];
for z := 0 to High(PMenuList) do
begin
case Sender of
PMenuList[z]:
begin
for e := 0 to High(Exercises[z]) do
ExerciseList[i][w].Items.Add(Exercises[z][e]);
end;
end;
end;
end;
procedure AddItem(Sender: TObject);
var
i,x,z,w,e: Integer;
begin
case Sender of
AddButtons[0]:
begin
Inc(NumberOfClients);
i := NumberOfClients - 1;
SetArrayLength(ClientTabs,NumberOfClients);
SetArrayLength(SubTabs,NumberOfClients+2);
SetArrayLength(DateTabs,NumberOfClients);
SetArrayLength(DateTabs[i],GetArrayLength(DateTabs[i])+1);
SetArrayLength(ClientControl,NumberOfClients);
SetArrayLength(PageControl,GetArrayLength(PageControl)+1);
SetArrayLength(DateControl,GetArrayLength(DateControl)+1);
SetArrayLength(DateControl[i],GetArrayLength(DateControl[i])+1);
SetArrayLength(DateTabs,NumberOfClients);
SetArrayLength(EButton,GetArrayLength(EButton)+1);
SetArrayLength(EButton[i],GetArrayLength(EButton[i])+1);
SetArrayLength(EEButton,GetArrayLength(EEButton)+1);
SetArrayLength(EEButton[i],GetArrayLength(EEButton[i])+1);
SetArrayLength(ExerciseList,GetArrayLength(ExerciseList)+1);
SetArrayLength(ExerciseList[i],GetArrayLength(ExerciseList[i])+1);
SetArrayLength(RepList,GetArrayLength(RepList)+1);
SetArrayLength(RepList[i],GetArrayLength(RepList[i])+1);
SetArrayLength(RepList[i][0],27);
SetArrayLength(SetList,GetArrayLength(SetList)+1);
SetArrayLength(SetList[i],GetArrayLength(SetList[i])+1);
SetArrayLength(SetList[i][0],27);
SetArrayLength(ClientNames,GetArrayLength(ClientTabs));
ClientTabs[i] := TTabSheet.Create(frmdesign);
ClientTabs[i].PageControl := PageControl[1];
ClientTabs[i].OnShow := @Identify;
if InputQuery('New Client','Enter name',ClientNames[i]) then
ClientTabs[i].Caption := ClientNames[i];
ClientControl[i] := TPageControl.Create(frmdesign);
with ClientControl[i] do
begin
Parent := ClientTabs[i];
Left := 5;
Top := 5;
Width := 660;
Height := 725;
TabOrder := 0;
end;
for x := 0 to 1 do
begin
case x of
0:
begin
SubTabs[i] := TTabSheet.Create(frmdesign);
SubTabs[i].PageControl := ClientControl[i];
SubTabs[i].Caption := 'Workouts';
//SubTabs[i].OnShow := @Identify;
end;
1:
begin
SubTabs[i+1] := TTabSheet.Create(frmdesign);
SubTabs[i+1].PageControl := ClientControl[i];
SubTabs[i+1].Caption := 'Notes';
end;
end;
end;
DateControl[i] := TPageControl.Create(frmdesign);
with DateControl[i] do
begin
Parent := SubTabs[i];
Left := 5;
Top := 5;
Width := 650;
Height := 725;
TabOrder := 0;
end;
SetArrayLength(ClientDates,GetArrayLength(ClientTabs));
SetArrayLength(ClientDates[i],GetArrayLength(DateTabs[i]));
w := GetArrayLength(DateTabs[i]) - 1;
DateTabs[i][w] := TTabSheet.Create(frmdesign);
DateTabs[i][w].PageControl := DateControl[i];
if(InputQuery('New Session','Enter date',ClientDates[i][0]))then
DateTabs[i][w].Caption := ClientDates[i][w];
DateTabs[i][w].OnShow := @ID;
x := 5;
for z := 0 to 8 do
begin
if z > 0 then
x := 0;
SetLabel[z] := TLabel.Create(frmdesign);
with SetLabel[z] do
begin
Parent := DateTabs[i][w]
Left := 7;
Top := x + z*69;
case z of
0: Caption := 'Warm Up';
1,2,3,4,5,6,7: Caption := 'Set ' + IntToStr(z);
8: Caption := 'Cool Down';
end;
with Font do
begin
Name := 'Ms Sans Serif';
Color := clBlack;
//Style := [fsBold];
end;
end;
end;
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
SetList[i][0][z] := TEdit.Create(frmdesign);
with SetList[i][0][z] do
begin
Parent := DateTabs[i][w];
Left := 75;
Top :=(z*20) + e;
Width := 200;
Height := 15;
OnClick := @Selected;
end;
end;
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
RepList[i][0][z] := TEdit.Create(frmdesign);
with RepList[i][0][z] do
begin
Parent := DateTabs[i][w];
Left := 250;
Top :=(z*20) + e;
Width := 100;
Height := 15;
end;
end;
ExerciseList[i][0] := TListBox.Create(frmdesign);
with ExerciseList[i][0] do
begin
Parent := DateTabs[i][w];
Left := 400;
Top := 30;
Width := 200;
Height := 570;
Color := clWhite;
OnDblClick := @FillEdits;
end;
EButton[i][0] := TButton.Create(frmdesign);
with EButton[i][0] do
begin
Parent := DateTabs[i][w];
Left := 400;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
EEButton[i][0] := TButton.Create(frmdesign);
with EEButton[i][0] do
begin
Parent := DateTabs[i][0];
Left := 500;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
AddButtons[1]:
begin
i := CurrentTab;
SetArrayLength(DateTabs[i],GetArrayLength(DateTabs[i])+1);
SetArrayLength(EButton[i],GetArrayLength(EButton[i])+1);
SetArrayLength(EEButton[i],GetArrayLength(EEButton[i])+1);
SetArrayLength(ExerciseList[i],GetArrayLength(ExerciseList[i])+1);
SetArrayLength(RepList[i],GetArrayLength(RepList[i])+1);
w := GetArrayLength(DateTabs[i]) - 1;
SetArrayLength(RepList[i][w],27);
SetArrayLength(SetList[i],GetArrayLength(SetList[i])+1);
SetArrayLength(SetList[i][w],27);
SetArrayLength(ClientDates,GetArrayLength(ClientTabs));
SetArrayLength(ClientDates[i],GetArrayLength(DateTabs[i]));
DateTabs[i][w] := TTabSheet.Create(frmdesign);
DateTabs[i][w].PageControl := DateControl[i];
if(InputQuery('New Session','Enter date',ClientDates[i][w]))then
DateTabs[i][w].Caption := ClientDates[i][w];
DateTabs[i][w].OnShow := @ID;
x := 5;
for z := 0 to 8 do
begin
if z > 0 then
x := 0;
SetLabel[z] := TLabel.Create(frmdesign);
with SetLabel[z] do
begin
Parent := DateTabs[i][w]
Left := 7;
Top := x + z*69;
case z of
0: Caption := 'Warm Up';
1,2,3,4,5,6,7: Caption := 'Set ' + IntToStr(z);
8: Caption := 'Cool Down';
end;
with Font do
begin
Name := 'Ms Sans Serif';
Color := clBlack;
//Style := [fsBold];
end;
end;
end;
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
SetList[i][w][z] := TEdit.Create(frmdesign);
with SetList[i][w][z] do
begin
Parent := DateTabs[i][w];
Left := 75;
Top :=(z*20) + e;
Width := 200;
Height := 15;
OnClick := @Selected;
end;
end;
e := 0;
for z := 0 to 26 do
begin
if((z mod 3) = 0)then
e := e + 7;
RepList[i][w][z] := TEdit.Create(frmdesign);
with RepList[i][w][z] do
begin
Parent := DateTabs[i][w];
Left := 250;
Top :=(z*20) + e;
Width := 100;
Height := 15;
end;
end;
ExerciseList[i][w] := TListBox.Create(frmdesign);
with ExerciseList[i][w] do
begin
Parent := DateTabs[i][w];
Left := 400;
Top := 30;
Width := 200;
Height := 570;
Color := clWhite;
OnDblClick := @FillEdits;
end;
EButton[i][w] := TButton.Create(frmdesign);
with EButton[i][w] do
begin
Parent := DateTabs[i][w];
Left := 400;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
EEButton[i][w] := TButton.Create(frmdesign);
with EEButton[i][w] do
begin
Parent := DateTabs[i][w];
Left := 500;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
AddButtons[2]:
begin
end;
end;
end;
procedure InitForm;
var
i,e,x: integer;
begin
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
SetBounds(TR.Left, TR.Top, TR.Right-TR.Left, TR.Bottom-TR.Top);
WindowState := wsMaximized;
Caption := 'frmDesign';
end;
SetArrayLength(Names, 6);
Names[0] := ['File', 'New', 'Open', 'Print','Save', 'Save and Exit'];
Names[1] := ['Edit', 'Edit Name', 'Edit Date'];
Names[2] := ['Tools', 'Options'];
Names[3] := ['Help', 'Help', 'Manual', 'About'];
SetArrayLength(Menu, GetArrayLength(names)); //Sets the length of the Menu array to the number of menus
Main := TMainMenu.Create(frmdesign); //Creates the MainMenu that holds all of the items
for i := 0 to high(names) do //Cycles through each Names array
begin
SetArrayLength(Menu[i], GetArrayLength(Names[i]));//Sets the length of menu items to the number of items in the corresponding names array
for e := 0 to high(names[i]) do //Cycles through each item in Names[i]
begin
Menu[i][e] := TMenuItem.Create(frmdesign); //Creates each MenuItem
Menu[i][e].Caption := Names[i][e]; //Makes the Caption of each Item, the specified string
if e = 0 then //if its the first item in the array then
Main.Items.Add(Menu[i][e]) //add it as a Menu
else //else
Main.Items.Items[i].add(Menu[i][e]); //add it as an Item to the "i" menu
Menu[i][e].OnClick := @MenuSelect; //OnClick event for the menu items
end;
end;
SetArrayLength(PageControl,3);
PageControl[0] := TPageControl.Create(frmdesign);
with PageControl[0] do
begin
Parent := frmdesign;
Left := 577;
Top := 5;
Width := 685;
Height := 725;
TabOrder := 0;
end;
SetArrayLength(MainTabs,2);
MainTabs[0] := TTabSheet.Create(frmdesign);
MainTabs[0].PageControl := PageControl[0];
MainTabs[0].Caption := 'Clients';
MainTabs[1] := TTabSheet.Create(frmdesign);
MainTabs[1].PageControl := PageControl[0];
MainTabs[1].Caption := 'Exercises';
MasterList := TListBox.Create(frmdesign);
with MasterList do
begin
Parent := MainTabs[1];
Left := 5;
Top := 30;
Width := 350;
Height := 400;
end;
PageControl[1] := TPageControl.Create(frmdesign);
with PageControl[1] do
begin
Parent := MainTabs[0];
Left := 5;
Top := 5;
Width := 670;
Height := 725;
TabOrder := 0;
end;
if(not(LoadSettings))then
begin
SetArrayLength(ClientNames,1);
SetArrayLength(ClientDates,1);
SetArrayLength(ClientDates[0],1);
NumberOfClients := 1;
SetArrayLength(ClientTabs,1);
SetArrayLength(ClientNames,1);
ClientTabs[0] := TTabSheet.Create(frmdesign);
ClientTabs[0].PageControl := PageControl[1];
ClientTabs[0].Caption := 'New Client';
ClientTabs[0].OnShow := @Identify;
PageControl[2] := TPageControl.Create(frmdesign);
with PageControl[2] do
begin
Parent := ClientTabs[0];
Left := 5;
Top := 5;
Width := 660;
Height := 725;
TabOrder := 0;
end;
SetArrayLength(SubTabs,2);
for i := 0 to 1 do
begin
SubTabs[i] := TTabSheet.Create(frmdesign);
SubTabs[i].PageControl := PageControl[2];
end;
SubTabs[0].Caption := 'Workouts';
SubTabs[1].Caption := 'Notes';
SetArrayLength(Notes,1)
Notes[0] := TRichEdit.Create(frmDesign);
with Notes[0] do
begin
Parent := SubTabs[1];
Top := 5;
Left := 5;
Width := 600;
Height := 700;
end;
SetArrayLength(DateControl,1);
SetArrayLength(DateControl[0],1);
DateControl[0] := TPageControl.Create(frmdesign);
with DateControl[0] do
begin
Parent := SubTabs[0];
Left := 5;
Top := 5;
Width := 650;
Height := 725;
TabOrder := 0;
end;
SetArrayLength(DateTabs,1);
SetArrayLength(DateTabs[0],1);
DateTabs[0][0] := TTabSheet.Create(frmdesign);
DateTabs[0][0].PageControl := DateControl[0];
DateTabs[0][0].Caption := 'Date';
DateTabs[0][0].OnShow := @ID;
SetArrayLength(SetLabel,9);
x := 5;
for i := 0 to 8 do
begin
if i > 0 then
x := 0;
SetLabel[i] := TLabel.Create(frmdesign);
with SetLabel[i] do
begin
Parent := DateTabs[0][0]
Left := 7;
Top := x + i*69;
case i of
0: Caption := 'Warm Up';
1,2,3,4,5,6,7: Caption := 'Set ' + IntToStr(i);
8: Caption := 'Cool Down';
end;
with Font do
begin
Name := 'Ms Sans Serif';
Color := clBlack;
//Style := [fsBold];
end;
end;
end;
SetArrayLength(SetList,1);
SetArrayLength(SetList[0],1);
SetArrayLength(SetList[0][0],27);
e := 0;
for i := 0 to 26 do
begin
if((i mod 3) = 0)then
e := e + 7;
SetList[0][0][i] := TEdit.Create(frmdesign);
with SetList[0][0][i] do
begin
Parent := DateTabs[0][0];
Left := 75;
Top :=(i*20) + e;
Width := 200;
Height := 15;
OnClick := @Selected;
end;
end;
SetArrayLength(RepList,1);
SetArrayLength(RepList[0],1);
SetArrayLength(RepList[0][0],27);
e := 0;
for i := 0 to 26 do
begin
if((i mod 3) = 0)then
e := e + 7;
RepList[0][0][i] := TEdit.Create(frmdesign);
with RepList[0][0][i] do
begin
Parent := DateTabs[0][0];
Left := 250;
Top :=(i*20) + e;
Width := 100;
Height := 15;
end;
end;
SetArrayLength(ExerciseList,1);
SetArrayLength(ExerciseList[0],1);
ExerciseList[0][0] := TListBox.Create(frmdesign);
with ExerciseList[0][0] do
begin
Parent := DateTabs[0][0];
Left := 400;
Top := 30;
Width := 200;
Height := 570;
Color := clWhite;
OnDblClick := @FillEdits;
end;
SetArrayLength(EButton,1);
SetArrayLength(EButton[0],1);
EButton[0][0] := TButton.Create(frmdesign);
with EButton[0][0] do
begin
Parent := DateTabs[0][0];
Left := 400;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
SetArrayLength(EEButton,1);
SetArrayLength(EEButton[0],1);
EEButton[0][0] := TButton.Create(frmdesign);
with EEButton[0][0] do
begin
Parent := DateTabs[0][0];
Left := 500;
Top := 15;
Width := 100;
Height := 15;
Caption := '';
OnClick := @PopUp;
end;
end;
Names[4] := ['Upper','Lower','Total','Arms','Legs','Abs','Plyo','Flexibility','Titleist','Muscle Groups'];
Names[5] := ['Back','Chest','Shoulders','Biceps','Triceps','Quads','Hamstrings','Glutes',
'Adductors','Abductors','Upper Abs','Lower Abs','Obliques'];
SetArrayLength(PMenuList,10);
for i := 0 to 9 do
begin
PMenuList[i] := TMenuItem.Create(frmdesign);
with PMenuList[i] do
begin
Caption := Names[4][i];
OnClick := @MenuClick;
end;
end;
SetArrayLength(PMenuList2,13);
for i := 0 to 12 do
begin
PMenuList2[i] := TMenuItem.Create(frmdesign);
with PMenuList2[i] do
begin
Caption := Names[5][i];
OnClick := @MenuClick;
end;
end;
PMenu := TPopupMenu.Create(frmdesign);
with PMenu do
begin
for i := 0 to High(PMenuList) do
Items.Add(PMenuList[i]);
end;
PMenu2 := TPopupMenu.Create(frmdesign);
with PMenu2 do
begin
for i := 0 to High(PMenuList2) do
Items.Add(PMenuList2[i]);
end;
SetArrayLength(AddButtons,2);
for i := 0 to 1 do
begin
AddButtons[i] := TButton.Create(frmdesign);
with AddButtons[i] do
begin
Parent := frmdesign;
Left := 400;
Top := 200 + (i*40);
Width := 70;
Height := 30;
OnClick := @AddItem;
end;
end;
AddButtons[0].Caption := 'Add Client';
AddButtons[1].Caption := 'Add Session';
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
begin
GetSelf.WindowState := wsMinimized;
try
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
finally
FreeForm(frmDesign);
except
WriteLn('FAIL');
end;
GetSelf.WindowState := wsMaximized;
end.
Type what you want into the Notes section and do File --> Save.
EDIT: I had problems with the latest SCAR crashing so I am using SCAR 3.14. Not sure if that will make a difference, but i figure i'd let ya know
METAL HEAD FOR LIFE!!!
huh. Its the same with my other script. I get no errors, SCAR just disappears when i run it. makes it kind of hard to help...
from the looks of your readini line i dont see why it wouldnt work. open the ini after you saved it and see if all the text is saved there.
Wondering - why are you using ini's to save your text? why not save to a text or rtf or etc file?
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
Yeah lol... all the text is there in the INI but it wont show up. Im using the INI because it was the only way I knew to load/save settings. It seems like a good way to keep it all in one file and able to differentiate the values that go to each unique tab. What would the benefits be to using another file?
METAL HEAD FOR LIFE!!!
I havent really looked at what this is supposed to be doing since i cant run it, but i cant really think of anything that you'd need a trichedit for that would be settingsy or that would lend itself towards...oh its called notes...notes...oh. I though one was typing things in so you could save it...and load it, which you do but i was thinking differently. Erm, well then yea ini is probably a fine medium. lol
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
There are currently 1 users browsing this thread. (0 members and 1 guests)