Posted: 09:16pm 27 Nov 2016 |
Copy link to clipboard |
 Print this post |
|
Read the manual and can not see what I am doing wrong?
Updated the code to be a little more descriptive - don't want to call this a bug but if I do something wrong program wise, shouldn't an error be created?
' Test program to create an a string array, erase it and ' then reuse it using the same name
Dim a_array_ptr% = 0 'integer for pointer to array Dim b_array_ptr% = 0 'integer for pointer to array which doesn't exist Dim a_array$(1,1) length 1 ' 2 by 2 one char string array a_array$(0,0)="A" 'set value into array Print "This is what we put in the first position of the array ",a_array$(0,0) a_array_ptr% = Peek(VARADDR a_array$()) 'get pointer to array Print "Address of array is ",hex$(a_array_ptr%) Erase a_array$ ' erase the array to free memory on error skip 'if error in next line, jump over IF ... GOTO a_array_ptr%=Peek(VARADDR a_array$()) ' get pointer to array if MM.ERRORNO <> 0 then goto exitdoor ' ** the peek above should fail as array was erased ??? ' so we should have jumped to the exitdoor Print "Address of erased array is ",hex$(a_array_ptr%)
' Now test a non existant array on error skip 'if error in next line, jump over IF ... GOTO b_array_ptr%=Peek(VARADDR b_array$()) ' get pointer to array if MM.ERRORNO <> 0 then goto exitdoor ' ** the peek should fail as array does not exist ' so we should have jumped to the exitdoor Print "Address of non-existant array !!! ",hex$(b_array_ptr%) ' We should not get here as both Peeks above should have failed Print "Why am I here?" Dim a_array$(2,2) length 1 ' re dim array should work ??? ' ** this should work as a_array$ was erased and should now ' be available for re-use ??
a_array$(0,0) = "Z" 'assign new value Print a_array$(0,0) ' and print error "Not really an error - correct end of program"
exitdoor: error "Really - an error happend up above!"
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |