Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copying Contents of an Array without Loop?
#11
kiz: i havent made that much progress on it lately, been helping out on a Turn Based Strategy game with torahteen/eclipzer/ryan/ssc/rattrap/xteraco
Reply
#12
Well, there you go syn. Heh, didn't think to look up C functions.
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#13
Quote:If you dimension an array using (20), it will dimension index 0 to 20, giving 21 subscripts.

Thanx that is new for me.

In other basic
dim a(1) as integer will make an array with one element on index 0
and
dim a(1 to 1) as integer will make an array with one element on index 1

Joshy
sorry about my english
Reply
#14
ok so I am trying to copy map data to temp map data array and then back again if there is an error witht he file, I am getting an out of array bounds. I am still trying to figure out what is going wrong, but can someone tell me if I am using memcpy correctly?
Code:
text$ = input_text(font, "Load What File?",CENTER,display.max_y/2, colour_1)
redim temp_array(1 to UBOUND(map_array,1)+1, 1 to Ubound(map_array,2)+1)
memcpy (@temp_array(0,0), @map_array(0,0), (len(sizeof(map_array))*(ubound(map_array,1)*ubound(map_array,2))))
If (load_map(map_array(),text$)) then
    memcpy (@map_array(0,0), @temp_array(0,0), (len(sizeof(map_array))*(ubound(map_array,1)*ubound(map_array,2))))
    display_text_solid(font,"*WARNING* File could not be opened",CENTER,display.max_y/2 + 40, colour_2)
    SDL_Flip (video)
    SDL_Delay 2000
end if
url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
Reply
#15
I don't think you can use UBound on multi-dimensional arrays. I'd post on freebasic.net forums to make sure on that one.
Reply
#16
Quote:I don't think you can use UBound on multi-dimensional arrays. I'd post on freebasic.net forums to make sure on that one.
it works, i looked it up in the FB .chm
url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
Reply
#17
youre dimming temp_array from "1 to ..." and then memcpy'ing from 0.

id suggest ALWAYS dimming arrays from index 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)