dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Nedaudz par texta failiem...

 
dev.gamez.lv Forum Index -> Iesācējiem
View previous topic :: View next topic  
Author Message
Oma



Joined: 20 Mar 2006
Posts: 39

PostPosted: Fri Sep 15, 2006 6:10 pm    Post subject: Nedaudz par texta failiem...

Taatad... Man ir texta fails un no taa man vajag izdabuut aaraa kaadu simbolu piem. burtu E. Domaaju ka tas vareetu izskatiities apmeeram kautkaa shaadi.
Code:

Procedure Iznjemtsimbolu(var X:Char);
var F:Text; Y:Char;
Begin
Assign(F, 'Fails.txt');
Reset(F);
repeat
Read(F,Y);
if (Y=X) then
begin
//Kautko te izdara...
end;
until Eof(f);
Close(F);
end;

Nu un es nekaadiigi nevaru izshtukot kaa var aizvietot vai izdzeest failaa to Charu kursh ir vienaads ar X;
_________________


Back to top
View user's profile
Oma



Joined: 20 Mar 2006
Posts: 39

PostPosted: Fri Sep 15, 2006 6:18 pm    Post subject:

AA varbuut varat man pateikt arii kapeec ierakstot kaadu single, double,vai float tipa mainiigo texta failaa tas izskataas kautkaa shitaa jo ciigi 6.428969570368406-e000 vai to -e var kautkaa noveerst jau ierakstot to failaa jo sho funkciju man vajag tikai tapeec lai peec tam iznjemtu aaraa to -e...
_________________


Back to top
View user's profile
elvman
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 09 Apr 2003
Posts: 1278
Location: Kuldiga

PostPosted: Fri Sep 15, 2006 8:25 pm    Post subject:

Tev vajag reset(F,1),kur 1 ir bloka lielums,kuru lasiisi.1 taapeec,ka char ir viens baits.
Peec tam BlockRead(F,Y,1);//mainiigajaa Y tiek ielasiits 1 baits

P.S. Iespeejams,ka nedaudz kljuudos ar pareizrakstiibu
_________________
long time; /* know C */
Back to top
View user's profile Visit poster's website
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Fri Sep 15, 2006 8:35 pm    Post subject:

elvman: tieši otrādi.
Ja lieto Reset(F), tad F ir vispārīgs fails un to jālasa ar blockread norādot bloka izmērus.
Taču, ja lieto Reset(F,1); tad tiek pateikts, ka F sastāvēs no 1 baita blokiem un Read mācēs to nolasīt, tb tieši tā kā piemērā - Read(F, Y), kur Y ir char.
Tas, protams, der File tipa failiem, nevis Text, kuriem Resetā jānorāda tikai faila mainīgais. Tiem nekāds izmērs nav jānorāda.

Oma: a kāpēc tev tā floata zinātniskā forma traucē (tas "-e" kautkas).
Ja tu pats to failu Raksti, tad to var rakstīt šādi: Write(F, floats:3:4), kur tie 3 un 4 nozīmē ciparu skaitu, kurus ierakstīt (palasi helpā ko precīzi katrs nozīmē).
Back to top
View user's profile Send e-mail
elvman
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 09 Apr 2003
Posts: 1278
Location: Kuldiga

PostPosted: Fri Sep 15, 2006 8:38 pm    Post subject:

Nope.Ar Reset(F,1); mes noradam bloka izmeeru,bet ar BlockRead(F,Y,1); mes pasakam cik daudz taadus blokus izlasiit (shajaa gadiijumaa 1 vienbaitiigu bloku).
_________________
long time; /* know C */
Back to top
View user's profile Visit poster's website
elvman
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 09 Apr 2003
Posts: 1278
Location: Kuldiga

PostPosted: Fri Sep 15, 2006 8:40 pm    Post subject:

Ja netici,tad tiko atradu dokumentaacijaa:
Quote:
Delphi syntax:

procedure BlockRead(var F: File; var Buf; Count: Integer [; var AmtTransferred: Integer]);

Description

F is an untyped file variable, Buf is any variable, Count is an expression of type Integer, and AmtTransferred is an optional variable of type Integer.

BlockRead reads Count or fewer records from the file F into memory, starting at the first byte occupied by Buf. The actual number of complete records read (less than or equal to Count) is returned in AmtTransferred.

The entire transferred block occupies at most Count * RecSize bytes. RecSize is the record size specified when the file was opened (or 128 if the record size was not specified).

If the entire block was transferred, AmtTransferred is equal to Count.

If AmtTransferred is less than Count, ReadBlock reached the end of the file before the transfer was complete. If the file's record size is greater than 1, AmtTransferred returns the number of complete records read.

If AmtTransferred isn't specified, an I/O error occurs if the number of records read isn't equal to Count. If the $I+ compiler directive is in effect, errors raise an EInOutError exception.

_________________
long time; /* know C */
Back to top
View user's profile Visit poster's website
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Fri Sep 15, 2006 9:01 pm    Post subject:

ok, ticu ticu. 100 gadus neesmu vairs ar paskāli/delphi darbojis, tāpēc jau viss piemirsies. Šoreiz tev taisnība, ne man ;)

Katrā ziņā, viņam tur ir F: Text, tāpēc nekādu Reset(F,1) nevajag, cik atceros. Un arī Blockread nevajag. Ar prastu Read var iztikt, ja vajag charakterus no text faila nolasīt.
Back to top
View user's profile Send e-mail
Oma



Joined: 20 Mar 2006
Posts: 39

PostPosted: Sat Sep 16, 2006 9:29 pm    Post subject:

Iisteniibaa manlieks ka ja tev tas faila mainiigais ir kaa Text tad vinjsh to blockread nemaz nenjeema pretii bet nu ja ir taadz veids ka ieraksta tikai noteiktu skaitu ciparus aiz komata ta viss kartibaa man tas -e trauceeja tapeec ka ja es to failu meegjinaaju nolasiit un taas float veertiibas pieshkjirt kaadam mainiigajam tad leca errors "Invalid numeric input" vai kautkas tam liidziigs... AA atljaushos pajataat kaadaa library atrodas taa float:3:4 funkcija vai kaada tur un kaa vinju buutu visvieglaaak atrast helpaa?
_________________


Back to top
View user's profile
Oma



Joined: 20 Mar 2006
Posts: 39

PostPosted: Sat Sep 16, 2006 9:32 pm    Post subject:

Elvman bet man jau nebija jautaajums kaa nolasiit bet kaa izdzeest 1 charu no faila un taa vietaa ielikt citu...
_________________


Back to top
View user's profile
Vecais_Dumais_Laacis
Guru
Guru


Joined: 29 Jan 2004
Posts: 800

PostPosted: Sun Sep 17, 2006 9:41 am    Post subject:

nu ja tev vajaga repleisot tad 2i varianti
1) nolasi failu, repleiso atminjaa charu un paarraksti
2) atver failu rw modee (nav ne jausmas kaa to delfos dariit - moka ar winapi?), aizej uz attieciigo vietu (fseek?) un paarraksti charu pa virsu.
_________________
...un ja bites buutu laachi...
Back to top
View user's profile
Display posts from previous:   
dev.gamez.lv Forum Index -> Iesācējiem All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group