PREGUNTAS CONTESTADAS - pascal/turbo pascal

 Hay un total de 203 Preguntas.<<  >> 

    Pregunta:  63545 - LEER FECHA DE LA BIOS CON TURBO PASCAL
Autor:  r. b.
Hola, alguien sabe como se puede leer la fecha y la hora desde la bios?. Necesito hacer una agenda y necesito esos datos. Desde ya gracias.
  Respuesta:  ramon garcia
program fechahora;

uses
crt, Dos;
const
days : array [0..6] of String[9] =
('domingo','lunes','martes',
'mi‚rcoles','jueves','viernes',
'S bado');
var
h, m, s, hund : Word; { Para GetTime}
y, ms, d, dow : Word; { para Getdate}

function colocozero(w : Word) : String;
var
s : String;
begin
Str(w:0,s);
if Length(s) = 1 then
s := '0' + s;
colocozero := s;
end;

begin
clrscr;
GetTime(h,m,s,hund);
GetDate(y,ms,d,dow);
textcolor(14);
gotoxy(13,11);write('Hora / Minuto / Segundo');
textcolor(10);
gotoxy(13,13);write(colocozero(h),' / ',colocozero(m),' / ',colocozero(s));
textcolor(14);
gotoxy(13,15);write('Hoy es / Dia / Mes / A¤o');
textcolor(10);
gotoxy(13,17);write(days[dow],' / ',d:0,' / ',ms:0,' / ',y:0);
textcolor(0);
readln;
end.

    Pregunta:  63586 - COMO PUEDO COMPARAR MAS DE 2 VARIABLES?
Autor:  Damian Gonzales
HOLA, YO TENGO QUE COMPARAR 6 VARIABLES DE DISTINTOS VALORES NUMÉRICOS CADA UNA. COMO HAGO? TENGO QE DECIR SI SON O NO MENORES A 40. SE PUEDE HACER ASI:?

IF VAR1 AND VAR2 AND VAR3 AND VAR4 AND VAR5 VAR6 <40 THEN
...
END;

AGRADECERIA MUCHO SU AYUDA ! GRACIAS!
  Respuesta:  Capitan Kirk
Que yo sepa, ni en PASCAL ni en ningún otro lenguaje se puede, las comparaciones tendrás que hacerlas de una en una. Lo que has puesto no es incorrecto desde el punto de vista de la sintaxis, pero funciona de otra forma:

VAR1 AND VAR2 será TRUE si VAR1 y VAR2 son distintos de cero, y FALSE si alguno de ellos es cero. Este resultado se compara con VAR3, resultando TRUE o FALSE, etc.

Así, te toca poner el completo:

IF (VAR1 < 40) AND (VAR2 < 40) AND ....

Por supuesto, con los paréntesis en cada comparación, para evitar sorpresas.

Saludos,

    Pregunta:  63836 - COMO ELIMINAR EL ERROR DIVISION BY ZERO
Autor:  karla giron
Hola estoy empezando y mi programa dice error division by zero, como puedo eliminarlo?? tengo una win XP y es turbo pascal 7
  Respuesta:  Carlos Antonio Casanova Pietroboni
Ese error también me apareció en windows xp, lo que hice fue ponerle un parche que saqué de esta página: http://www.driverop.com.ar/pascal.php#3 . Tiene además otras cosas sobre Turbo Pascal.

Espero que te sirva.

Saludos

    Pregunta:  63884 - LLAMAR UN EJECUTABLE EXTERNO A PASCAL
Autor:  pedro perdomo
Alguien me puede ayudar a llamar una aplicaion externa (.exe), desde Turbo Pascal, cualquiera que sea la aplicacion, es que estamos haciendo un proyecto del semestre y ya terminamos todo, pero nos falta el llamar la aplicacion externa que hicimos que en este caso fue un archivo flash que transformamos en (.exe), la insertamos en la carpeta BIN del turbo pascal y tratamos de llamarla con infinidades de comandos que encontramos en la web pero no nos sirve nada, si pudieran ayudarnos se los agradeceriamos.
  Respuesta:  alfonso juarez
no no soy muy experto pero no se si ya intentaste con hacer un archivo .txt llmando al programa con un call y lo compilas como .bat....

    Pregunta:  63898 - COMO GRAFICAR UNA MATRIZ
Autor:  Salome Antonetti
no se como manejar la interfaz grafica para crear una simple planilla, ya hice alguna de las funciones que se me pidio pero estoy trabada.. aunque sea si sabes de donde puedo sacar informacion facil y entendible.GRACIAS!!!
  Respuesta:  ramon
program grafi;

uses
crt, graph;
var
datos : array[1..6] of real;
drive, modo : integer;
tt, x, y, i : integer;
tecla : char;
temp : real;

procedure entradas;
var
dat : string[6];
ra : real;
err : integer;
begin
i := 1;
gotoxy(10,10);write('Entre N : ');
gotoxy(19,10);clreol;
repeat
tecla := readkey;
if tecla in[#48..#57,#46] then
begin
dat[i] := tecla;
dat[0] := chr(i);
gotoxy(18 + i,10);write(dat[i]);
i := i + 1;
if i > 6 then
i := 6;
end;
if tecla = #8 then
begin
i := i - 1;
if i < 1 then
i := 1;
dat[i] := ' ';
dat[0] := chr(i);
gotoxy(18 + i,10);write(dat[i]);
end;
until tecla = #13;
if i > 1 then
begin
val(dat,ra,err);
datos[tt] := ra;
end;
end;

begin
clrscr;
for tt := 1 to 6 do
begin
entradas;
end;
clrscr;
gotoxy(10,10);write('Presentacion Ordenada o Normal [O/N]');
repeat
tecla := upcase(readkey);
until tecla in[#79,#78];
if tecla = #79 then
begin
temp := 0;
for i := 1 to 6 do
begin
for tt := 1 to 6 do
begin
if datos[i] < datos[tt] then
begin
temp := datos[tt];
datos[tt] := datos[i];
datos[i] := temp;
end;
temp := 0;
end;
end;
end;
clrscr;
drive := detect;
initgraph(drive,modo,'C: pgi'); {Fijate en esto C: pgi ponlo como lo tengas tu}
if graphresult <> 0 then
halt(1);
setcolor(15);
x := 10;
outtextxy((getmaxx div 2) - 40,(getmaxy div 2) + 20,'Grafico de Barras');
for i := 1 to 6 do
begin
bar(((getmaxx div 2)- 36) + i + x,getmaxy div 2,
((getmaxx div 2) - 36) + (i + x) + 10,
(getmaxy div 2) - trunc(datos[i]));
x := x + 12;
end;
readln;
closegraph;
end.

    Pregunta:  64351 - PASAR DE UN PROGRAMA(.PAS) A OTRO .PAS
Autor:  juan perez
Necesito pasar de un "menu principal" hecho en pascal, a otro programa tambien hecho en pascal. En el menu principal pongo diversas opciones, y cada una de ellas me debe llevar a un programa distinto, por favor ayudenme!.
  Respuesta:  ramon garcia
Ejemplo de programa que activara uno exterior:
al finalizar retorna al programa,
program  ejecuci;

{$M $4000,0,0 } {asignacion de memoria}
uses Dos;
var
Programanombre, comandoLinea : string;
begin
Write('Programa a ejecutar (path completo): ');
ReadLn(Programanombre);
Write('L¡nea de comandos a pasar a ', Programanombre, ': ');
ReadLn(comandoLinea);
WriteLn('A punto de ejecutar...');
SwapVectors;
Exec(Programanombre, comandoLinea);
SwapVectors;
WriteLn('...de vuelta');
if DosError <> 0 then{ ¨Error? }
WriteLn('Dos error #', DosError)
else
WriteLn('Ejecuci¢n satisfactoria. ',
'C¢digo de salida de proceso hijo = ',
DosExitCode);
end.

lo puedes colocar solo las partes que te interesen como
procedimiento para llamada a programas diversos.

    Pregunta:  64506 - TRANSFORMAR CADENA A NUMERO
Autor:  Vicen
tengo una duda al realizar un programa, tengo que leer de teclado uan expresion tipo "3-2", "3 / 7", "8 *6",leerlo como cadena y transformarlo para que sea una expresion aritmetica y con el signo de "+ - * /" tengo problemas porque no se como hacerlo.

Muchas gracias por adelantado.
  Respuesta:  ramon garcia
{Espero este te ayude a entenderlo}

program cuentas;

uses
crt, dos;
type
string12 = string[12];
var
dat1, dat2, dat3 : real;
tecla : char;
cade1, cade2, cade3 : string12;

function combierte(ent : string12) : real;
var
num : real;
erro : integer;
begin
val(ent,num,erro);
if erro <> 0 then
exit;
combierte := num;
end;

function entra_dato(x,y : integer) : string12;
var
conta : integer;
cadena : string12;
begin
conta := 1;
fillchar(cadena,13,' ');
cadena[0] := chr(12);
textcolor(1);
repeat
tecla := readkey;
if tecla in[#47..#57,#42,#43,#45] then
begin
cadena[conta] := tecla;
cadena[0] := chr(conta);
conta := conta + 1;
if conta > 12 then
conta := 12;
gotoxy(x,y);write(cadena);
end;
if tecla = #32 then
begin
conta := conta - 1;
if conta < 1 then
conta := 1;
cadena[conta] := ' ';
cadena[0] := chr(conta);
gotoxy(x,y);write(cadena);
end;
until (tecla = #13) or (tecla = #27);
textcolor(15);
if tecla = #13 then
entra_dato := copy(cadena,1,length(cadena))
else
entra_dato := ' ';
end;

function operacion(como : string12) : real;
var
n, cu : integer;
da1, da2 : string12;
nu1, nu2 : real;
dos : boolean;
opera : char;
begin
dos := false;
cu := 1;
n := 1;
fillchar(da1,13,' ');
da1[0] := chr(12);
fillchar(da2,13,' ');
da2[0] := chr(12);
repeat
if como[cu] in [#42,#43,#45,#47] then
begin
opera := como[cu];
dos := true;
end
else
begin
if dos = false then
begin
da1[cu] := como[cu];
da1[0] := chr(cu);
end
else
begin
da2[n] := como[cu];
da2[0] := chr(n);
n := n + 1;
end;
end;
cu := cu + 1;
until cu > Length(como);
nu1 := combierte(da1);
nu2 := combierte(da2);
case opera of
#42 : begin
operacion := nu1 * nu2;
end;
#43 : begin
operacion := nu1 + nu2;
end;
#45 : begin
operacion := nu1 - nu2;
end;
#47 : begin
operacion := nu1 / nu2;
end;
end;
end;

begin
clrscr;
gotoxy(10,20);write('Entre dato : ');
TextBackground(7);
gotoxy(9,22);write(' ');
gotoxy(9,22);
cade1 := entra_dato(10,22);
TextBackground(0);
textcolor(14);
gotoxy(22,20);write(operacion(cade1):8:2);
textcolor(15);
readln;

end.

    Pregunta:  64874 - COMO CORRER PROGRAMAS DE TURBO 7 EN WINDOWS7 EN MODO GRAFICO
Autor:  Luis Lopez
Tengo programas realizados en Turbo pascal 7.0 pero cuando los quiero ejecutar en windows XP, Vista ó Windows 7 este no funciona, solo funciona al principio en la parte de modo texto, al pasar a modo gráfico se bloquea o simplemente se interrumpe. Existe algun modo de hacer que estos programas funcionen en este modo grafico sobre windows7?
  Respuesta:  ramon
[El archivo graph debe de estar en el directorio units y el egavga.bgi en
directorio bgi]

[Esta en desarrollo Pero funciona ]
[tienes el sistema gráfico trabajando en windows 7 sin problema]


program pruefrec;
uses
graph, dos, crt;
const
dividen : real = 1.0;
homio : array[1..8] of string[8] = ('00111100',
'01111110',
'11000011',
'11000011',
'11000011',
'01100110',
'00100100',
'01100110');

Gray : FillPatternType = ($AA, $55, $AA,
$55, $AA, $55, $AA, $55);

fondo : array[0..1] of FillPatternType = (
($AA, $55, $AA, $55, $AA, $55, $AA, $55),
($ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff));

raton : array[1..17] of string[16] =
('1100000000000000',
'1810000000000000',
'1881000000000000',
'1888100000000000',
'1888810000000000',
'1888881000000000',
'1888888100000000',
'1888888810000000',
'1888888881000000',
'1888881111100000',
'1881881000000000',
'1118188100000000',
'1100188100000000',
'0000018810000000',
'0000018810000000',
'0000001810000000',
'0000001110000000');

Var
balor1, balor2, total, conden, conden2 ,resit1, resit2 : real;
pulsada : char;
por, resul, dato : real;
cuenta : string[16];
d, g, x, y : integer;
yy, xr, yr, h, v : integer;
sal : boolean;
OldPattern : FillPatternType;
driver, mode : integer;
cursor : pointer;
ocupa : word;
texgraf : byte;
regs : registers;
esist : boolean;
final, mouse, activo : boolean;

procedure initmouse(como : byte);
begin
texgraf := como;
regs.ax := $00;
intr($33,regs);
esist := regs.ax <> $00;
if texgraf = 1 then
if not mouse then
mouse := true;
end;

function posx_raton : integer;
begin
regs.ax := $03;
intr($33,regs);
posx_raton := regs.cx;
end;

function posy_raton : integer;
begin
regs.ax := $03;
intr($33,regs);
posy_raton := regs.dx;
end;

procedure pon_posicion_raton(xg, yg : word);
begin
regs.ax := $04;
regs.cx := xg;
regs.dx := yg;
intr($33,regs);
end;

function boton_raton : word;
begin
boton_raton := 0;
regs.ah := $00;
regs.al := $03;
intr($33,regs);
boton_raton := regs.bx
end;

function realstring(n : real) : string;
var
s : string[16];
begin
fillchar(s,17,' ');
s[0] := chr(16);
str(n:10:10,s);
realstring := s;
end;

function realstring2(n : real) : string;
var
s : string[16];
begin
fillchar(s,17,' ');
s[0] := chr(16);
str(n:10:3,s);
realstring2 := s;
end;

function stringint(s : string) : integer;
var
n : integer;
error : integer;
begin
stringint := 0;
val(s,n,error);
stringint := n;
end;

procedure frecuencia2(herz : real);
var
sacafre : integer;
begin
dato := herz;
resul := dividen / dato;
cuenta := realstring(resul);
sal := false;
y := 0;
x := 1;
repeat
if cuenta[x] = '0' then
begin
inc(y);
end;
if cuenta[x] > '0' then
begin
sal := true;
end;
inc(x);
until (x > 16) or (sal = true);
sacafre := 1;
case y of
1 : begin
sacafre := 7;
por := 10;
end;
2 : begin
sacafre := 6;
por := 100;
end;
3 : begin
sacafre := 5;
por := 1000;
end;
4 : begin
sacafre := 4;
por := 10000;
end;
5 : begin
sacafre := 3;
por := 100000;
end;
6,7,8,9 : begin
sacafre := 2;
por := 1000000;
end;
end;
rectangle((getmaxx - 110) - 54,108,(getmaxx - 110) + 50,126);
SetFillPattern(Gray, 3);
bar((getmaxx - 110) - 53,109,(getmaxx - 110) + 49,125);
SetFillPattern(Gray, 0);
resul := resul * por;
x := round(resul);
if x < 1 then
x := 2;
g := 0;
d := 0;
for y := 1 to sacafre do
begin
case x of
1 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'-');
end;
2 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'--');
end;
3 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'---');
end;
4 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'----');
end;
5 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'-----');
end;
6 : begin
outtextxy(((getmaxx - 110) - 50) + d * 8,110 + g * 8,'------');
end;
end;
d := d + x;
inc(g);
if g > 1 then
begin
g := 0;
end;
end;
end;


function intstring(n : integer) : string;
var
s : string[8];
begin
fillchar(s,9,' ');
s[0] := chr(8);
str(n,s);
intstring := s;
end;

function wordstring(n : word) : string;
var
s : string[15];
begin
fillchar(s,16,' ');
s[0] := chr(15);
str(n,s);
wordstring := s;
end;

function longntstring(n : longint) : string;
var
s : string[16];
begin
fillchar(s,17,' ');
s[0] := chr(16);
str(n,s);
longntstring := s;
end;

function stringreal(s : string) : real;
var
n : real;
error : integer;
begin
stringreal := 0.1;
val(s,n,error);
stringreal := n;
end;

procedure SG3525A(xl, yl : integer);
var
li : integer;
begin
setcolor(15);
rectangle(xl,yl,xl + 110,yl + 160);
line(xl,yl + 10,xl - 20,yl + 10);
outtextxy(xl + 8,yl + 6,'1');
line(xl,yl + 30,xl - 20,yl + 30);
outtextxy(xl + 8,yl + 26,'2');
line(xl,yl + 50,xl - 20,yl + 50);
outtextxy(xl + 8,yl + 46,'3');
line(xl,yl + 70,xl - 20,yl + 70);
outtextxy(xl + 8,yl + 66,'4');
line(xl,yl + 90,xl - 20,yl + 90);
outtextxy(xl + 8,yl + 86,'5');
line(xl,yl + 110,xl - 20,yl + 110);
outtextxy(xl + 8,yl + 106,'6');
line(xl,yl + 130,xl - 20,yl + 130);
outtextxy(xl + 8,yl + 126,'7');
line(xl,yl + 150,xl - 20,yl + 150);
outtextxy(xl + 8,yl + 146,'8');

line(xl + 110,yl + 10,xl + 130,yl + 10);
outtextxy(xl + 92,yl + 6,'16');
line(xl + 110,yl + 30,xl + 130,yl + 30);
outtextxy(xl + 92,yl + 26,'15');
line(xl + 110,yl + 50,xl + 130,yl + 50);
outtextxy(xl + 92,yl + 46,'14');
line(xl + 110,yl + 70,xl + 130,yl + 70);
outtextxy(xl + 92,yl + 66,'13');
line(xl + 110,yl + 90,xl + 130,yl + 90);
outtextxy(xl + 92,yl + 86,'12');
line(xl + 110,yl + 110,xl + 130,yl + 110);
outtextxy(xl + 92,yl + 106,'11');
line(xl + 110,yl + 130,xl + 130,yl + 130);
outtextxy(xl + 92,yl + 126,'10');
line(xl + 110,yl + 150,xl + 130,yl + 150);
outtextxy(xl + 92,yl + 146,'9');
outtextxy(xl + 28,yl + 76,'SG3525A');
setcolor(11);
rectangle(xl - 20,yl + 105,xl - 50,yl + 115);
outtextxy(xl - 42,yl + 107,'RT');
line(xl - 50,yl + 110,xl - 70,yl + 110);
line(xl - 70,yl + 110,xl - 70,yl + 120);
line(xl - 80,yl + 120,xl - 60,yl + 120);
line(xl - 20,yl + 90,xl - 100,yl + 90);
line(xl - 100,yl + 90,xl - 100,yl + 150);
line(xl - 110,yl + 150,xl - 90,yl + 150);
line(xl - 110,yl + 160,xl - 90,yl + 160);
line(xl - 100,yl + 160,xl - 100,yl + 180);
line(xl - 90,yl + 180,xl - 110,yl + 180);
outtextxy(xl - 130,yl + 152,'CT');
rectangle(xl - 20,yl + 125,xl - 50,yl + 135);
outtextxy(xl - 42,yl + 127,'RD');
line(xl - 50,yl + 130,xl - 100,yl + 130);
setcolor(15);
end;

procedure SG3524A(xl, yl : integer);
var
li : integer;
begin
setcolor(15);
rectangle(xl,yl,xl + 110,yl + 160);
line(xl,yl + 10,xl - 20,yl + 10);
outtextxy(xl + 8,yl + 6,'1');
line(xl,yl + 30,xl - 20,yl + 30);
outtextxy(xl + 8,yl + 26,'2');
line(xl,yl + 50,xl - 20,yl + 50);
outtextxy(xl + 8,yl + 46,'3');
line(xl,yl + 70,xl - 20,yl + 70);
outtextxy(xl + 8,yl + 66,'4');
line(xl,yl + 90,xl - 20,yl + 90);
outtextxy(xl + 8,yl + 86,'5');
line(xl,yl + 110,xl - 20,yl + 110);
outtextxy(xl + 8,yl + 106,'6');
line(xl,yl + 130,xl - 20,yl + 130);
outtextxy(xl + 8,yl + 126,'7');
line(xl,yl + 150,xl - 20,yl + 150);
outtextxy(xl + 8,yl + 146,'8');

line(xl + 110,yl + 10,xl + 130,yl + 10);
outtextxy(xl + 92,yl + 6,'16');
line(xl + 110,yl + 30,xl + 130,yl + 30);
outtextxy(xl + 92,yl + 26,'15');
line(xl + 110,yl + 50,xl + 130,yl + 50);
outtextxy(xl + 92,yl + 46,'14');
line(xl + 110,yl + 70,xl + 130,yl + 70);
outtextxy(xl + 92,yl + 66,'13');
line(xl + 110,yl + 90,xl + 130,yl + 90);
outtextxy(xl + 92,yl + 86,'12');
line(xl + 110,yl + 110,xl + 130,yl + 110);
outtextxy(xl + 92,yl + 106,'11');
line(xl + 110,yl + 130,xl + 130,yl + 130);
outtextxy(xl + 92,yl + 126,'10');
line(xl + 110,yl + 150,xl + 130,yl + 150);
outtextxy(xl + 92,yl + 146,'9');
outtextxy(xl + 28,yl + 76,'SG3524A');
setcolor(12);
rectangle(xl - 30,yl + 105,xl - 60,yl + 115);
outtextxy(xl - 52,yl + 107,'RT');
line(xl - 60,yl + 110,xl - 120,yl + 110);
line(xl - 120,yl + 110,xl - 120,yl + 130);
line(xl - 110,yl + 130,xl - 130,yl + 130);
line(xl - 30,yl + 110,xl - 20,yl + 110);
line(xl - 50,yl + 130,xl - 70,yl + 130);
line(xl - 70,yl + 130,xl - 70,yl + 140);
line(xl - 80,yl + 140,xl - 60,yl + 140);
line(xl - 50,yl + 130,xl - 20,yl + 130);
line(xl - 80,yl + 150,xl - 60,yl + 150);
line(xl - 70,yl + 150,xl - 70,yl + 170);
line(xl - 80,yl + 170,xl - 60,yl + 170);
outtextxy(xl - 98,yl + 141,'CT');
setcolor(15);
end;

procedure LM494CN(xl, yl : integer);
var
li : integer;
begin
setcolor(15);
rectangle(xl,yl,xl + 110,yl + 160);
line(xl,yl + 10,xl - 20,yl + 10);
outtextxy(xl + 8,yl + 6,'1');
line(xl,yl + 30,xl - 20,yl + 30);
outtextxy(xl + 8,yl + 26,'2');
line(xl,yl + 50,xl - 20,yl + 50);
outtextxy(xl + 8,yl + 46,'3');
line(xl,yl + 70,xl - 20,yl + 70);
outtextxy(xl + 8,yl + 66,'4');
line(xl,yl + 90,xl - 20,yl + 90);
outtextxy(xl + 8,yl + 86,'5');
line(xl,yl + 110,xl - 20,yl + 110);
outtextxy(xl + 8,yl + 106,'6');
line(xl,yl + 130,xl - 20,yl + 130);
outtextxy(xl + 8,yl + 126,'7');
line(xl,yl + 150,xl - 20,yl + 150);
outtextxy(xl + 8,yl + 146,'8');

line(xl + 110,yl + 10,xl + 130,yl + 10);
outtextxy(xl + 92,yl + 6,'16');
line(xl + 110,yl + 30,xl + 130,yl + 30);
outtextxy(xl + 92,yl + 26,'15');
line(xl + 110,yl + 50,xl + 130,yl + 50);
outtextxy(xl + 92,yl + 46,'14');
line(xl + 110,yl + 70,xl + 130,yl + 70);
outtextxy(xl + 92,yl + 66,'13');
line(xl + 110,yl + 90,xl + 130,yl + 90);
outtextxy(xl + 92,yl + 86,'12');
line(xl + 110,yl + 110,xl + 130,yl + 110);
outtextxy(xl + 92,yl + 106,'11');
line(xl + 110,yl + 130,xl + 130,yl + 130);
outtextxy(xl + 92,yl + 126,'10');
line(xl + 110,yl + 150,xl + 130,yl + 150);
outtextxy(xl + 92,yl + 146,'9');
outtextxy(xl + 28,yl + 76,'LM494CN');
setcolor(13);
rectangle(xl - 30,yl + 105,xl - 60,yl + 115);
outtextxy(xl - 52,yl + 107,'RT');
line(xl - 60,yl + 110,xl - 90,yl + 110);
line(xl - 30,yl + 110,xl - 20,yl + 110);
line(xl - 90,yl + 110,xl - 90,yl + 130);
line(xl - 80,yl + 130,xl - 100,yl + 130);
line(xl - 130,yl + 90,xl - 20,yl + 90);
line(xl - 130,yl + 90,xl - 130,yl + 120);
line(xl - 140,yl + 120,xl - 120,yl + 120);
line(xl - 140,yl + 130,xl - 120,yl + 130);
outtextxy(xl - 160,yl + 122,'CT');
line(xl - 130,yl + 130,xl - 130,yl + 150);
line(xl - 140,yl + 150,xl - 120,yl + 150);
setcolor(15);
end;

procedure presentahomio(xo, yo : integer);
var
oo, mm : integer;
begin
for oo := 1 to 8 do
for mm := 1 to 8 do
begin
if homio[oo][mm] = '1' then
begin
putpixel(xo + mm,yo + oo,15);
end;
end;
end;

procedure boton_menu(xm, ym, xxm, yym : integer; estado : boolean;
fon : integer; titulo : string);
var
m1, m2 : integer;
color3, color2 : byte;
begin
if estado = true then
begin
color2 := 7;
color3 := 15;
end
else
begin
color2 := 15;
color3 := 7;
end;
for m1 := 0 to 4 do
begin
setcolor(color2);
line(xm + m1,ym + m1,xxm - m1,ym + m1);
line(xm + m1,ym + m1,xm + m1,yym - m1);
setcolor(color3);
line(xxm - m1,ym + m1,xxm - m1,yym - m1);
line(xm + m1,yym - m1,xxm - m1,yym - m1);
end;
setcolor(15);
setfillpattern(fondo[1],fon);
bar(xm + 5,ym + 5,xxm - 5,yym - 5);
setfillpattern(fondo[1],0);
setcolor(14);
outtextxy(xm + 8,ym + 8,titulo);
setcolor(15);
end;

function edita_entrada(xe, ye : integer) : real;
var
tecla : char;
texto : string[15];
cont : integer;
valor : word;
begin
edita_entrada := 0.0;
setfillpattern(fondo[1],10);
bar(xe,ye,xe + 8,ye + 8);
cont := 1;
fillchar(texto,16,' ');
texto[0] := chr(15);
repeat
tecla := readkey;
if tecla = #0 then
valor := word(ord(readkey)) shl 8
else
valor := ord(upcase(tecla));

if valor in [44,46,48..57] then
begin
setfillpattern(fondo[1],1);
bar((xe - 8) + (cont * 8),ye,((xe - 8) + (cont * 8)) + 8,ye + 8);
texto[0] := chr(cont);
texto[cont] := tecla;
outtextxy((xe - 8) + (cont * 8),ye,texto[cont]);
inc(cont);
if cont > 15 then
begin
cont := 15;
end;
setfillpattern(fondo[1],10);
bar((xe - 8) + (cont * 8),ye,((xe - 8) + (cont * 8)) + 8,ye + 8);
end;
if valor = 8 then
begin
setfillpattern(fondo[1],1);
bar((xe - 8) + (cont * 8),ye,((xe - 8) + (cont * 8)) + 8,ye + 8);
dec(cont);
if cont < 1 then
begin
cont := 1;
end;
texto[0] := chr(cont);
texto[cont] := ' ';
setfillpattern(fondo[1],1);
bar((xe - 8) + (cont * 8),ye,((xe - 8) + (cont * 8)) + 8,ye + 8);
end;
until (valor = 13) or (valor = 27);
edita_entrada := stringreal(texto);

setfillpattern(fondo[1],1);
bar((xe - 8) + (cont * 8),ye,((xe - 8) + (cont * 8)) + 8,ye + 8);
end;

procedure pantalla_menu;
var
d : integer;
begin
d := 1;
repeat
setcolor(15);
line(1 + d,40 + d,(getmaxx - 8) - d,40 + d);
line(1 + d,40 + d, 1 + d, (getmaxy - 2) - d);
setcolor(7);
line(1 + d,(getmaxy - 2) - d,(getmaxx - 8) - d,(getmaxy - 2) - d);
line((getmaxx - 8) - d, 40 + d,(getmaxx - 8) - d,(getmaxy - 2) - d);
inc(d);
until d = 6;
d := 1;
repeat
setcolor(7);
line(1 + d,1 + d,(getmaxx - 8) - d,1 + d);
line(1 + d,1 + d, 1 + d, 40 - d);
setcolor(15);
line(1 + d,40 - d,(getmaxx - 8) - d,40 - d);
line((getmaxx - 8) - d,1 + d,(getmaxx - 8) - d,40 - d);
inc(d);
until d = 6;
SetFillPattern(Gray, 10);
bar(7,7,(getmaxx - 7) - 7,40 - 7);
SetFillPattern(Gray, 0);
setcolor(15);
end;

procedure initvga(s:string);
Begin
Driver := detect;
InitGraph(Driver,Mode,s);
if graphresult <> 0 then
begin
Writeln('ERROR GRAFICO : ');
Halt(1);
end;
GetFillPattern(OldPattern);
SetFillPattern(Gray, 0);
end;

procedure inicia_graficos;
begin
initvga('c: pgi');
for h := 1 to 17 do
for v := 1 to 16 do
begin
if raton[h][v] = '1' then
begin
putpixel(110 + v,120 + h,7);
end;
if raton[h][v] = '8' then
begin
putpixel(110 + v,120 + h,15);
end;
end;
ocupa := imagesize(110,120,110 + 16, 120 + 17);
activo := false;
if memavail > ocupa then
begin
getmem(cursor,ocupa);
getimage(110,120,110 + 16, 120 + 17,cursor^);
putimage(110,120,cursor^,xorput);
activo := true;
end;
initmouse(1);
pon_posicion_raton(110,120);
xr := posx_raton;
yr := posy_raton;
putimage(xr,yr,cursor^,xorput);
putimage(xr,yr,cursor^,xorput);
end;

begin
inicia_graficos;
putimage(xr,yr,cursor^,xorput);
pantalla_menu;
boton_menu(9,10,146,32,false,1,'Calculo SG3525A');
boton_menu(158,10,295,32,false,1,'Calculo SG3524A');
boton_menu(307,10,444,32,false,1,'Calculo LM494CN');
boton_menu(456,10,603,32,false,1,' SALIR ');
setcolor(133);
outtextxy(150,50,'** CALCULO DE FRECUENCIA DE SALIDA [PWM] **');
setcolor(15);
final := false;
repeat
if (xr <> posx_raton) or (yr <> posy_raton) then
begin
putimage(xr,yr,cursor^,xorput);
xr := posx_raton;
yr := posy_raton;
if xr > getmaxx - 12 then
begin
xr := getmaxx - 12;
end;
if yr > getmaxy - 2 then
begin
yr := getmaxy - 2;
end;
putimage(xr,yr,cursor^,xorput);
end;
if boton_raton = 1 then
begin
putimage(xr,yr,cursor^,xorput);
case yr of
15..29 : begin
case xr of
13..139 : begin
setfillpattern(fondo[1],0);
bar(7,56,getmaxx - 16,getmaxy - 9);
resit1 := 0.0;
resit2 := 0.0;
conden := 0.0;
conden2 := 0.0;
balor1 := 0.0;
balor1 := 0.0;
total := 0.0;
boton_menu(9,10,146,32,true,1,'Calculo SG3525A');
SG3525A(300,60);
boton_menu(140,260,440,284,true,1,'ENTRE VALOR RT :');
boton_menu(140,288,440,312,true,1,'ENTRE VALOR RD :');
boton_menu(140,316,440,340,true,1,'ENTRE VALOR CT :');
setcolor(14);
presentahomio(416,268);
presentahomio(416,296);
outtextxy(464 - 60,324,'nF');
outtextxy(110,345,'Resistencias en y Condensador en Nano Faradio');
presentahomio(231,343);
outtextxy(110,355,'1nF = 0.001uF / 10nF = 0.01uF / 100nF = 0.1uF');
outtextxy(110,365,'1 = 0.001K / 10 = 0.01K / 100 = 0.1K ');
presentahomio(116,363);
presentahomio(197,363);
presentahomio(248,363);
presentahomio(326,363);
presentahomio(382,363);
presentahomio(454,363);
setcolor(10);
outtextxy(110,420,'RESULTADO = Khz');
setcolor(15);
resit1 := edita_entrada(274,268);
setfillpattern(fondo[1],1);
bar(274,268,364 + 8,268 + 8);
setcolor(14);
outtextxy(255,268,realstring2(resit1));
setcolor(15);
resit2 := edita_entrada(274,297);
setfillpattern(fondo[1],1);
bar(274,297,364 + 8,297 + 8);
setcolor(14);
outtextxy(255,297,realstring2(resit2));
setcolor(15);
conden := edita_entrada(274,324);
conden2 := conden * 0.000000001;
setfillpattern(fondo[1],1);
bar(274,324,364 + 8,324 + 8);
setcolor(14);
outtextxy(255,324,realstring2(conden));
setcolor(15);
balor1 := (0.7 * resit1) + (resit2 * 3);
balor2 := balor1 * conden2;
total := 1/balor2;
outtextxy(206,420,realstring2(total/1000));
frecuencia2(total);
boton_menu(9,10,146,32,false,1,'Calculo SG3525A');
end;
162..288 : begin
setfillpattern(fondo[1],0);
bar(7,56,getmaxx - 16,getmaxy - 9);
resit1 := 0.0;
conden := 0.0;
balor1 := 0.0;
total := 0.0;
boton_menu(158,10,295,32,true,1,'Calculo SG3524A');
SG3524A(300,60);
boton_menu(140,260,440,284,true,1,'ENTRE VALOR RT :');
boton_menu(140,288,440,312,true,1,'ENTRE VALOR CT :');
setcolor(14);
outtextxy(408,268,'K');
presentahomio(416,268);
outtextxy(464 - 50,296,'uF');
outtextxy(110,345,'Resistencias en K y Condensador en uF');
outtextxy(110,355,'1nF = 0.001uF / 10nF = 0.01uF / 100nF = 0.1uF');

setcolor(10);
outtextxy(110,420,'RESULTADO = Khz');
setcolor(15);
resit1 := edita_entrada(274,268);
setfillpattern(fondo[1],1);
bar(274,268,364 + 8,268 + 8);
setcolor(14);
outtextxy(255,268,realstring2(resit1));
setcolor(15);
conden := edita_entrada(274,297);
setfillpattern(fondo[1],1);
bar(274,297,364 + 8,297 + 8);
setcolor(14);
outtextxy(255,297,realstring2(conden));
setcolor(15);
balor1 := (resit1 * conden);
total := (1.8/balor1);
outtextxy(206,420,realstring2(total));
frecuencia2(total);
boton_menu(158,10,295,32,false,1,'Calculo SG3524A');
end;
312..439 : begin
setfillpattern(fondo[1],0);
bar(7,56,getmaxx - 16,getmaxy - 9);
resit1 := 0.0;
conden := 0.0;
balor1 := 0.0;
total := 0.0;
boton_menu(307,10,444,32,true,1,'Calculo LM494CN');
LM494CN(300,60);
boton_menu(140,260,440,284,true,1,'ENTRE VALOR RT :');
boton_menu(140,288,440,312,true,1,'ENTRE VALOR CT :');
setcolor(14);
outtextxy(408,268,'K');
presentahomio(416,268);
outtextxy(464 - 50,296,'uF');
outtextxy(110,345,'Resistencias en K y Condensador en uF');
outtextxy(110,355,'1nF = 0.001uF / 10nF = 0.01uF / 100nF = 0.1uF');
presentahomio(245,344);
setcolor(10);
outtextxy(110,420,'RESULTADO = Khz');
setcolor(15);
resit1 := edita_entrada(274,268);
setfillpattern(fondo[1],1);
bar(274,268,364 + 8,268 + 8);
setcolor(14);
outtextxy(255,268,realstring2(resit1));
setcolor(15);
conden := edita_entrada(274,297);
setfillpattern(fondo[1],1);
bar(274,297,364 + 8,297 + 8);
setcolor(14);
outtextxy(255,297,realstring2(conden));
setcolor(15);
balor1 := ((resit1 * 2) * conden);
total := (1/balor1);
outtextxy(206,420,realstring2(total));
frecuencia2(total);
boton_menu(307,10,444,32,false,1,'Calculo LM494CN');
end;
459..598 : begin
boton_menu(456,10,603,32,true,1,' SALIR ');
delay(300);
final := true;
boton_menu(456,10,603,32,false,1,' SALIR ');
end;
end;
end;
end;
putimage(xr,yr,cursor^,xorput);
end;
if keypressed then
pulsada := readkey;
if pulsada <> #27 then
begin
pulsada := #0;
end;
until (final = true) or (pulsada = #27);
closegraph;
end.

    Pregunta:  65309 - ¿COMO HACER EL METODO DE BISECCION EN TURBO PASCAL?
Autor:  Joel Jarquin
Necesito urgentemente que alguien me de un ejemplo de como realizar un programa cualquiera con una funcion cualquiera resuelta con el Metodo de Biseccion en Turbo Pascal.
Muchas Gracias.
  Respuesta:  ramon
program biseccion;

uses
crt;
var
p, a, b, c, n : real;
cc, ca, cb, resultado, resul : real;
error, cont, l : integer;
sal : boolean;

function calculo(a : real) : real;
begin
calculo := cos(a) / a;
end;

function dato(x, y : integer) : integer;
var
tec : char;
pos : integer;
tex : string[5];
valo : integer;
begin
dato := 0;
fillchar(tex,6,' ');
tex[0] := chr(5);
pos := 1;
gotoxy(x,y);
repeat
tec := readkey;
if tec in[#48..#57] then
begin
tex[pos] := tec;
tex[0] := chr(pos);
gotoxy(x + pos,y);write(tex[pos]);
pos := pos + 1;
if pos > 5 then
pos := 5;
end;
if tec = #8 then
begin
pos := pos - 1;
if pos < 1 then
pos := 1;
tex[pos] := ' ';
tex[0] := chr(pos);
gotoxy(x + pos,y);write(tex[pos]);
end;
until (tec = #13) or (tec = #27);
if tec = #27 then
sal := true;
if tec = #13 then
begin
val(tex,valo,error);
dato := valo;
end;
end;

procedure entrada_datos;
begin
gotoxy(10,1);write('<<< Programa De biseccion >>>');
gotoxy(10,3);write('*** Entre los Datos ***');
gotoxy(10,4);write('Valor de A = ',' ','Primer Valor');
gotoxy(10,5);write('Valor de B = ',' ','Segundo Valor');
gotoxy(10,6);write('Valor de p = ',' ','Veces de Intentos');
a := dato(22,4);
if sal = false then
b := dato(22,5);
if sal = false then
p := dato(22,6);
end;

procedure calculamos;
begin
clrscr;
entrada_datos;
c := (a + b) / 2;
cc := calculo(c);
cont := 0;
repeat
n := b - c;
if (abs(n) < p) or (cc = 0.0) then
resultado := c
else
begin
cc := calculo(c);
cb := calculo(b);
resul := cb * cc;
if (resul < 0.0) then
a := c
else
b := c
end;
cont := cont + 1;
gotoxy(10,8);write(' Intentos : ',cont,' Salio : ',c);
c := (a + b) / 2;
until (abs(n) < p) or (cc = 0.0);
gotoxy(10,10);write(' El Resultado Es : ',resultado : 8:8);
end;

begin
clrscr;
calculamos;
readln;
end.

    Pregunta:  65393 - ERROR EN COMPILACION EN PASCAL
Autor:  Laura Gutierrez
program tarea1;
var
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, #, *: char;
oracion: char;

tengo ese fragmento y me aparece tarea1.pas (3,4) fatal: syntax error expected "identifier" but "ordinal const" found.
No sé que error estoy cometiendo y si el (3,4) es la linea 3, lugar 4.
  Respuesta:  ramon
En pascal no admite los números como variable ni los signos
tales como # y * puesto que están designados en pascal para
otras operaciones pon delante de los números una letra y te
funcionara bien .
Suerte.

|<  <<  11 12 13 14 15 16 17 18 19 20 21  >>  >|