Problems with Listbox in BBC BasicSDL2

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
RNBW
Posts: 38
Joined: Thu 05 Apr 2018, 21:41

Problems with Listbox in BBC BasicSDL2

Post by RNBW »

Here is some code where I keep getting "Incorrect Arguments" error message or "Not in a Procedure". Can you advise what I am doing wrong and what needs to be done to rectify it.

Code: Select all

      REM ================================================================
      REM MY DIARY - BBC BASIC SDL 2.0
      REM Phase 1: Main dialogue with ListBoxes (CORRECTED)
      REM ================================================================

      REM ================================================================
      REM PROCEDURE DEFINITIONS (must be before they are used)
      REM ================================================================

      DEF PROCdummy()
      ENDPROC

      REM ================================================================
      REM MAIN PROGRAM
      REM ================================================================

      ON ERROR IF ERR=17 CHAIN @lib$+"../examples/tools/touchide" ELSE MODE 3 : PRINT REPORT$ : END

      INSTALL @lib$ + "dlglib"

      PROC_setdialogpalette

      IF INKEY(-256) = &57 THEN
        *FONT Segoe UI,10
      ELSE
        OSCLI "FONT """ + @lib$ + "DejaVuSans"",12"
      ENDIF

      REM ================================================================
      REM DATA ARRAYS
      REM ================================================================

      MAXDAYLINES%   = 300
      MAXMONTHLINES% = 3000

      DIM DayView$(MAXDAYLINES%)
      DIM MonthView$(MAXMONTHLINES%)

      FOR I% = 0 TO MAXDAYLINES%
        DayView$(I%) = ""
      NEXT
      DayView$(0) = ""
      DayView$(1) = "Day View goes here"
      DayView$(2) = "(Phase 1 placeholder)"

      FOR I% = 0 TO MAXMONTHLINES%
        MonthView$(I%) = ""
      NEXT
      MonthView$(0) = ""
      MonthView$(1) = "Month View goes here"
      MonthView$(2) = "(Phase 1 placeholder)"

      REM ================================================================
      REM CREATE THE DIALOGUE BOX
      REM ================================================================

      dlg% = FN_newdialog("My Diary - Phase 1", 160, 140)

      REM --- Heading ---
      PROC_static(dlg%, "My Diary - Outlook Style", 100, 4, 4, 152, 12, 0)

      REM --- Day View label ---
      PROC_static(dlg%, "Day View", 101, 4, 20, 60, 10, 0)

      REM --- Day View ListBox (ID from FN_setproc) ---
      DayListID% = FN_setproc(PROCdummy())
      PROC_listbox(dlg%, "", DayListID%, 4, 32, 70, 90, 0)
      PROC_setlistboxarray(dlg%, DayListID%, DayView$(), DIM(DayView$(),1))

      REM --- Month View label ---
      PROC_static(dlg%, "Month View", 103, 80, 20, 60, 10, 0)

      REM --- Month View ListBox (ID from FN_setproc) ---
      MonthListID% = FN_setproc(PROCdummy())
      PROC_listbox(dlg%, "", MonthListID%, 80, 32, 76, 90, 0)
      PROC_setlistboxarray(dlg%, MonthListID%, MonthView$(), DIM(MonthView$(),1))

      REM --- Calendar navigation buttons ---
      PROC_button(dlg%, "<<",    10, 4,   126, 20, 12, 0)
      PROC_button(dlg%, "<",     11, 26,  126, 20, 12, 0)
      PROC_button(dlg%, "Today", 12, 48,  126, 28, 12, 0)
      PROC_button(dlg%, ">",     13, 78,  126, 20, 12, 0)
      PROC_button(dlg%, ">>",    14, 100, 126, 20, 12, 0)
      PROC_button(dlg%, "Go",    15, 122, 126, 20, 12, 0)

      REM --- Action buttons, row 1 ---
      PROC_button(dlg%, "Open",    20, 4,  140, 20, 12, 0)
      PROC_button(dlg%, "New",     21, 26, 140, 20, 12, 0)
      PROC_button(dlg%, "Refresh", 22, 48, 140, 28, 12, 0)

      REM --- Action buttons, row 2 ---
      PROC_button(dlg%, "Search", 23, 4,  154, 20, 12, 0)
      PROC_button(dlg%, "Export", 24, 26, 154, 20, 12, 0)
      PROC_button(dlg%, "Recent", 25, 48, 154, 20, 12, 0)
      PROC_button(dlg%, "Sync",   26, 70, 154, 20, 12, 0)

      REM --- Close button ---
      PROC_button(dlg%, "Close", 1, 132, 154, 24, 12, 0)

      REM ================================================================
      REM SHOW THE DIALOGUE
      REM ================================================================

      result% = FN_showdialog(dlg%)
      PROC_closedialog(dlg%)

      END
Phil_Thatcham
Posts: 13
Joined: Tue 03 Apr 2018, 11:59

Re: Problems with Listbox in BBC BasicSDL2

Post by Phil_Thatcham »

"Not in a procedure"

See https://www.bbcbasic.co.uk/bbcwin/manua ... procedures

Under The function/procedure body

Summary: Put DEFs after END where they can't be executed directly. Your DEF PROCdummy() is in the body of the program.

"Incorrect arguments"

See https://www.bbcbasic.co.uk/bbcwin/manua ... #arguments

Under Incorrect arguments

The error is in your line: result% = FN_showdialog(dlg%)

Summary: dlg% isn't what FN_showdialog() is expecting. The code supplied doesn't include your definition of FN_showdialog(), so we can't say what is expected.

PT
RNBW
Posts: 38
Joined: Thu 05 Apr 2018, 21:41

Re: Problems with Listbox in BBC BasicSDL2

Post by RNBW »

Phil_Thatcham wrote: ↑Thu 17 Sep 2026, 08:58 "Not in a procedure"

See https://www.bbcbasic.co.uk/bbcwin/manua ... procedures

Under The function/procedure body

Summary: Put DEFs after END where they can't be executed directly. Your DEF PROCdummy() is in the body of the program.

"Incorrect arguments"

See https://www.bbcbasic.co.uk/bbcwin/manua ... #arguments

Under Incorrect arguments

The error is in your line: result% = FN_showdialog(dlg%)

Summary: dlg% isn't what FN_showdialog() is expecting. The code supplied doesn't include your definition of FN_showdialog(), so we can't say what is expected.

PT
Thanks for your response, I'll have a look at what you've said and see if I can sort it out.
rnbw