# intdim

Declare integer array variable.

    intdim <array> <size>

## Remarks

Defines the array of integer type having the <size> entry. The <size> range is from 1 to 65536 and the array index is 0-origin.
The default value of the array is 0.

## Example

    ; Fibonacci sequence
    intdim fibonacci 20
    fibonacci[0] = 0
    fibonacci[1] = 1
    for i 2 19
            fibonacci[i] = fibonacci[i-2] + fibonacci[i-1]
    next

    msg = ""
    for i 0 19
            sprintf2 msg "%s%d, " msg fibonacci[i]
    next

    messagebox msg "result"

    ; binary search tree
    N = 10
    intdim a N
    a[0] = 1
    a[1] = 2
    a[2] = 3
    a[3] = 7
    a[4] = 11
    a[5] = 32
    a[6] = 40
    a[7] = 68
    a[8] = 81
    a[9] = 99

    inputbox 'Search data?' 'User Input'
    str2int key inputstr

    flag = 0
    low = 0
    high = N - 1
    while low <= high
    	mid = (low + high) / 2
    	if a[mid] == key then
    		sprintf "Your data %d found in index %d." key mid
    		messagebox inputstr 'Success'
    		flag = 1
    		break
    	endif
    	if a[mid] < key then
    		low = mid + 1
    	else
    		high = mid - 1
    	endif
    endwhile

    if flag == 0 then
    	messagebox 'Your data not found.' 'Failure'
    endif
    end

    ; sieve of Eratosthenes
    ;
    ; Example of execution result
    ; 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 [18 primes]
    ;

    N = 30
    intdim flag N+1
    count = 1
    for i 0 N
    	flag[i] = 1
    next

    for i 0 N
    	if flag[i] =1 then
    		count = count + 1
    		p = 2 * i + 3
    		sprintf "%d " p
    		dispstr inputstr

    		k = i + p
    		while k <= N
    			flag[k] = 0
    			k = k + p
    		endwhile
    	endif
    next

    sprintf "[%d primes]" count
    dispstr inputstr

    end

## See also

- Types