0 Members and 2 Guests are viewing this topic.
It is probably because of the pos function (that's me guessing). I will find the problem and fix it when I have the time.Thanks for the feedback guys =D
function retrievepropertext(text, linesplitter, datasplitter, nds, textontop: string; fillwith, corner, fillx, filly: char): array of string; //nds = new data splitter
function retrievepropertext(text, linesplitter, datasplitter, nds, textontop: string; fillwith, corner, fillx, filly: char): array of string; //nds = new data splittervar s, q, u, y, datalen: byte; bef, af: array of string; i: array of integer; d: array of array of string; sq: array of array of integer; temp: string;beginif (text = nil) or (linesplitter = nil) or (datasplitter = nil) or (nds = '') or (fillwith = '') or (fillx = '') or (filly = '') then exit;setarraylength(result,0);text := text + linesplitter; //PRECISA fazer issobef := explode(text,linesplitter);while bef[getarraylength(bef)-1] = nil do setarraylength(bef,getarraylength(bef)-1); //isso TAMBÉM precisa fazerfor s := 0 to getarraylength(bef)-1 do bef[s] := bef[s] + datasplitter;af := explode(bef[0],datasplitter); //pra poupar variáveis né.. vida de pobre dá nissodatalen := getarraylength(af);setarraylength(i,datalen);setarraylength(d,getarraylength(bef));setarraylength(sq,getarraylength(bef));setarraylength(af,getarraylength(bef));setarraylength(result,getarraylength(bef));for s := 0 to getarraylength(d)-1 do setarraylength(d[s],datalen);for s := 0 to getarraylength(sq)-1 do setarraylength(sq[s],datalen);for s := 0 to getarraylength(af)-1 do begin //loop principal af[s] := ''; for q := 0 to datalen do begin //nesse loop, retirar o velho datasplitter e adicionar o novo no lugar dele (nds) u := pos(datasplitter,bef[s]); if q < datalen then sq[s][q] := u; af[s] := af[s] + copy(bef[s],1,u-1) + iif(q = datalen,'',nds); delete(bef[s],1,u + length(datasplitter) - 1); end; bef[s] := af[s]; for q := 0 to datalen-1 do begin //nesse loop, verificar quais são as maiores datas de cada linha u := pos(nds,bef[s]); if u-1 > i[q] then i[q] := u-1; delete(bef[s],1,u + length(nds) - 1); end; end;for s := 0 to getarraylength(af)-1 do for q := 0 to datalen-1 do begin //nesse loop, adicionar os chars à variável result u := sq[s][q]; for y := u-1 to i[q] do d[s][q] := d[s][q] + iif(y = i[q],'',fillwith); result[s] := result[s] + copy(af[s],1,u-1) + d[s][q] + iif(q = datalen-1,'',nds); delete(af[s],1,u + length(nds) - 1); end;setarraylength(result,getarraylength(result)+2); //adicionar dois "blanks" no final da arrayfor s := getarraylength(result)-2 downto 1 do result[s] := result[s-1]; //e agora mover os textos para uma posição acimaresult[0] := '';i[0] := 0;for s := 0 to getarraylength(result)-1 do if length(result[s])+2 > i[0] then i[0] := length(result[s])+2; //i[0] is now the lenghtiest motherfucking linefor s := 1 to i[0]-2 do begin temp := result[getarraylength(result)-1]; result[getarraylength(result)-1] := temp + fillx; //put some filling end;for s := 1 to (((i[0]-2) div 2) - (length(textontop) div 2)) do begin temp := result[0]; result[0] := temp + fillx; //fill before the text on top end;temp := result[0];result[0] := temp + textontop; //put the text on topfor s := length(result[0]) to i[0]-3 do begin temp := result[0]; result[0] := temp + fillx; //fill after the text on top end;temp := result[0];result[0] := corner + temp + corner; //put some motherfucking cornerstemp := result[getarraylength(result)-1];result[getarraylength(result)-1] := corner + temp + corner; //put some more motherfucking cornersfor s := 1 to getarraylength(result)-2 do begin temp := result[s]; result[s] := filly + temp + filly; //and box it up to finish it!! end;end;