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

Username:   Password: 
 RegisterRegister   
 Arrays help or someother way
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Zeeshan




PostPosted: Mon Jan 01, 2007 3:25 pm   Post subject: Arrays help or someother way

I wanted to use an array to use a name of a file iam importing. But i cant figure it out. I want the file name 2 be a variable or something so i can add 1 to it in a loop it makes a movie that way. Can anyone tell me how to use an array for this or make it a variable

code:
var pic : int
var name: int := 1

for t :1..30
name := Pic.FileNew ("1")%--------- i want this to be a variable (name) so i could do this [name:=name+1]
Pic.Draw (pic, 200, 200, picCopy)
delay (500)
pic := Pic.FileNew ("20.bmp")
Pic.Draw (yoshi, 200, 200, picCopy)
end for
[/code]
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Jan 01, 2007 3:35 pm   Post subject: (No subject)

look at the string manipulation tutorial in the Turing Walkthrough for how to do this. Specifially look for the functions intstr() and strint() to aid you.
Zeeshan




PostPosted: Mon Jan 01, 2007 3:48 pm   Post subject: (No subject)

i do know how to use a function and strings but can u use function and strings to save a file name as a variable i still cant figure it out. i need more help. plzzz
Zeeshan




PostPosted: Mon Jan 01, 2007 4:18 pm   Post subject: (No subject)

like no1 noes how to do this
come onnnnnnnn
u guys are smart
sum1 HELP!!! plzzzzzz
Sad
CodeMonkey2000




PostPosted: Mon Jan 01, 2007 4:36 pm   Post subject: (No subject)

I think you are looking for something like:
code:
var p : string
var pic : array 1 .. 5 of int
for x : 1 .. 5
    p := "Run" + intstr (x) + ".bmp"
    put "Pic(", x, ")=", p
    pic (x) := Pic.FileNew (p)
end for
Hackmaster




PostPosted: Mon Jan 01, 2007 8:37 pm   Post subject: (No subject)

arrays are declared like this:

code:


var foo: array 1..30 of int



you can replace int with any type of variable.

ok? easy stuff.
Zeeshan




PostPosted: Tue Jan 02, 2007 10:26 am   Post subject: (No subject)

Hey spearmonkey2000 could you maybe explain what you did there i think that what i want as well buh i don understand it.

i have 255 bmp files i want 2 load into turing but dont want to waste my time doing each one at a time so i thought i could do it in a loop or sumthing. Thats wht i want i noe i wasnt clear b4. So does anyone know how to do that. if u do kindly help.

thanks
Prince Pwn




PostPosted: Tue Jan 02, 2007 12:51 pm   Post subject: (No subject)

This is what he did:
code:

var p : string % Variable used to store file name
var pic : array 1 .. 5 of int % Five being the number of pictures. (each picture stored in the array)
for x : 1 .. 5
    p := "Run" + intstr (x) + ".bmp" % sets 'p' to the picture file "Run1.bmp" through "Run5.bmp"
    put "Pic(", x, ")=", p
    pic (x) := Pic.FileNew (p) % puts the picture in an array
end for


You could also scan the directory for .bmp files but that is a bit for confusing, this way should work fine.
Sponsor
Sponsor
Sponsor
sponsor
Zeeshan




PostPosted: Tue Jan 02, 2007 12:58 pm   Post subject: (No subject)

But that doesnt display my pictures it just display text on the output screen. how can i display pictures like that. i have my pictures name 1,2,3...255. could anyone change that code so it open pictures by those names. 1 through 255

thanks again
Clayton




PostPosted: Tue Jan 02, 2007 1:04 pm   Post subject: (No subject)

ok, so you have your array of pictures now right? That's all you need.

code:

Pic.Draw (x, y, p(n), picCopy)


really, put some thought into this, we're not into the habit of doing your homework for you here.
Zeeshan




PostPosted: Tue Jan 02, 2007 3:04 pm   Post subject: (No subject)

ayo freakshow i wuznt tellin no1 to do my homework. its not evn homework i wuz doin jus checkn sumthin. buh i figured it out. so.........
it don matterr
Prince Pwn




PostPosted: Tue Jan 02, 2007 5:59 pm   Post subject: (No subject)

Most people on these forums I noticed with a high post count easily get angered when someone asks for help that can't spell or doesn't describe their problem using many "technical" terms. They mistake lots of people here with low post counts for students wanting someone else to do their homework for them. That's how I see it anyways, and in many ways is true, but sometimes it gets out of hand.

I used to be mistaken for one of those "please do my homework types", even though I work on Turing mostly at home and not for school. I find the best way to learn Turing is to practice at home, and not just do it for school. I find the biggest reason why they think you are the "please do my homework types" is because of your spelling that makes you sound 1337.

We were showing you how to gather all of the pictures into an array. Once that information was stored in the array, just draw it back on the screen. Just because you store the data inside the array doesn't mean they will magically "open" on the screen. The data is there, then you "Draw" it on the screen with another command.
Zeeshan




PostPosted: Tue Jan 02, 2007 6:58 pm   Post subject: (No subject)

yo thanks prince i got it all figured out.
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 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: