1

Apologizes, I am new to scripting in Altium, which uses Delphiscript. I am trying to make an array of TEdits, using an input number from a tedit. I followed this post to make the teditarray. In the line Type EditArray = Array of Tedit I get the error "only class declarations allowed"

The altium documentation says you cannot create new objects nor declare array types, but you can declare arrays to variables. I think this may be why it doesn't allow me to create a new class of Teditarray. Is it possible here to make a new object or class to fix the problem?

Here is the solution I ended up using, but I think it is far from ideal: I deleted the Editarray code from above and left in my variable declarations Edits : TEditArr; which gave me no errors (this is not a known identifier last I checked). When I hit run, it gives me a new error in the for loop:

For e in Edits do
        Begin
          E.Top:=Y; E.Left:=0;
          INC(Y,E.Height+8)
        end;

Error in for line: : expected

To get around all of this, I tried a static array: Edits : Array [0..50] of TEdit; I then have this function which, when recieving a number from the first edit box, checks for an integer and then creates the inputted quantity of tedit boxes:

if (TryStrtoInt(edit1.text,1)) = TRUE Then
     Begin
        Ports := Strtoint(edit1.text);
        For a := 1 to Ports do
        Begin
          Edits[PRED(a)] := TEdit.Create(Self);
          Edits[PRED(a)].Parent := Self;
          Edits[PRED(a)].Top := Y + 344;
          Edits[PRED(a)].Left := 32;
          INC(Y,Edits[PRED(a)].Height+8)
        end;
      ShowInfo('created ports:');
     end;
   end;

where ports is the number of tedit boxes I would like. I would still like to get this dynamic array working one day, and want to know if anyone would know how to do this.

Ethan Levy
  • 21
  • 1
  • Why are you tagging your question with ``delphi``, when you use something else!? – Delphi Coder Jul 13 '22 at 04:39
  • You are trying to declare a new type which appears not to be allowed in `altium-designer`. You should try to declare your dynamic array as variable `var EditArray = Array of TEdit`. Maybe this is allowed. I'm not sure since I have never used `altium-designer` myself. – SilverWarior Jul 13 '22 at 12:17
  • I was able to set the var Editarray as I mentioned, but it is not dynamic. – Ethan Levy Jul 20 '22 at 20:22

0 Answers0