Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Won't work: imgArray as integer[imageWidth,imageHeight]

Author
Message
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th Nov 2017 12:03

I wanted to use two changeable values to make an array. But the stuff just refuse to work:



This gave me:
main.agc:94: error: Unexpected token "imagewidth", Array dimension must be an integer literal or a constant

I later tried using those fancy 'constants' for imageHeight and imageWidth, but that screwed up in new ways:
main.agc:94: error: Unexpected token "getmemblockint", Array dimension must be an integer literal or a constant

I got so desperate that I even tried looking in the manual. I'm pretty much stuck.
adambiser
AGK Developer
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 26th Nov 2017 16:12 Edited at: 26th Nov 2017 16:35
Try this:

dim imgArray[imageWidth,imageHeight] as integer

EDIT: You'll probably want to subtract 1 from imageWidth and imageHeight for the array, too, since the arrays in Tier 1 really deal with upper bounds instead of lengths.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Nov 2017 16:25 Edited at: 26th Nov 2017 16:31
if you not have a constant you can resize with .length=
i agree for a basic language it not should be a stumbling block.
but i recommend the new array commands.
https://www.appgamekit.com/documentation/guides/12_array_changes.htm
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.2) Radeon R7 265 : Mac mini OS High Sierra (10.13)
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 27th Nov 2017 16:41
Thanks, dim and subtract fixed it! No clue as to the deeper logic, (I really should read up on this) but things are working now.

Login to post a reply

Server time is: 2024-09-30 11:26:46
Your offset time is: 2024-09-30 11:26:46