malo mozganja i malo AI-a i došao sam do onog što sam htio…
ovo snimite kao .cps datoteku i pokrenite unutar korpusa… pitat će vas da unesete tekst koji će vam biti dodan kao prefix u imenu fronte.
trebam informaciju kako da izvučem redni broj elementa koji je trenutno element ima u projektu? koja je to varijabla?
rado bi to dodao kao prefix frontama…
Program DajPrefixFrontama;
var
totalBoards: integer;
d: tDaska;
imeparenta: string;
form: TForm;
edPrefix: TEdit;
btnOk: TButton;
lblPrompt: TLabel;
prefix: string;
function SmjerDaskeToStr(smjer: TSmjerDaske): string;
begin
case smjer of
VertBok: Result := 'VertBok';
VertFront: Result := 'VertFront';
Horiz: Result := 'Horiz';
else
Result := 'Unknown';
end;
end;
procedure ListSpecificBoards(e: telement; levelNum: string; parentName: string);
var
i: integer;
begin
imeparenta := e.naziv;
writeln('Element name: ' + imeparenta);
for i := 0 to e.childdaska.count - 1 do
begin
d := e.childdaska.daska[i];
if d.Visible and (d.smjer = VertFront) and (d.tipdaske = fronta) then
begin
d.naziv := prefix + '_' + d.naziv;
writeln('Novo ime je: ' + d.naziv);
writeln(parentName + ' / ' + e.naziv + ' / ' + d.naziv + ' / ' + SmjerDaskeToStr(d.smjer));
totalBoards := totalBoards + 1;
end;
end;
for i := 0 to e.ElmList.Count - 1 do
begin
ListSpecificBoards(tElement(e.ElmList.Items[i]), levelNum + '.' + IntToStr(i + 1), imeparenta);
end;
end;
procedure btnOkClick(Sender: TObject);
begin
prefix := edPrefix.Text;
form.ModalResult := mrOk;
end;
procedure ShowPrefixForm;
begin
form := TForm.Create(nil);
try
form.Position := poScreenCenter;
form.Width := 300;
form.Height := 150;
form.Caption := 'Enter Prefix';
lblPrompt := TLabel.Create(form);
lblPrompt.Parent := form;
lblPrompt.Caption := 'Upišite prefix koji želite na fronti:';
lblPrompt.Left := 50;
lblPrompt.Top := 20;
edPrefix := TEdit.Create(form);
edPrefix.Parent := form;
edPrefix.Left := 50;
edPrefix.Top := 50;
edPrefix.Width := 200;
btnOk := TButton.Create(form);
btnOk.Parent := form;
btnOk.Caption := 'OK';
btnOk.Left := 100;
btnOk.Top := 90;
btnOk.OnClick := @btnOkClick;
form.ShowModal;
finally
form.Free;
end;
end;
begin
totalBoards := 0;
ShowPrefixForm;
writeln('Root level:');
ListSpecificBoards(e, '1', 'Root');
writeln('');
writeln('Total number of visible VertFront boards with tipdaske fronta: ' + IntToStr(totalBoards));
end.
in editor menu (when editing element) click on icon (next to light bulb and then paste code