PDA

View Full Version : Pascal e domande idiote ^_^'


Mako87
12-09-2005, 14:07
Mi servirebbe sapere la sintassi per convertire un tipo in un altro
es: string in int
So che č una domanda banale ma non riesco pių a trovarla e non me la ricordo ^^'
:muro:

trapanator
12-09-2005, 16:02
http://www2.toki.or.id/fpcdoc/ref/refsu184.html#x269-27500013.3

http://www2.toki.or.id/fpcdoc/ref/refsu177.html#x262-26800013.3

valgono anche in Turbo Pascal

Mako87
12-09-2005, 18:12
ti ringrazio ^_^ :D :D
Ora avrei un altro problemino, (sto usando delphi), io ho un testo, e devo fare in modo che il programma divida il testo nelle sue singole frasi e le dispogna su un array, come posso fare?

cdimauro
13-09-2005, 11:24
Non ho Delphi a disposizione per poterlo testare, ma "a naso" dovrebbe essere qualcosa di simile a questo:

procedure StringToArray(const s: string; var a: array of string);
var
i, j, OldLength: integer;

procedure SkipSpaces;
begin
while (i <= Length(s)) and (s[i] = ' ') do
Inc(i);
end;

function IsWordAvailable: Boolean;
begin
j := i;
while (i <= Length(s)) and (s[i] <> ' ') do
Inc(i);
Result := i <> j;
end;

begin
i := 1;
while i <= Length(s) do begin
SkipSpaces;
if IsWordAvailable then begin
OldLength := Length(a);
SetLength(a, OldLength + 1);
a[OldLength] := Copy(s, j, i - j);
end;
end;
end;