Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Loading .txt Files
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheXploder




PostPosted: Fri Feb 06, 2004 8:37 pm   Post subject: (No subject)

I added some more code now it adds the value loaded to a two dimensional array, yay now I'm done my game... because all you need is numbers it's all about numbers every game is made with arrays full of numbers like CS, anyway, can I shorten that any further..?

code:

var map : array 1 .. 10, 1 .. 10 of int
var number : array 1 .. 10 of string
var stremin, stremout : int %a var that is an int is needed to open a file

open : stremin, "test.txt", get %this will open a connection to get data

loop
    exit when eof (stremin)
    for i : 1 .. 10
        get : stremin, number (i)
    end for
end loop

for i : 1 .. 10
    for i2 : 1 .. 10
        map (i, i2) := strint (number (i) (i2))
    end for
end for

for i : 1 .. 10
    for i2 : 1 .. 10
        put map (i, i2) ..
    end for
    put ""
end for
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Sat Feb 07, 2004 12:34 pm   Post subject: (No subject)

the last for loop is useless.. just output it rite after you save it

code:

for i : 1 .. 10
    for i2 : 1 .. 10
        map (i, i2) := strint (number (i) (i2))
        put map (i, i2) ..
    end for
put""
end for



???
strint (number (i) (i2))
number is a 1 d aray
santabruzer




PostPosted: Sat Feb 07, 2004 1:33 pm   Post subject: (No subject)

it's probably string manipulation... or something of the sort... of the array
Andy




PostPosted: Sat Feb 07, 2004 1:41 pm   Post subject: (No subject)

oooo... y didnt he just get one character at a time from the txt file?
santabruzer




PostPosted: Sat Feb 07, 2004 1:43 pm   Post subject: (No subject)

i have no idea.. and that would be so much simpler and more efficient *decides that he is not gonna write it*
TheXploder




PostPosted: Sat Feb 07, 2004 1:44 pm   Post subject: (No subject)

I am going to create a map out of this, so you need the x, y position of every integer..
Andy




PostPosted: Sat Feb 07, 2004 1:45 pm   Post subject: (No subject)

yea...

code:

var temp:string(1)
for i:1..10
    for j:1..10
        get:file, temp
        map(i,j):=strint(temp)
    end for
end for

and he's done
TheXploder




PostPosted: Sun Feb 08, 2004 3:34 pm   Post subject: (No subject)

Dodge, I don't understand how your code works, could you write a complete source that also loads a file..
Anyway I got another probelem I want to open map.txt files that are in another folder:

code:

var map : array 1 .. 10, 1 .. 10 of int
var number : array 1 .. 10 of string
var stremin, stremout : int := 1 %a var that is an int is needed to open a file

open : stremin, "New Folder\map.txt", get %this will open a connection to get data

loop
    exit when eof (stremin)
    for i : 1 .. 10
        get : stremin, number (i)
    end for
end loop

close : stremout

for i : 1 .. 10
    for i2 : 1 .. 10
        map (i, i2) := strint (number (i) (i2))
    end for
end for

for i : 1 .. 10
    for i2 : 1 .. 10
        put map (i, i2)
    end for
end for
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 23 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: