
-----------------------------------
Insectoid
Thu Aug 07, 2008 4:12 pm

loading pics into an array with a for loop
-----------------------------------
How can I load up pictures automatically into an array with a for loop? I have pictures named 'bar (1)', 'bar (2)', etc, and want to load them into an array 1..10 of int.

I tried this:


var bars : array 1..10 of int
for x: 1..10
bars (x) := Pic.FileNew ("bar ("x").bmp")
end for


which obviously doesn't work (I tried it for the small chance it would.)

I need a way to sub in the picture's number for 'x'. 
Help?

~Insectoid

-----------------------------------
Tony
Thu Aug 07, 2008 4:23 pm

RE:loading pics into an array with a for loop
-----------------------------------

"bar (" + intstr(x) + ").bmp"


-----------------------------------
DemonWasp
Thu Aug 07, 2008 11:31 pm

RE:loading pics into an array with a for loop
-----------------------------------
There are a number of standard patterns used for inserting the values of variables into a string object (usually for output, though they have other uses, as you've shown).

First, there's concatenation, which is essentially "joining sequentially". This is what Tony suggested, and goes like

string A = "there are" + posts + " posts on this forum"
// (A contains "there are 23989 posts on this forum")

Different languages use different operators. In Turing, you can use + in all cases, but you can also use commas in put and write statements. C++ uses 