Posted: 20th Aug 2011 17:00
The following code works correctly but if I put the remstart after the Bird$(49) entry it crashes and I don't know why. Can anyone help with this? I have had other problems like this one.


+ Code Snippet
rem AGK Application
rem
// place a sprite on screen using the virtual resolution

// set a virtual resolution of 320 x 480
SetVirtualResolution ( 320, 480 )

rem
rem AGK Application
rem
// place a sprite on screen using the virtual resolution

// set a virtual resolution of 320 x 480
SetVirtualResolution ( 320, 480 )
Global iDispSprite
dim Bird$[50]
dim State$[50]
dim Tree$[50]

// load a background and create a sprite
LoadImage ( 101, "statebackground.png" )
CreateSprite ( 101, 101)
LoadImage ( 100, "Made-With-AGK-White-64px.png" )
CreateSprite ( 100, 100 )
LoadImage (1,"Alabama-Flag-128.png")
LoadImage (2,"Alaska-Flag-128.png")
LoadImage (3,"Arizona-Flag-128.png")
LoadImage (4,"Arkansas-Flag-128.png")
LoadImage (5,"California-Flag-128.png")
LoadImage (6,"Colorado-Flag-128.png")
LoadImage (7,"Connecticut-Flag-128.png")
LoadImage (8,"Delaware-Flag-128.png")
LoadImage (9,"Florida-Flag-128.png")
LoadImage (10,"Georgia-Flag-128.png")
LoadImage (11,"Hawaii-Flag-128.png")
LoadImage (12,"Idaho-Flag-128.png")
LoadImage (13,"Illinois-Flag-128.png")
LoadImage (14,"Indiana-Flag-128.png")
LoadImage (15,"Iowa-Flag-128.png")
LoadImage (16,"Kansas-Flag-128.png")
LoadImage (17,"Kentucky-Flag-128.png")
LoadImage (18,"Louisiana-Flag-128.png")
LoadImage (19,"Maine-Flag-128.png")
LoadImage (20,"Maryland-Flag-128.png")
LoadImage (21,"Massachusetts-Flag-128.png")
LoadImage (22,"Michigan-Flag-128.png")
LoadImage (23,"Minnesota-Flag-128.png")
LoadImage (24,"Mississippi-Flag-128.png")
LoadImage (25,"Missouri-Flag-128.png")
LoadImage (26,"Montana-Flag-128.png")
LoadImage (27,"Nebraska-Flag-128.png")
LoadImage (28,"Nevada-Flag-128.png")
LoadImage (29,"New-Hampshire-Flag-128.png")
LoadImage (30,"New-Jersey-Flag-128.png")
LoadImage (31,"New-Mexico-Flag-128.png")
LoadImage (32,"New-York-Flag-128.png")
LoadImage (33,"North-Carolina-Flag-128.png")
LoadImage (34,"North-Dakota-Flag-128.png")
LoadImage (35,"Ohio-Flag-128.png")
LoadImage (36,"Oklahoma-Flag-128.png")
LoadImage (37,"Oregon-Flag-128.png")
LoadImage (38,"Pennsylvania-Flag-128.png")
LoadImage (39,"Rhode-Island-Flag-128.png")
LoadImage (40,"South-Carolina-Flag-128.png")
LoadImage (41,"South-Dakota-Flag-128.png")
LoadImage (42,"Tennessee-Flag-128.png")
LoadImage (43,"Texas-Flag-128.png")
LoadImage (44,"Utah-Flag-128.png")
LoadImage (45,"Vermont-Flag-128.png")
LoadImage (46,"Virginia-Flag-128.png")
LoadImage (47,"Washington-Flag-128.png")
LoadImage (48,"West-Virginia-Flag-128.png")
LoadImage (49,"Wisconsin-Flag-128.png")
LoadImage (50,"Wyoming-Flag-128.png")



Bird$[1] = "Yellowhammer"
Bird$[2] = "Willow Ptarmigan"
Bird$[3] = "Cactus Wren"
Bird$[4] = "Mockingbird"
Bird$[5] = "California Valley Quail"
Bird$[6] = "Lark Bunting"
Bird$[7] = "Robin"
Bird$[8] = "Blue Hen Chicken"
Bird$[9] = "Mockingbird"
Bird$[10] = "Brown Thrasher"
Bird$[11] = "Nene"
Bird$[12] = "Mountain Bluebird"
Bird$[13] = "Cardinal"
Bird$[14] = "Cardinal"
Bird$[15] = "Eastern Goldfinch"
Bird$[16] = "Western Meadowlark"
Bird$[17] = "Cardinal"
Bird$[18] = "Eastern Brown Pelican"
Bird$[19] = "Chickadee"
Bird$[20] = "Baltimore Oriole"
Bird$[21] = "Chickadee"
Bird$[22] = "Robin"
Bird$[23] = "Common Loon"
Bird$[24] = "Mockingbird"
Bird$[25] = "Bluebird"
Bird$[26] = "Western Meadowlark"
Bird$[27] = "Western Meadowlark"
Bird$[28] = "Mountain Bluebird"
Bird$[29] = "Purple Finch"
Bird$[30] = "Eastern Goldfinch"
Bird$[31] = "Roadrunner"
Bird$[32] = "Bluebird"
Bird$[33] = "Cardinal"
Bird$[34] = "Western Meadowlark"
Bird$[35] = "Cardinal"
Bird$[36] = "Scissor-tailed Flycatcher"
Bird$[37] = "Western Meadowlark"
Bird$[38] = "Ruffed Grouse"
Bird$[39] = "Rhode Island Red"
Bird$[40] = "Great Carolina Wren"
Bird$[41] = "Ring-necked Pheasant"
Bird$[42] = "Mockingbird"
Bird$[43] = "Mockingbird"
Bird$[44] = "California Seagull"
Bird$[45] = "Hermit Thrush"
Bird$[46] = "Cardinal"
Bird$[47] = "Willow Goldfinch"
Bird$[48] = "Cardinal"
remstart
Bird$[49] = "Robin"
Bird$[50] = "Western Meadowlark"
 remend



        CreateText (1,"U.S. States")
        SetTextPosition (1,70,50)
        SetTextColor (1,255,255,0,255)
        SetTextSize (1,32)
        CreateText (2,"Instructions")
        SetTextPosition (2,70,130)
        SetTextColor (2,255,0,0,255)
        SetTextSize (2,32)
        CreateText (3,"Play")
        SetTextPosition (3,70,210)
        SetTextColor (3,255,0,0,255)
        SetTextSize (3,32)
        do
            sync( )
        loop
Posted: 22nd Aug 2011 3:22
Arrays are zero based (aren't they) so with dim Bird$[50] the index goes from 0 to 49. If you index 50 then you'll get an error.
Posted: 22nd Aug 2011 11:27
@ briwal: I think they can go from 0 to max_value - see snippet

+ Code Snippet
dim array[10]

do
    for n = 0 to 10
        array[n] = n
        print(array[n])
    next n
    sync()
loop


@Uechi: Please put your code into code snippets (inbetween code tags [ code]Code Here[ /code] without the spaces in the tags) as it makes posts massive.

As far as I can tell (I haven't played around with the text commands) but your code seems fine. I have heard that remstart and remend are ineffective right now though. You also set the virtual resolution twice .
Posted: 23rd Aug 2011 16:47
Arrays in AppGameKit are zero based but you get +1 slots!

A

+ Code Snippet
dim array[10]


will give you an array with indexes ranging from 0-10.