Post Reply 
notebook code error
01-04-2023, 04:39 AM (This post was last modified: 01-04-2023 05:45 AM by DrEureka.)
Post: #6
RE: notebook code error
I made a modification instead of using "case" use conditionals, now I have a problem on line 43 that I don't understand why
Code:
EXPORT Notebook()

BEGIN
  // Define variables for notebook and notes
  LOCAL notebook, notes;
  notebook := {};
  notes := {};

  // Define main menu options
  LOCAL mainMenuOptions;
  mainMenuOptions := ["New note", "View notes", "Delete note"];

  // Main menu loop
  WHILE TRUE DO
    // Display main menu
    LOCAL options, optionIndex, option;

    options := ["Option 1", "Option 2", "Option 3"];

    optionIndex := Input("Choose an option: ", options);

    option := options[optionIndex];

    // Handle main menu option selection
    IF option == "Option 1" THEN
      // Create new note
      noteTitle := Input("Enter note title: ");
      noteText := Input("Enter note text: ");
      note := {noteTitle, noteText};
      notes := {note, notes};
      Print("Note created successfully.");
    ELSE
      IF option == "Option 2" THEN
        // View notes
        IF notes = {} THEN
          Print("No notes to display.");
        ELSE
          noteTitles := {};
          FOR i FROM 1 TO LENGTH(notes) DO
            noteTitles := {noteTitles, notes[i, 1]};
          END;
          noteIndex := Input("Notes", noteTitles);
          Print("Title: " + notes[noteIndex, 1]);
Print("Text: " + notes[noteIndex, 2]);
        END;
      ELSE
        IF option == "Option 3" THEN
          // Delete note
          IF notes = {} THEN
            Print("No notes to delete.");
          ELSE
            noteTitles := {};
            FOR i FROM 1 TO LENGTH(notes) DO
              noteTitles := {noteTitles, notes[i, 1]};
            END;
            noteIndex := Input("Notes", noteTitles);
            notes := remove(notes, noteIndex);
            Print("Note deleted successfully.");
          END;
        END;
      END;
    END;
  END;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
notebook code error - DrEureka - 01-02-2023, 07:10 AM
RE: notebook code error - Didier Lachieze - 01-02-2023, 08:34 AM
RE: notebook code error - DrEureka - 01-04-2023, 04:18 AM
RE: notebook code error - Dougggg - 01-03-2023, 01:06 AM
RE: notebook code error - DrEureka - 01-04-2023, 04:22 AM
RE: notebook code error - DrEureka - 01-04-2023 04:39 AM
RE: notebook code error - roadrunner - 01-04-2023, 01:47 PM



User(s) browsing this thread: 1 Guest(s)