#HASH-OFF
NEWINTERPRETER
// @mode:strict
//
// The purpose of this test is to verify that index cursor operations
// without a matching INDEX_CLOSE in the same scope trigger ACU-IND-001.
//

// TEST SETUP
// ==========
VAR sHandle : SHORT
VAR sStatus : SHORT


// ACCEPTED FORMATS
// ================

sHandle = 0
sStatus = INDEX_SAVE_POSITION("MD")
sStatus = INDEX_OPEN_STANDARD("MD", 0, sHandle)
sStatus = INDEX_LOAD_KEY_STRING(sHandle, "FUND", 5)
sStatus = INDEX_READ_BY_KEY(sHandle, ">")
sStatus = INDEX_CLOSE(sHandle)   // Valid: INDEX_CLOSE present.
sStatus = INDEX_RESTORE_POSITION("MD")


// REJECTED FORMATS
// ================

FUNCTION CursorWithoutClose() : SHORT
  VAR sH : SHORT
  VAR sRet : SHORT
  sH = 0
  sRet = INDEX_SAVE_POSITION("PH")
  sRet = INDEX_OPEN_STANDARD("PH", 0, sH)
  sRet = INDEX_LOAD_KEY_STRING(sH, "SMITH", 5)
  sRet = INDEX_READ_BY_KEY(sH, ">")
  // ERROR: No INDEX_CLOSE — ACU-IND-001.
  sRet = INDEX_RESTORE_POSITION("PH")
  RETURN sRet
ENDFUNCTION
