[ Passwd @ 19.05.2005. 15:11 ] @
U ovom slucaju svaki novi "korisnik" koji se upise izbrise prvog korisnika, sto treba nadopisat il izmjenit kako bi se spremali svi korisnici koji se zapisu a ne samo zadnji!!

Upisao sam i ovo al opet isto??

while not eof(x) do read(x,b)..


Code:

program korisnici;
uses crt;
type datoteka=record
                   ime:string[20];
                   telefon:string[20];
              end;

     fajl=file of datoteka;

var x:fajl;
    b:datoteka;
begin
clrscr;
assign(x,'korisnici.txt');
reset(x);
writeln('Upisite svoje ime:');
readln(b.ime);
writeln('Upisite broj vaseg telefona:');
readln(b.telefon);
while not eof(x) do read(x,b);
write(x,b);
close(x);
readln;
end.
[ Srki_82 @ 19.05.2005. 16:39 ] @
Probaj umesto Reset(x) da stavis Append(x) (ne treba nista da citas iz fajla jer je pokazivas na kraju cim se fajl otvori)
[ Bojan Kopanja @ 19.05.2005. 21:06 ] @
Yup, to je 1000000% greska, stavi lepo append i uzivaj u dopisivanju imena u fajl ...
[ Passwd @ 20.05.2005. 11:59 ] @
Kad zamjenim
reset(x) sa append(x) javlja mi error 63!!
[ Srki_82 @ 20.05.2005. 17:33 ] @
Probaj da X postavis samo na file, da fajl otvoris sa Reset(X, 1), zatim odes na kraj fajla Seek(X, FileSize(X)) i na kraj upises podatak BlockWrite(X, B, SizeOf(B)). Probao sam i radi 100%

BTW hajde pogedaj u help-u sta je greska 63?
[ Passwd @ 20.05.2005. 19:47 ] @
Evo ga, sljaka!! :)

Hvala Srki_82, a ti Strong se prestani smijati!!
[ Passwd @ 20.05.2005. 20:05 ] @
A al evo problema, kako sada ocitat tko je sve upisan-ovako nece ici (goto 2):

Code:

program korisnici;
uses crt;
label 0,1,2;
type datoteka=record
                   ime:string[20];
                   telefon:string[20];
              end;

     fajl=file of datoteka;

var x:fajl;
    b:datoteka;
    izbor:char;

begin
0:begin
 clrscr;
 writeln('1-Upis novog korisnika');
 write('2-Pregled upisanih');
 izbor:=readkey;
 if izbor='1' then goto 1;
 if izbor='2' then goto 2;
 end; 

1:begin
 clrscr;
 assign(x,'korisnici.txt');
 rewrite(x);
 seek(x,filesize(x));
 writeln('Upisite svoje ime:');
 readln(b.ime);
 writeln('Upisite broj vaseg telefona:');
 readln(b.telefon);
 write(x,b);
 close(x);
 readln;
 goto 0;
end;

2:begin
  clrscr;
  assign(x,b.ime);
  reset(x);
  write(x,b);
  readln;
  close(x);
  end;

readln;
end.
[ Bojan Kopanja @ 20.05.2005. 23:23 ] @
Pa ocitavanje radi u repeat until petlji!

Znaci ono sto citas stavi lepo u nesto ovako:

Code:
repeat
//kod za citanje iz fajla
until eof(imefajla);


I sada ce ti biti iscitani svi redovi iz fajla.

BTW nije Strong, nego Strog i ne smejem se ja toliko .

Uh, sad videh da si koristio write za citanje . Ajde mi sad reci koliko je to logican potez .

Znaci koristi readln(x,b);
[ Passwd @ 21.05.2005. 09:53 ] @
@Streonger!!

Pozdrav!!
[ Bojan Kopanja @ 21.05.2005. 15:00 ] @
WTF je to znacilo?
[ Passwd @ 21.05.2005. 16:08 ] @
Ma nista!!Mijenjam ti nadimak..!!

Poz!!
[ Bojan Kopanja @ 22.05.2005. 09:28 ] @
Mani se ti toga, nego reci treba li ti jos nesto ako ovo nije pomoglo, a ako je sve OK da ne trosimo vise vreme .
[ Passwd @ 22.05.2005. 11:11 ] @
Ovo gore je u redu, samo imam jedan glup problem.
Ovako, zelim sve kodove koje imam stavit u jedan velik program.
Problem je u tome sto nisam radio u procedurama vec sa goto!!
U pocetku je bilo dobro, al kad je kod postao malo veci vise ne znam gdje sta ide i tko sta poziva!!I ono s atomskim brojem je glupo (mogao sam stavit to u neki string pa njega ponavljat...al dobro)
Ne da mi se sad sve prebacivat u procedure, a evo i koda (to nije ni pola koda):



Code:

program jurasoft;
uses crt;
label 0,1,2,3,4,matematika,kemija;
type datoteka=record
                   ime:string[20];
                   telefon:string[20];
              end;

     fajl=file of datoteka;
var x:fajl;
    el:string;
    b:datoteka;
    br1,br2,br3,br4:integer;
    izbor,izbor1,izbor2,izbor3,izbor4,izbor_elementa,izbor_predmeta,izbor_povratak,izbor_operacije:char;

begin
clrscr;

0:
begin
clrscr;
gotoxy(5,5);
writeln('Made by a JURASOFT!!');
writeln;
writeln;
gotoxy(5,7);
writeln('Press enter to get in!!');
readln;
clrscr;
writeln('GLAVNI IZBORNIK:');
writeln;
writeln('1-pokreni JuraSoft');
writeln('2-izlaz');
izbor1:=readkey;
if izbor1='1' then goto 1;
if izbor1='2' then exit;
end;

1:
begin
clrscr;
gotoxy(5,10);
writeln('Welcome to JuraSoft!!');
writeln;
writeln('1-zabava');
writeln('2-skola');
writeln('3-upis u knjigu gostiju');
izbor2:=readkey;
if izbor2='1' then goto 2;
if izbor2='2' then goto 3;
if izbor2='3' then goto 4;
readln;
goto 0;
end;

2:
begin
clrscr;
writeln('Under reconstrucston!!');
writeln;
writeln('1-povratak na glavni izbornik');
izbor3:=readkey;
if izbor3='1' then goto 0;
readln;
goto 0;
end;


3:
begin
clrscr;
writeln('Dobrodsli u dio programa namjenjen za ucenje!!');
writeln('1-matematika');
writeln('2-kemija');
writeln('3-povratak na glavni izbornik');
izbor_predmeta:=readkey;
if izbor_predmeta='1' then goto matematika;
if izbor_predmeta='2' then goto kemija;
if izbor_predmeta='3' then goto 0;
readln;
goto 0;
end;

matematika:
begin
clrscr;
writeln('Matematika-uzivajte');
writeln;
writeln;
writeln;
writeln;
writeln('Odaberite:');
writeln;
writeln('1-digitron (dva broja)');
writeln('2-povrsina i opseg pravokutnog trokuta');
writeln('3-povrsina i opseg kvadrata');
writeln('4-opseg paralelograma');
writeln('5-opseg raznostranicnog trokuta');
writeln('6-povrsina i opseg pravokutnika');
writeln('7-opseg romba');
writeln('8-opseg jednakostranicnog trokuta');
writeln('9-opseg trapeza');
writeln('0-opseg jednakokracnog trokuta');
writeln;
writeln('c-povratak na glavni izbornik');
izbor_operacije:=readkey;
writeln;
writeln;
case izbor_operacije of
'1' :         begin
              clrscr;
              writeln('D I G I T R O N');
              writeln('Upisite dva broja:');
              readln(br1,br2);
              writeln('Rezultat zbrajanja je ',br1+br2);
              writeln('Rezultat oduzimanja je ',br1-br2);
              writeln('Rezultat mnozenja je ',br1*br2);
              writeln('Rezultat dijeljenja je ',br1 div br2);
              readln;
              goto matematika;
              end;

'2' :        begin
              clrscr;
              writeln('P R A V O K U T N I   T R O K U T');
              writeln('Upisite stranicu a,b,c');
              readln(br1,br2,br3);
              writeln('Povrsina trokuta je ',(br1*br2) div 2);
              writeln('Opseg trokuta je ',br1+br2+br3);
              readln;
              goto matematika;
              end;

'3':          begin
              clrscr;
              writeln('K V A D R A T');
              writeln('Upisite stranicu kvadrata [a]');
              readln(br1);
              writeln('Povrsina kvadrata je ',br1*br1);
              writeln('Opseg kvadrata je ',4*br1);
              readln;
              goto matematika;
              end;

'4':          begin
              clrscr;
              writeln('P A R A L E L O G R A M');
              writeln('Upisi stranice paralelograma [a] i [b]');
              readln(br1,br2);
              writeln('Opseg paralelograma je ',2*(br1+br2));
              readln;
              goto matematika;
              end;

'5':          begin
              clrscr;
              writeln('R A Z N O S T R A N I C A N  T R O K U T');
              writeln('Upisi stranice raznostranicnog trokuta [a] [b] [c]');
              readln(br1,br2,br3);
              writeln('Opseg raznostranicnog trokuta je ',br1+br2+br3);
              readln;
              goto matematika;
              end;

'6' :         begin
              clrscr;
              writeln('P R A V O K U T N I K');
              writeln('Upisi stranice pravokutnika [a] [b]');
              readln(br1,br2);
              writeln('Povrsina pravokutnika je ',br1*br2);
              writeln('Opseg pravokutnika je ',2*(br1+br2));
              readln;
              goto matematika;
              end;

'7' :         begin
              clrscr;
              writeln('R O M B');
              writeln('Upisite stranicu romba');
              readln(br1);
              writeln('Opseg romba je ',4*br1);
              readln;
              goto matematika;
              end;

'8' :         begin
              clrscr;
              writeln('J E D N A K O S T R A N I C A N  T R O K U T');
              writeln('Upisite stranicu jednakostranicnog trokuta');
              readln(br1);
              writeln('Opseg jedankostranicnog trokuta je ',br1+br1+br1);
              readln;
              goto matematika;
              end;

'9' :         begin
              clrscr;
              writeln('T R A P E Z');
              writeln('Upisite stranice trapeza [a] [b] [c] [d]');
              readln(br1,br2,br3,br4);
              writeln('Opseg trapeza je ',br1+br2+br3+br4);
              readln;
              goto matematika;
              end;

'0':           begin
               clrscr;
               writeln('J E D N A K O K R A C A N  T R O K U T');
               writeln('Upisite stranice jednakokracnog trokuta [a] [b]');
               readln(br1,br2);
               writeln('Opseg jednakokracnog trokuta je ',br1+br2+br2);
               readln;
               goto matematika;
               end;

'c' : goto 0;
end;
readln;
goto 0;
end;

kemija:
  begin
  clrscr;
  writeln('Kemija-uzivajte!');
  writeln;
  writeln;
  writeln;
  writeln('1-pokazuje atomski broj svakog elementa');
  writeln;
  writeln('2-povratak na glavni izbornik');
  izbor_elementa:=readkey;
  case izbor_elementa of
  '1':begin
      clrscr;
      writeln('Upisite simbol elementa [malim slovima]');
      readln(el);
      clrscr;
      if el='h' then writeln('Atomski broj tog elementa je 1,008 ');
      if el='li' then writeln('Atomski broj tog elementa je 6,941 ');
      if el='na' then writeln('Atomski broj tog elementa je 22,99 ');
      if el='k' then writeln('Atomski broj tog elementa je 39,10 ');
      if el='rb' then writeln('Atomski broj tog elementa je  85,47');
      if el='cs' then writeln('Atomski broj tog elementa je 132,9 ');
      if el='fr' then writeln('Atomski broj tog elementa je  223');
      if el='be' then writeln('Atomski broj tog elementa je  9,012');
      if el='mg' then writeln('Atomski broj tog elementa je  24,31');
      if el='ca' then writeln('Atomski broj tog elementa je  40,08');
      if el='sr' then writeln('Atomski broj tog elementa je  87,62');
      if el='ba' then writeln('Atomski broj tog elementa je  137,3');
      if el='ra' then writeln('Atomski broj tog elementa je  226');
      if el='sc' then writeln('Atomski broj tog elementa je  44,86');
      if el='y' then writeln('Atomski broj tog elementa je  88,91');
      if el='lu' then writeln('Atomski broj tog elementa je  174,97');
      if el='lr' then writeln('Atomski broj tog elementa je  -');
      if el='ti' then writeln('Atomski broj tog elementa je  47,90');
      if el='zr' then writeln('Atomski broj tog elementa je  91,22');
      if el='hf' then writeln('Atomski broj tog elementa je  178,5');
      if el='unq' then writeln('Atomski broj tog elementa je  -');
      if el='v' then writeln('Atomski broj tog elementa je  50,94');
      if el='nb' then writeln('Atomski broj tog elementa je  92,91');
      if el='ta' then writeln('Atomski broj tog elementa je  180,9');
      if el='unp' then writeln('Atomski broj tog elementa je  -');
      if el='cr' then writeln('Atomski broj tog elementa je  52,00');
      if el='mo' then writeln('Atomski broj tog elementa je  95,94');
      if el='w' then writeln('Atomski broj tog elementa je  183,9');
      if el='unh' then writeln('Atomski broj tog elementa je  -');
      if el='mn' then writeln('Atomski broj tog elementa je  54,94');
      if el='tc' then writeln('Atomski broj tog elementa je  97');
      if el='re' then writeln('Atomski broj tog elementa je  186,2');
      if el='uns' then writeln('Atomski broj tog elementa je  -');
      if el='fe' then writeln('Atomski broj tog elementa je  55,85');
      if el='ru' then writeln('Atomski broj tog elementa je  101,1');
      if el='os' then writeln('Atomski broj tog elementa je  190,2');
      if el='uno' then writeln('Atomski broj tog elementa je  -');
      if el='co' then writeln('Atomski broj tog elementa je  58,93');
      if el='rh' then writeln('Atomski broj tog elementa je  102,9');
      if el='ir' then writeln('Atomski broj tog elementa je  192,2');
      if el='unp' then writeln('Atomski broj tog elementa je  -');
      if el='ni' then writeln('Atomski broj tog elementa je  58,70');
      if el='pd' then writeln('Atomski broj tog elementa je  106,4');
      if el='pt' then writeln('Atomski broj tog elementa je  195,1');
      if el='cu' then writeln('Atomski broj tog elementa je  63,55');
      if el='ag' then writeln('Atomski broj tog elementa je  107,9');
      if el='au' then writeln('Atomski broj tog elementa je  197,0');
      if el='zn' then writeln('Atomski broj tog elementa je  65,38');
      if el='cd' then writeln('Atomski broj tog elementa je  112,4');
      if el='hg' then writeln('Atomski broj tog elementa je  200,6');
      if el='b' then writeln('Atomski broj tog elementa je  10,81');
      if el='al' then writeln('Atomski broj tog elementa je  26,98');
      if el='ga' then writeln('Atomski broj tog elementa je  69,72');
      if el='in' then writeln('Atomski broj tog elementa je  111,4');
      if el='tl' then writeln('Atomski broj tog elementa je  204,4');
      if el='c' then writeln('Atomski broj tog elementa je  12,01');
      if el='si' then writeln('Atomski broj tog elementa je  28,09');
      if el='ge' then writeln('Atomski broj tog elementa je  72,59');
      if el='sn' then writeln('Atomski broj tog elementa je  118,7');
      if el='pb' then writeln('Atomski broj tog elementa je  207,2');
      if el='n' then writeln('Atomski broj tog elementa je  14,01');
      if el='p' then writeln('Atomski broj tog elementa je  30,97');
      if el='as' then writeln('Atomski broj tog elementa je  74,92');
      if el='sb' then writeln('Atomski broj tog elementa je  121,8');
      if el='bi' then writeln('Atomski broj tog elementa je  209,0');
      if el='o' then writeln('Atomski broj tog elementa je  16');
      if el='s' then writeln('Atomski broj tog elementa je  32,06');
      if el='se' then writeln('Atomski broj tog elementa je  78,96');
      if el='te' then writeln('Atomski broj tog elementa je  127,6');
      if el='po' then writeln('Atomski broj tog elementa je  209');
      if el='f' then writeln('Atomski broj tog elementa je  19,00');
      if el='cl' then writeln('Atomski broj tog elementa je  35,45');
      if el='br' then writeln('Atomski broj tog elementa je  79,90');
      if el='i' then writeln('Atomski broj tog elementa je  126,9');
      if el='at' then writeln('Atomski broj tog elementa je  210');
      if el='he' then writeln('Atomski broj tog elementa je  4,003');
      if el='ne' then writeln('Atomski broj tog elementa je  20,18');
      if el='ar' then writeln('Atomski broj tog elementa je  39,95');
      if el='kr' then writeln('Atomski broj tog elementa je  83,80');
      if el='xe' then writeln('Atomski broj tog elementa je  131,3');
      if el='rn' then writeln('Atomski broj tog elementa je  222');
      readln;
      goto 0;
      end;
      '2':goto 0;


end;
readln;
goto 0;
end;

4:
begin
 clrscr;
 assign(x,'korisnici.txt');
 rewrite(x);
 seek(x,filesize(x));
 writeln('Upisite svoje ime:');
 readln(b.ime);
 writeln('Upisite broj vaseg telefona:');
 readln(b.telefon);
 write(x,b);
 close(x);
 readln;
 clrscr;
 write('1-povratak na glavni izbornik');
 izbor4:=readkey;
 if izbor4='1' then goto 0;
 readln;
 end;

end.
[ Passwd @ 22.05.2005. 11:30 ] @
Evo jos nesto sto me muci (kad vec zelis/te pomoc)!!
Naime, radim na jednoj "simulaciji" sudara dva aviona i ne znam kako da napravim nesto ovako!!

Evo banalni primjer:

Code:

program gdfjdgjfd;
uses crt;
var a:integer;
begin
clrscr;
for a:=1 to 40 do
begin
write(copy('*',1,a));
delay(100);
end;
readln;
end.


Znaci, kako napravit da se zvijezdice brisu iza sebe kako idu naprijed!(Tako da izgleda kao da se krece)!!
[ Bojan Kopanja @ 22.05.2005. 17:48 ] @
E, pazi kad mi ne pada na pamet da pratim sta se desava u ovom ogromnom kodu! Upamti jedno za uvek! NIKADA ne koristi goto, ponavljam NIKADA!!! Kad god ga budes koristio upasces u ovakve probleme, vec sve resavaj procedurama i repeat until i sl. petljama.

A sto se tice drugog pitanja evo ti primer koji sam napisao na brzinu, nije nesto, ali radi ono sto bi tebi trebalo:

Code:
program progress;
uses crt;
var i,j:integer;
begin
  clrscr;
  for i:= 1 to 50 do
  begin
      for j:= 1 to i do write('.');
      write('-');
      delay(4000);
      write(char(8));
      write('\');
      delay(4000);
      write(char(8));
      write('|');
      delay(4000);
      write(char(8));
      write('/');
      delay(4000);
      write(char(13));
  end;
  writeln(char(13)+char(10),'100% DONE!');
  readln;
end.


Sta ces, Linux uticaj . Moglo je ovo i jednostavnije da se napise, ali ovo mi je bilo onako, skoro pa vec formirano u glavi kada sam poceo, pa sam ga tako i napisao .

Eto, uzivaj!
[ Passwd @ 22.05.2005. 20:51 ] @
A pazi ovo:

Code:

program progress;
uses crt;
var i,j:integer;
begin
  clrscr;
  for i:= 1 to 200 do
  begin
      for j:= 1 to i do write('.');
      write('-');
      delay(50);
      write('\');
      delay(50);
      write('|');
      delay(50);
      write('/');
      delay(50);
      
  end;
  readln;
end.


Dal te podsjeca ovo na livadu na kojoj raste trava!!
Imas u attachu .exe ako ti se neda da kompajliras!!hahaha

Moram prec na ljajnuxy da vidimo taj open source!!
[ Bojan Kopanja @ 22.05.2005. 23:17 ] @
Ne, to mi lici na onaj moj program iz kog si izbrisao char za vracanje na pocetak reda ... Mada 'ajde, neka ti bude, lici na travu ( samo izbaci onda jos i "-" da bude bas pravi zbunic ).
[ Nemanja Avramović @ 22.05.2005. 23:39 ] @
nesto retka owa trava
a inace je dobra fora... lepo izgleda!
[ Passwd @ 23.05.2005. 09:10 ] @
Sve me vise podsjeca na satelitsku snimku zemlje!!
Da umrem od smjeha!