The following code just opens a window and checks if the ListIconGadget has been selected (an item in it that is)
Code: Select all
Open_View_Window:
  If GetGadgetState(#Gadget_main_listbox) <> -1
    If FileOpen = 1                                           ; Only open window if file has been opened
      If mutex = 0                                            ; No other windows allowed to be opened at the same time except main
        mutex = 1                                             ; Set the single window openable flag
        If Window_view()
          Gosub Get_Letter
        Else
          Stat(0, "Cannot open view window, problem with screen, memory or program")
        EndIf
      EndIf
    Else
      Stat(0, "A file must be open for this function to work!!")
    EndIf
  Else
    Stat(0, "There is no line currently selected to view")
  EndIf
  
Return
Code: Select all
Get_Letter:
  CurrentLine     = GetGadgetState(#Gadget_main_listbox)                    ; What line are we on
  CurrentRecord.s = GetGadgetItemText(#Gadget_main_listbox, CurrentLine, 0)
  Debug Str(CurrentLine)
  Qry.s = "Select Dfile From Style Where Id = " + CurrentRecord.s + ";"
  ;----------------------------------------------------------------------------------------
  If DatabaseQuery(Qry.s)                                              ; Build the table if you can
    While NextDatabaseRow()
      Dfile.s    = GetDatabaseString(0)
    Wend
    If ReadFile(0, Dfile.s) And Lof() > 0
      CloseFile(0)
    Else
      Stat(0, "File seems to be damaged or missing, try another file?")
      Return
     EndIf
    CabName$   = Dfile.s   
    ExtractTo$ = "C:\iCat2\View\"
    WildCard$  = ""
    CallFunctionFast(SetupIterateCabinet, CabName$, 0, @CabinetCallback(), #FILEOP_DOIT)
    SetGadgetText(#Gadget_view_viewbox,  "C:\iCat2\View\Flavor.htm")
    SetGadgetText(#Gadget_view_diskfile, Dfile.s)
  Else
    Stat(0, "Cannot get record, table, database or query error or file isn't a letter")
    Return
  EndIf
Return
Code: Select all
Next_Letter:
  SetGadgetItemState(#Gadget_main_listbox, CurrentLine, 0)
  SetGadgetItemState(#Gadget_main_listbox, CurrentLine + 1, #PB_ListIcon_Selected)
  ActivateWindow()
  Gosub Get_Letter
  
; Get the previous letter in the window
Previous_Letter:
  SetGadgetItemState(#Gadget_main_listbox, CurrentLine, 0)
  SetGadgetItemState(#Gadget_main_listbox, CurrentLine - 1, #PB_ListIcon_Selected)
  ActivateWindow()
  Gosub Get_Letter
Return
Some kind person save my soul please??
P.s This exact same routine worked under a previous version of PB, I just retested it.

