0 Members and 1 Guest are viewing this topic.
procedure TextBox(ID: byte; title,input,delim: string; wallx,wally,corner: char; color: longint);var i,lines,lines2,max,tempint,delimlen: integer; output,tempstr: string;beginoutput := '';max := length(title);delimlen := length(delim);i := 0;lines := 1;for i := 1 to length(input) do if copy(input,i,delimlen) = delim then lines := lines + 1;lines2 := lines;for i := 0 to lines-1 do begin tempstr := getpiece(input,delim,i); tempint := length(tempstr); if tempint > max then max := tempint; end;tempint := ((max-length(title)) div 2);output := output + corner + replicate(wallx,tempint) + title + replicate(wallx,max-(tempint+length(title))) + corner + delim;for i := 0 to lines-1 do begin tempstr := getpiece(input,delim,i); if tempstr = nil then begin lines2 := lines2 - 1; continue; end; tempint := length(tempstr); output := output + wally; case copy(tempstr,1,3) of '[r]': output := output + replicate(' ',max-(tempint-3)) + copy(tempstr,4,tempint-3); '[l]': output := output + copy(tempstr,4,tempint-3) + replicate(' ',max-(tempint-3)); '[c]': output := output + replicate(' ',(max-(tempint-3)) div 2) + copy(tempstr,4,tempint-3) + replicate(' ',max-(tempint-3+(max-(tempint-3)) div 2)); else output := output + tempstr + replicate(' ',max-tempint); end; output := output + wally + delim; end;output := output + corner + replicate(wallx,max) + corner;for i := 0 to lines2+1 do begin tempstr := getpiece(output,delim,i); if ((ID >= 0) AND (ID <= 32)) then writeconsole(ID,tempstr,color) else writeln(tempstr); end;end;
procedure TextBoxTest();var buffer: string;beginbuffer := '';buffer := buffer + 'line one is normal' + #6;buffer := buffer + '[c]centered' + #6;buffer := buffer + '[r]right alligned' + #6;buffer := buffer + 'this is a test' + #6;textbox(0,' Title ',buffer,#6,'_','|','+',$ff000000);end;
textbox(0,' Title ', 'line one is normal'#6'[c]centered'#6'[r]right alligned'#6'this is a test',#6,'_','|','+',$ff000000);