List elements.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Shows how the init_list_indices function works.
  2. #define USE_TI89 // Compile for TI-89
  3. #define USE_TI92PLUS // Compile for TI-92 Plus
  4. #define USE_V200 // Compile for V200
  5. #define MIN_AMS 101 // Compile for AMS 1.01 or higher
  6. #define SAVE_SCREEN // Save/Restore LCD Contents
  7. #include <tigcclib.h> // Include All Header Files
  8. // The {1, 0, -1} list.
  9. static const ESQ list_1_0_minus1[10] = {END_TAG, 0x01, 0x01, NEGINT_TAG, 0x00, POSINT_TAG, 0x01, 0x01, POSINT_TAG, LIST_TAG};
  10. // Main Function
  11. void _main(void)
  12. {
  13. ESI elements[3];
  14. HANDLE h;
  15. TRY
  16. ClrScr();
  17. DrawStr (0, 0, "The elements of list", A_NORMAL);
  18. DrawStr (0, 20, "are", A_NORMAL);
  19. // Print whole expression.
  20. h = Parse1DExpr (list_1_0_minus1 + 9, FALSE, 0);
  21. DrawStr(0, 10, HeapDeref(h), A_NORMAL);
  22. HeapFree(h);
  23. // Get the individual constituents of the expression and print them.
  24. init_list_indices(elements, list_1_0_minus1 + 9);
  25. h = Parse1DExpr (elements[0], FALSE, 0);
  26. DrawStr(0, 30, HeapDeref(h), A_NORMAL);
  27. HeapFree(h);
  28. h = Parse1DExpr (elements[1], FALSE, 0);
  29. DrawStr(0, 40, HeapDeref(h), A_NORMAL);
  30. HeapFree(h);
  31. h = Parse1DExpr (elements[2], FALSE, 0);
  32. DrawStr(0, 50, HeapDeref(h), A_NORMAL);
  33. HeapFree(h);
  34. ONERR
  35. DrawStr (0, 70, "Error!", A_NORMAL);
  36. ENDTRY
  37. GKeyIn (NULL, 0);
  38. }