Advertisement

How do I load a text file in Delphi?? (For a tile-Based map editor)

Started by December 12, 2000 01:52 AM
2 comments, last by The_Krill 24 years ago
How would I go about loading a text file into an array (Layer2[13][130]) in Delphi? I can load text into a memo and other things, but havent been able to load an array or string or anything. HOW? How to get the MousePos in the window would also be usefull, I did it in another program of mine but dont remember how. Thanx in advance -Kevin Souter P.S. The game itself is being developed in C++ using OpenGL. Good ole NeHe. Never argue with an idiot, they drag you down to their level and then beat you with experience.
Never argue with an idiot, they drag you down to their level and then beat you with experience.
Anybody??
Never argue with an idiot, they drag you down to their level and then beat you with experience.
Advertisement
Use binary files. They''ll take a lot less space. As for the commands well I''ve not used Delphi much I don''t know them.
Hey,
Try using the blockread() command, for example:-

var
t: file;
mapheader: array[1..5] of char;
data1: array[1..100] of char;
numread: integer;
begin;
assignfile(t,''C:\test\mymap.txt'');
reset(t,1);
blockread(t,mapheader,5,numread);
blockread(t,data1,100,numread);
closefile(t);
end;

Or if you want to stay nice and simple!! Try:-

var
t: textfile;
header, data1: string;
begin;
assignfile(t,''C:\test\mymap.txt'');
reset(t);
readln(t,header);
readln(t,data1);
closefile(t);
end;

Hope that helps, if not feel free to email me :- x_ntrocks@ic24.net

Matt,
A.K.A KingMaximus

This topic is closed to new replies.

Advertisement