3
I have a field edit
in the Delphi
and need to travel it in search of the character >
and store the position of all characters >
in a vector.
By doing this I can only get the position of the first character >
in the memo
, but I must take the position of all.
Texto := memdsformapreparo.Text;
posicao := memdsformapreparo.SelStart; //pega posição do clique
posicaofinal := memdsformapreparo.SelLength; //pega posição final do mouse
posicaoabre := AnsiPos('<', Texto); //pega posição do caractere maior
posicaofecha:= AnsiPos('>', Texto); //pega posição do caractere menor
{if ((posicaoabre <= posicao) and (posicaofecha > posicao)) or ((posicaofinal >= posicaoabre) or (posicaofinal <= posicaofecha)) then
begin
memdsformapreparo.SelStart := posicaofecha;
end;}
To be less verbose in If would do so Setlength(positions, Length(positions) + 1); positions[Length(positions) - 1] := i;
– Lucas Riechelmann Ramos
could do as follows: while(a <= Length(Text)) of Begin c := copy(Text, a, 1); if (c = '>') then Begin larger[nmaior] := a; nmaior := nmaior+1; end; if (c = '<') then Begin minor[nmenor] := a; nmenor := nmenor+1; end; a := a+1; end;
– Lucas Augusto Coelho Lopes