AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

fscanf in Delphi?

Ein Thema von c113plpbr · begonnen am 13. Jul 2005 · letzter Beitrag vom 14. Jul 2005
Antwort Antwort
Benutzerbild von c113plpbr
c113plpbr

Registriert seit: 18. Nov 2003
Ort: localhost
674 Beiträge
 
Delphi 2005 Professional
 
#1

fscanf in Delphi?

  Alt 13. Jul 2005, 17:34
Hi DP'ler,

ich bin grad am übersetzen eines C-Quellcodes, und bin an fscanf hängengeblieben. Die Frage die ich mir stelle ist, ob es etwas ähnliches auch in Delphi gibt? Also das Einlesen von formatierten (mit tab-getrennten) daten (aus einer Datei/Filestream)?

Oder als alternative, gibt es eine art "umkehrfunktion" von Format?

ciao & thx, Philipp
Philipp
There is never enough time to do all the nothing you want.
*HABENWILL*
  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#2

Re: fscanf in Delphi?

  Alt 13. Jul 2005, 17:51
tab ist docch #13, oder?

Delphi-Quellcode:
function readfilebytabs(filename:string):TStrings;
var f:file of widestring; s:string;
begin
result:=Tstringlist.create;
assignfile(f,filename);
reset(f)
while not eof(f) do
 begin
  read(f,s);
  result.deliminator:=#13;
  result.delimitedtext:=s;
 end;
closefile(f);
end;
ich weiss, dass das weder elegant noch performant ist, aber es sollte funktionieren.

edit: das closefile nicht vergessen...
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
Benutzerbild von c113plpbr
c113plpbr

Registriert seit: 18. Nov 2003
Ort: localhost
674 Beiträge
 
Delphi 2005 Professional
 
#3

Re: fscanf in Delphi?

  Alt 13. Jul 2005, 17:59
Zitat von DGL-luke:
tab ist docch #13, oder?
Nein, tab ist #9
#13 ist enter/neue zeile

Zitat von DGL-luke:
ich weiss, dass das weder elegant noch performant ist, aber es sollte funktionieren.
Hmm ... ich werds mir mal anschauen ... dennoch wäre das ne mordsarbeit bei sowas:
Code:
fscanf(inf,"%i%i%i%i%i%s%s%i%s%s%s%i%i%i%i%i%i%i%i%i\n", &j,&j,&j,&j,&j, nam, nam1, &j, s9, s10, s11, &j,&j, &j,&fmedian,&fmean,&fsd,&bmedian,&bmean,&bsd);
ciao, Philipp
Philipp
There is never enough time to do all the nothing you want.
*HABENWILL*
  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#4

Re: fscanf in Delphi?

  Alt 13. Jul 2005, 18:00
was isn das für ne syntax

sag mir doch mal kurz die definition von fscanf...
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#5

Re: fscanf in Delphi?

  Alt 13. Jul 2005, 18:02
Das ist C.

Noch ein Tipp: ExplodeExplode.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Benutzerbild von c113plpbr
c113plpbr

Registriert seit: 18. Nov 2003
Ort: localhost
674 Beiträge
 
Delphi 2005 Professional
 
#6

Re: fscanf in Delphi?

  Alt 13. Jul 2005, 18:08
Zitat von Luckie:
Noch ein Tipp: ExplodeExplode.
Schön, danke, ich glaube das ist genau das was ich suche ... ^^

Zitat von DGL-luke:
sag mir doch mal kurz die definition von fscanf...
MSDN-Library durchsuchenfscanf

ciao & thx, Philipp
Philipp
There is never enough time to do all the nothing you want.
*HABENWILL*
  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#7

Re: fscanf in Delphi?

  Alt 14. Jul 2005, 14:27
Zitat von Luckie:
Das ist C.
is mir klar, nur so ne monster-parameterliste kam mir halt ungeheuer vor...

Zitat:
Noch ein Tipp: ExplodeExplode.


und das mir, der ich schon einmal selbst eine explode-funktion geschrieben habe...
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz