Microsoft Small Basic

Program Listing:
Embed this in your website
'Program: ToDoList 1.3
' based on Names (06/2015) by Martin Menze (martmen)
' and LitDev Extension V 1.2.9.0 for .Net 4.5 framework and Small Basic 1.2
' by backtothestart 06/2016
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' update by backtothestart 08/2019 Flickr-Download with Temp-File
' LitDev Extension V 1.2.22.0
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Window & Database Defines
'______________________________________________________________________
GraphicsWindow.Title  = " Task List "
DataBaseFile          = "TasklistV12.db"
DataBaseTable         = "ActualTasks"
Column_1              = "Scope"
Column_2              = "Task"
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Events 'Events can start a Subroutine. This program use the following events.
'______________________________________________________________________
GraphicsWindow.KeyUp                = KeyUp          'Start Sub KeyUp if a key was uped.
Controls.ButtonClicked              = ButtonClicked  'Start Sub ButtonClickes if a button was clicked.
LDControls.ListViewSelectionChanged = ListviewSelect 'Start Sub ListviewSelect if a Listviewline was clicked.
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Initialisation
'______________________________________________________________________
Initialisation()       'All objects, variable and so on will define in the subroutine Initialisation.
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Main Program
'______________________________________________________________________
Controls.ShowControl(ArrTextBox[VarNumFirstName])'Show the texbox to input the first name.
VarInputIndex = VarNumFirstName                  'Fill the variable VarInputIndex with the same value it is in the variable VarNumFirstName. It is 1.
LDFocus.SetFocus(ArrTextBox[VarInputIndex])      'Set the fokus to the textbox to input the first name. The cursor is blinking in this text box.
SetFocus()                                       'Start the subroutine SetFocus.
'Fokus() 'Start the subroutine Fokus.
While VarEndOfProgram = F                        'Begin of the main loop. Lopp in the main loop as long as the variable VarEndOfProgram is equal F. F is "False".
  Fokus()                                        'Start the subroutine Fokus.
  CheckEvents()                                  'Start the subroutine CheckEvents
  Program.Delay(200)                              'Free CPU Resources
EndWhile                                         'End of the main loop.
Program.End()                                    'The End of this Program.
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutines
'______________________________________________________________________
' Subroutine Fokus
' Notize the value form the last name of the textbox in the variable VarOldFocus.
' Notize the value from the actual name of the textbox in the variable VarFokus.
' Is the Focus changed then identify in a loop the name of the actual textbox.
' Has it found, set the loop variable of the end value. This optimize the loop cycle.
' Start the subroutine Set Focus.
'______________________________________________________________________
Sub Fokus                                        'Begin of subroutine Fokus
  VarOldFokus = VarFokus
  VarFokus = LDFocus.GetFocus()                  'Get the name of the object with the actualy focus.
  If VarFokus <> VarOldFokus Then                'If the focus was changed do the folowing.
    For i = VarNumFirstName To VarNumLastInput   'Loop as long as i is the same as VarNumLastInput. Begin with i equal the same as in VarNumFirstName
      If VarFokus = ArrTextBox[i] Then           'Is the Name of the actual object the same as the textbox
        VarOldInputIndex = VarInputIndex         'Put the value from variable VarInputIndex into the variable VarOldInputIndex
        VarInputIndex = i                        'Put the value from variable i into the variable VarInputIndex
        SetFocus()                               'Start the subroutine SetFocus.
      EndIf                                      'End the last If
    EndFor                                       'If the value from i equal VarNumLastInput it is the end of the loop else the add 1 to the vallue of i.
  EndIf                                          'End the last if
EndSub 'Fokus 'go back to the next line after the Start of the subroutine Fokus()

'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine CheckEvents
' The subroutine CheckEvents check the events skips for events.
' Was a button clicked it start the subroutine WhichButtonWasClicked.
' Was a key pressed and key uped then start the subroutine WichKeyWasPressed.
'______________________________________________________________________
Sub CheckEvents
  If VarButtonClicked = T Then
    VarButtonClicked = F
    VarLastClickedButton = Controls.LastClickedButton
    WhichButtonWasClicked()
  EndIf
  If VarKeyUP = T Then
    VarKeyUP = F
    VarLastKey = GraphicsWindow.LastKey
    WhichKeyWasUped()
  EndIf
EndSub 'CheckEvents
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine WhichButtonWasClicked
' There are 3 buttons (Next, Save and Exit).
' Was clicked Next then start the subroutines SetFocusToNextTextBox and SetFocus.
' Was clicked Save then start the subroutines SetFocustoToNextTextBox and SetFocus.
' Start the subroutine DataToDatabase and ClearObjects. At last by button Save
' to set the focus to the first text box.
' Was clicked Exit then put T (True) to the variable VarEndOfProgram. So the main loop will ended
'______________________________________________________________________
Sub WhichButtonWasClicked
  'TextWindow.WriteLine("VarLastClickedButton:.." +VarLastClickedButton )
  ' _________________NEXT
  If VarLastClickedButton = ArrButton[VarNumNextField] Then
    SetFocusToNextTextBox()
    SetFocus()
  ' _________________SAVE
  ElseIf VarLastClickedButton = ArrButton[VarNumSave] Then
    SetFocusToNextTextBox()
    SetFocus()
    ArrData[VarNumLastName] = LDText.Trim(ArrData[VarNumLastName])
    If Edit_Mode = "Insert" Then
     If ArrData[VarNumLastName] = "" Then
      GraphicsWindow.ShowMessage("Please input data. ", " No save without data.")
      VarMessage = "Data: " + ArrData[VarNumFirstName] + " " + ArrData[VarNumLastName] + " was not saved."
     Else
      DataToDatabase()
      VarMessage = "Data: " + ArrData[VarNumFirstName] + " " + ArrData[VarNumLastName] + " was saved."
      ClearObjects()
     EndIf
    Elseif Edit_Mode = "Update" Then
      RecordToDatabase()
      ClearObjects()
      Edit_Mode = "Insert"
    EndIf
    ShowSelection()
    ShowMessage()
  ' ___________________DELETE
  ElseIf VarLastClickedButton = ArrButton[VarNumDel] Then
    If LineSelect = "" OR VarListViewClicked = F Then
      GraphicsWindow.ShowMessage("Please select row. ", " Nothing Delete")
    Else
      DelRecord()
      ClearObjects()
      ShowSelection()
    EndIf
    ShowMessage()
  ' ___________________EDIT
  ElseIf VarLastClickedButton = ArrButton[VarNumEdit] Then
    If LineSelect = "" OR VarListViewClicked = F Then
      GraphicsWindow.ShowMessage("Please select row. ", " Which row to edit ?")
    Else
      EditRecord()
      SetFocusToNextTextBox()
      SetFocus()
    EndIf
    ShowMessage()
  ' ___________________POS UP
  ElseIf VarLastClickedButton = ArrButton[VarNumUp] Then
    If LineSelect = 0 Then
      GraphicsWindow.ShowMessage("Please select row. ", " Nothing to move")
    Else
      RecordUp()
      LDFocus.SetFocus(tdlist)
    EndIf
    ShowMessage()
  ' ___________________POS DOWN
  ElseIf VarLastClickedButton = ArrButton[VarNumDown] Then
    If LineSelect = 0 Then
      GraphicsWindow.ShowMessage("Please select row. ", " Nothing to move")
    Else
      RecordDown()
      LDFocus.SetFocus(tdlist)
    EndIf
    ShowMessage()
  ' ___________________PreSelection 1
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 1] Then
    View_Mode = 1
    ShowSelection()
  ' ___________________PreSelection 2
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 2] Then
    View_Mode = 2
    ShowSelection()
  ' ___________________PreSelection 3
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 3] Then
    View_Mode = 3
    ShowSelection()
  ' ___________________PreSelection 4
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 4] Then
    View_Mode = 4
    ShowSelection()
  ' ___________________PreSelection 5
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 5] Then
    View_Mode = 5
    ShowSelection()
  ' ___________________PreSelection 6
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 6] Then
    View_Mode = 6
    ShowSelection()
  ' ___________________PreSelection 7
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 7] Then
    View_Mode = 7
    ShowSelection()
  ' ___________________PreSelection 8
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 8] Then
    View_Mode = 8
    ShowSelection()
  ' ___________________PreSelection 9
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 9] Then
    View_Mode = 9
    ShowSelection()
  ' ___________________PreSelection 10
  ElseIf VarLastClickedButton = ArrButton[VarLastButton + 10] Then
    View_Mode = 10
    ShowSelection()
  ' ___________________PreSelection 10
  ElseIf VarLastClickedButton = ArrButton[VarNumDesign] Then
    SelectBackground()
  ' ___________________EXIT
  ElseIf VarLastClickedButton = ArrButton[VarNumExit] Then
    VarEndOfProgram = T
  EndIf
EndSub 'WhichButtonWasClicked
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine SelectBackground
' - Hide Controls
' - Get New Picture from Flickr and wait
' - Show Controls
'______________________________________________________________________
Sub SelectBackground
  Controls.HideControl(tdlist)
  Controls.HideControl(ArrTextBox[1])
  Controls.HideControl(ArrTextBox[2])
  For i = 1 To VarLastButton + 10
   Controls.HideControl(ArrButton[i])
  endfor

' The following line could be harmful and has been automatically commented.
' tmpFile = File.GetTemporaryFilePath()
  imageURL = Flickr.GetPictureOfMoment()
  LDNetwork.DownloadFile(tmpFile,imageURL)
  Hintergrund = ImageList.LoadImage(tmpFile)
' The following line could be harmful and has been automatically commented.
' File.DeleteFile(tmpFile)
  ' Hintergrund = ImageList.LoadImage(Flickr.GetPictureOfMoment())
  GraphicsWindow.DrawResizedImage(Hintergrund,0,0,GraphicsWindow.Width,GraphicsWindow.Height)

  Program.Delay(2000)
  For i = 1 To VarLastButton + 10
   Controls.ShowControl(ArrButton[i])
  endfor
  Controls.ShowControl(ArrTextBox[1])
  Controls.ShowControl(ArrTextBox[2])
  Controls.ShowControl(tdlist)
  BrushPreSelectButtons()
EndSub 'SelectBackground
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine ShowSelection
' - Get DataBaseData via Preselection - Fill DB-Array and View
' - Show the Preselection in the first textfield
'______________________________________________________________________
Sub ShowSelection
   GetDBData()
   Arrdata[VarNumFirstName] = Text.GetSubTextToEnd(PreSelect[View_Mode],1)
   'TextWindow.WriteLine("Preset : "+ Arrdata[VarNumFirstName])
   If View_Mode > 1 then
    Controls.SetTextBoxText(ArrTextBox[VarNumFirstName], ArrData[VarNumFirstName])
   Else
    Controls.SetTextBoxText(ArrTextBox[VarNumFirstName], "")
   endif
   Controls.ShowControl(ArrTextBox[VarNumFirstName])
   ShowMessage()
EndSub 'ShowSelection
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine ShowMessage
' - Display Info Line on Graphic Window
'______________________________________________________________________
Sub ShowMessage
  Shapes.SetText(MessageShape, VarMessage)
  Shapes.ShowShape(MessageShape)
EndSub 'ShowMessage
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine WhichKeyWasUped
' Was it key Return, then start the subroutine SetFocusToNextTextBox. The same doing by key
' Tab (Tabulator).
' By the combination of key tab and a shift key (right or left) the variable VarInputIndex substract 1.
' Is this lower then 1 the value will set with the last number ob text boxes. At last the Focus set in
' the actualy text box.
'______________________________________________________________________
Sub WhichKeyWasUped
  If VarLastKey = "Return" Then
    SetFocusToNextTextBox()
  ElseIf VarLastKey = "Tab" Then
    If GraphicsWindow.LastKey = "RightShift" or GraphicsWindow.LastKey = "LeftShift" Then
      VarInputIndex = VarInputIndex - 1
      If VarInputIndex < 1 Then
        VarInputIndex = VarNumLastInput
      EndIf
      SetFocus()
    Else
      SetFocusToNextTextBox()
    EndIf
  EndIf
  SetFocus()
  Shapes.HideShape(MessageShape)
EndSub 'WhichKeyWasUped
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine SetFocus
' Put the Input from the text box into the array for database data.
' hide the old objects and shows the actualy objects.
'______________________________________________________________________
Sub SetFocus
  ArrData[VarOldInputIndex] = Controls.GetTextBoxText(ArrTextBox[VarOldInputIndex])
  Controls.HideControl(ArrTextBox[VarOldInputIndex])
  Shapes.SetText(ArrDataShape[VarOldInputIndex], ArrData[VarOldInputIndex])
  Shapes.ShowShape(ArrDataShape[VarOldInputIndex])
  Shapes.HideShape(ArrDataShape[VarInputIndex])
  Controls.SetTextBoxText(ArrTextBox[VarInputIndex], ArrData[VarInputIndex])
  Controls.ShowControl(ArrTextBox[VarInputIndex])
  LDFocus.SetFocus(ArrTextBox[VarInputIndex])
EndSub 'SetFocus
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine SetFocutToNextTextBox
' Add 1 to the value of the variable VarInputIndex. Is this greater as the last text box number then set
' it to the first input number VarNumFirstName.
' At last start the subroutine SetFocus.
'______________________________________________________________________
Sub SetFocusToNextTextBox
  VarInputIndex = VarInputIndex + 1
  If VarInputIndex > VarNumLastInput Then
    VarInputIndex = VarNumFirstName
  EndIf
  SetFocus()
EndSub 'SetFocusToNextTextBox
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine DataToDatabase
' For database data it is not possible to write a ' into a database. If there one ' replace it with two '
' then it will be functions.
' Set the variable command with the sql-command to put the data in the database
' At last show all data from the table in the listView.
'______________________________________________________________________
Sub DataToDatabase
  For i = VarNumFirstName To VarNumLastInput
    ArrData[i] = LDText.Replace(ArrData[i], "'", "''")
  EndFor
  command = "BEGIN TRANSACTION;"
  command = command + "INSERT INTO " + DataBaseTable + "("+Column_1+","+Column_2+")"
  command = command + "VALUES('"+ArrData[VarNumFirstName]+"','"+ArrData[VarNumLastName]+"');"
  command = command + "COMMIT;"
  LDDataBase.Command(database,command)
  GetDBData()
EndSub 'DataToDatabase
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine RecordToDatabase
' Get Edit-Array-Data
' Set the variable command with the sql-command to update the record
' At last show actual data from the table in the listView.
'______________________________________________________________________
Sub RecordToDatabase
   Col1_Data = LDText.Replace(Arrdata[VarNumFirstName], "'", "''")
   Col2_Data = LDText.Replace(Arrdata[VarNumLastName] , "'", "''")
   command = "BEGIN TRANSACTION;"
   command = command + "UPDATE " + DataBaseTable
   command = command + " SET "+Column_1+"='"+ Col1_Data +"',"+Column_2+"='"+ Col2_Data +"'"
   command = command + " WHERE Id='"+Id_Number+"';"
   command = command + "COMMIT;"
   LDDataBase.Command(database,command)
   GetDBData()
EndSub 'DataToDatabase
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine DelRecord
'
' Get Id of the selected Listview line
' Delete Record of this Id from database
' Reload database in Listview and Array
'______________________________________________________________________
Sub DelRecord
  IF VarListViewClicked = T Then
   Id_Number_start = Text.GetIndexOf(DB_Data[LineSelect],"Id=")
   Id_Number_end   = Text.GetIndexOf(DB_Data[LineSelect],";")
   Id_Number       = Text.GetSubText(DB_Data[LineSelect],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
   command = "BEGIN TRANSACTION;"
   command = command + "DELETE FROM " + DataBaseTable
   command = command + " WHERE Id='"+Id_Number+"';"
   command = command + "COMMIT;"
   LDDataBase.Command(database,command)
   GetDBData()
  EndIf
  VarListViewClicked = F
EndSub 'DelRecord
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine EditRecord
'
' Set Edit_Mode = "Update"
' Get Id of the selected Listview line
' Copy Record of this Id from database to InputArray
' ---->Update Line in database via "Save"
' Reload database in Listview and Array
'______________________________________________________________________
Sub EditRecord
  Edit_Mode = "Update"
  IF VarListViewClicked = T Then
   Id_Number_start = Text.GetIndexOf(DB_Data[LineSelect],"Id=")
   Id_Number_end   = Text.GetIndexOf(DB_Data[LineSelect],";")
   Id_Number       = Text.GetSubText(DB_Data[LineSelect],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
   Col1_Data = Text.GetSubText(DB_Data[LineSelect], Text.GetIndexOf(DB_Data[LineSelect],Column_1)+Text.GetLength(Column_1)+1,Text.GetIndexOf(DB_Data[LineSelect],Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_1)-Text.GetLength(Column_1)-2)
   Col2_Data = Text.GetSubText(DB_Data[LineSelect],Text.GetIndexOf(DB_Data[LineSelect],Column_2)+Text.GetLength(Column_2)+1,Text.GetLength(DB_Data[LineSelect])-Text.GetLength(Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_2)-1)
   Arrdata[VarNumFirstName] = Col1_Data
   Arrdata[VarNumLastName] = Col2_Data
   Controls.SetTextBoxText(ArrTextBox[VarNumFirstName], ArrData[VarNumFirstName])
   Controls.SetTextBoxText(ArrTextBox[VarNumLastName], ArrData[VarNumLastName])
   Controls.ShowControl(ArrTextBox[VarNumFirstName])
   Controls.ShowControl(ArrTextBox[VarNumLastName])
  EndIf
  VarListViewClicked = F
EndSub 'EditRecord
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine RecordUp
'
' Get Id of the selected Listview line and check limits
' Insert Record Data of this id to one row upwards in database
' Insert Record Data of this id minus one row to id in database
' Reload database in Listview and Array
'______________________________________________________________________
Sub RecordUp
 if LineSelect > 1  Then
  Lineup= LineSelect - 1
  Id_Number_start = Text.GetIndexOf(DB_Data[Lineup],"Id=")
  Id_Number_end   = Text.GetIndexOf(DB_Data[Lineup],";")
  Id_Number       = Text.GetSubText(DB_Data[Lineup],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
  Col1_Data = Text.GetSubText(DB_Data[LineSelect], Text.GetIndexOf(DB_Data[LineSelect],Column_1)+Text.GetLength(Column_1)+1,Text.GetIndexOf(DB_Data[LineSelect],Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_1)-Text.GetLength(Column_1)-2)
  Col2_Data = Text.GetSubText(DB_Data[LineSelect],Text.GetIndexOf(DB_Data[LineSelect],Column_2)+Text.GetLength(Column_2)+1,Text.GetLength(DB_Data[LineSelect])-Text.GetLength(Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_2)-1)
  Col1_Data = LDText.Replace(Col1_Data, "'", "''")
  Col2_Data = LDText.Replace(Col2_Data, "'", "''")
  command = "BEGIN TRANSACTION;"
  command = command + "UPDATE " + DataBaseTable
  command = command + " SET "+Column_1+"='"+ Col1_Data +"',"+Column_2+"='"+ Col2_Data +"'"
  command = command + " WHERE Id='"+Id_Number+"';"
  command = command + "COMMIT;"
  LDDataBase.Command(database,command)
  Id_Number_start = Text.GetIndexOf(DB_Data[LineSelect],"Id=")
  Id_Number_end   = Text.GetIndexOf(DB_Data[LineSelect],";")
  Id_Number       = Text.GetSubText(DB_Data[LineSelect],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
  Col1_Data = Text.GetSubText(DB_Data[Lineup], Text.GetIndexOf(DB_Data[Lineup],Column_1)+Text.GetLength(Column_1)+1,Text.GetIndexOf(DB_Data[Lineup],Column_2)-Text.GetIndexOf(DB_Data[Lineup],Column_1)-Text.GetLength(Column_1)-2)
  Col2_Data = Text.GetSubText(DB_Data[Lineup],Text.GetIndexOf(DB_Data[Lineup],Column_2)+Text.GetLength(Column_2)+1,Text.GetLength(DB_Data[Lineup])-Text.GetLength(Column_2)-Text.GetIndexOf(DB_Data[Lineup],Column_2)-1)
  Col1_Data = LDText.Replace(Col1_Data, "'", "''")
  Col2_Data = LDText.Replace(Col2_Data, "'", "''")
  command = "BEGIN TRANSACTION;"
  command = command + "UPDATE " + DataBaseTable
  command = command + " SET "+Column_1+"='"+ Col1_Data +"',"+Column_2+"='"+ Col2_Data +"'"
  command = command + " WHERE Id='"+Id_Number+"';"
  command = command + "COMMIT;"
  LDDataBase.Command(database,command)
  GetDBData()
  LineSelect = Lineup
 Endif
 VarListViewClicked = F
EndSub 'RecordUp
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine RecordDown
'
' Get Id of the selected Listview line and check limits
' Insert Record Data of this id one row to buttom in database
' Insert Record Data of this id plus one row to id in database
' Reload database in Listview and Array
'______________________________________________________________________
Sub RecordDown
 if LineSelect < Array.GetItemCount(DB_Data)  Then
  LineDown= LineSelect + 1
  Id_Number_start = Text.GetIndexOf(DB_Data[LineDown],"Id=")
  Id_Number_end   = Text.GetIndexOf(DB_Data[LineDown],";")
  Id_Number       = Text.GetSubText(DB_Data[LineDown],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
  Col1_Data = Text.GetSubText(DB_Data[LineSelect], Text.GetIndexOf(DB_Data[LineSelect],Column_1)+Text.GetLength(Column_1)+1,Text.GetIndexOf(DB_Data[LineSelect],Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_1)-Text.GetLength(Column_1)-2)
  Col2_Data = Text.GetSubText(DB_Data[LineSelect],Text.GetIndexOf(DB_Data[LineSelect],Column_2)+Text.GetLength(Column_2)+1,Text.GetLength(DB_Data[LineSelect])-Text.GetLength(Column_2)-Text.GetIndexOf(DB_Data[LineSelect],Column_2)-1)
  Col1_Data = LDText.Replace(Col1_Data, "'", "''")
  Col2_Data = LDText.Replace(Col2_Data, "'", "''")
  command = "BEGIN TRANSACTION;"
  command = command + "UPDATE " + DataBaseTable
  command = command + " SET "+Column_1+"='"+ Col1_Data +"',"+Column_2+"='"+ Col2_Data +"'"
  command = command + " WHERE Id='"+Id_Number+"';"
  command = command + "COMMIT;"
  LDDataBase.Command(database,command)
  Id_Number_start = Text.GetIndexOf(DB_Data[LineSelect],"Id=")
  Id_Number_end   = Text.GetIndexOf(DB_Data[LineSelect],";")
  Id_Number       = Text.GetSubText(DB_Data[LineSelect],Id_Number_start+3,Id_Number_end-(Id_Number_start+3))
  Col1_Data = Text.GetSubText(DB_Data[LineDown], Text.GetIndexOf(DB_Data[LineDown],Column_1)+Text.GetLength(Column_1)+1,Text.GetIndexOf(DB_Data[LineDown],Column_2)-Text.GetIndexOf(DB_Data[LineDown],Column_1)-Text.GetLength(Column_1)-2)
  Col2_Data = Text.GetSubText(DB_Data[LineDown],Text.GetIndexOf(DB_Data[LineDown],Column_2)+Text.GetLength(Column_2)+1,Text.GetLength(DB_Data[LineDown])-Text.GetLength(Column_2)-Text.GetIndexOf(DB_Data[LineDown],Column_2)-1)
  Col1_Data = LDText.Replace(Col1_Data, "'", "''")
  Col2_Data = LDText.Replace(Col2_Data, "'", "''")
  command = "BEGIN TRANSACTION;"
  command = command + "UPDATE " + DataBaseTable
  command = command + " SET "+Column_1+"='"+ Col1_Data +"',"+Column_2+"='"+ Col2_Data +"'"
  command = command + " WHERE Id='"+Id_Number+"';"
  command = command + "COMMIT;"
  LDDataBase.Command(database,command)
  GetDBData()
  LineSelect = LineDown
 Endif
VarListViewClicked = F
EndSub 'RecordDown
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine ClearObjects
' Set nothing in the database data shape, in the text box and in the variable for the database data.
'______________________________________________________________________
Sub ClearObjects
  For i = VarNumFirstName to VarNumLastInput
    Shapes.SetText(ArrDataShape[i], "")
    Controls.SetTextBoxText(ArrTextBox[i], "")
    ArrData[i] = ""
  EndFor
EndSub 'ClearObjects
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine GetData
' Copy database data in DataView Array.
'______________________________________________________________________
Sub GetDBData
  If View_Mode = 1 Then
    DB_Data  = LDDataBase.Query(database, "SELECT * FROM "+ DataBaseTable + ";", tdlist, "True")
  Else
    DB_Data  = LDDataBase.Query(database, "SELECT * FROM "+ DataBaseTable + " WHERE "+Column_1+"='"+PreSelect[View_Mode]+"';", tdlist, "True")
  Endif
EndSub 'GetDBData
'______________________________________________________________________
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Event Subroutines
'______________________________________________________________________
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine KeyUp
' By event KeyUP set the event skip to T equal "True"
'______________________________________________________________________
Sub KeyUp
  VarKeyUP = T
EndSub 'KeyUp
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
'Subroutine ButtonClicked
'By event ButtonClicked set the event skip to T equal "True"
'______________________________________________________________________
Sub ButtonClicked
  VarButtonClicked = T
EndSub 'ButtonClicked
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subroutine ListviewSelect
'______________________________________________________________________
Sub ListviewSelect
  VarListViewClicked = T
  LineSelect = LDControls.LastListViewRow
EndSub 'ListviewSelect

'+++++++++++++ Variables & Modes & Object Settings & DataBase +++++++++++++++++++
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Initialisation
'______________________________________________________________________
Sub Initialisation
  GraphicsWindow.BrushColor       =  "Black" '
  GraphicsWindow.Width            =  600
  GraphicsWindow.Height           =  400
  GraphicsWindow.FontSize         =   12

' The following line could be harmful and has been automatically commented.
' tmpFile = File.GetTemporaryFilePath()
  imageURL = Flickr.GetPictureOfMoment()
  LDNetwork.DownloadFile(tmpFile,imageURL)
  Hintergrund = ImageList.LoadImage(tmpFile)
' The following line could be harmful and has been automatically commented.
' File.DeleteFile(tmpFile)
  'Hintergrund = ImageList.LoadImage(Flickr.GetPictureOfMoment())
  GraphicsWindow.DrawResizedImage(Hintergrund,0,0,GraphicsWindow.Width,GraphicsWindow.Height)

  'TextWindow.WriteLine( "Width : " + Desktop.Width )
  'TextWindow.WriteLine( "Height: " + Desktop.Height )

  GraphicsWindow.Left = Desktop.Width  - GraphicsWindow.Width  - 20
  GraphicsWindow.Top  = Desktop.Height - GraphicsWindow.Height - 80

'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Program modes
'______________________________________________________________________
  Edit_Mode = "Insert"
  View_Mode = 1              ' 1= ALL 2-10=PreSelect[2..10]
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Variables
'______________________________________________________________________
' Boolean
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  T = "True"
  F = "False"
'______________________________________________________________________
' Program controls
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  VarEndOfProgram = F
  VarButtonClicked = F
  VarListviewClicked = F
  VarKeyUP = F
  VarNumInputIndex = 1
'______________________________________________________________________
' Variable Input
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  VarNumFirstName = 1
  VarNumLastName =  2
  VarNumLastInput = 2
  VarNumTabText =   70
'______________________________________________________________________
' Variable Button
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  VarNumNextField = 1
  VarNumSave      = 2
  VarNumExit      = 3
  VarNumDel       = 4
  VarNumUp        = 5
  VarNumDown      = 6
  VarNumEdit      = 7
  VarNumDesign    = 8
  VarLastButton   = 8
'______________________________________________________________________
' Array
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  'Position on Desktop
  VarXPositionShape[VarNumFirstName] = 15
  VarYPositionShape[VarNumFirstName] = 16
  VarXPositionShape[VarNumLastName]  = 135
  VarYPositionShape[VarNumLastName]  = 16

  VarXPositionButton[VarNumNextField] = 10
  VarXPositionButton[VarNumSave]      = 445
  VarXPositionButton[VarNumExit]      = 445
  VarXPositionButton[VarNumDel]       = 10
  VarXPositionButton[VarNumUp]        = 157
  VarXPositionButton[VarNumDown]      = 130
  VarXPositionButton[VarNumEdit]      = 75
  VarXPositionButton[VarNumDesign]    = 375

  VarYPositionButton[VarNumNextField] = 10
  VarYPositionButton[VarNumSave]      = 10
  VarYPositionButton[VarNumExit]      = 280
  VarYPositionButton[VarNumDel]       = 280
  VarYPositionButton[VarNumUp]        = 280
  VarYPositionButton[VarNumDown]      = 280
  VarYPositionButton[VarNumEdit]      = 280
  VarYPositionButton[VarNumDesign]    = 280
'______________________________________________________________________
' Data
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  ArrData[VarNumFirstName] = ""
  ArrData[VarNumLastName] = ""
'______________________________________________________________________
' Listview & DB_Data
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Id_Number = 0
  LineSelect = 0
'______________________________________________________________________
' Button Text
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  ArrInputText[VarNumFirstName] = "First name"
  ArrInputText[VarNumLastName]  = "Last name"

  ArrTextButton[VarNumNextField]  = "Next"
  ArrTextButton[VarNumSave]       = "Save"
  ArrTextButton[VarNumExit]       = " Exit "
  ArrTextButton[VarNumDel]        = "Delete"
  ArrTextButton[VarNumUp]         = " A "
  ArrTextButton[VarNumDown]       = " V "
  ArrTextButton[VarNumEdit]       = " Edit "
  ArrTextButton[VarNumDesign]     = "Design"
'______________________________________________________________________
  'Shapes, TextBoxes and the array with the Database data
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  For i = VarNumFirstName To VarNumLastInput
    'Set a new shape with database data and fill it with nothing.
    ArrDataShape[i] = Shapes.AddText("")
    'Hide the database data shape
    Shapes.HideShape(ArrDataShape[i])
    'Set the shape to her position
    Shapes.Move(ArrDataShape[i], VarXPositionShape[i]+VarNumTabText, VarYPositionShape[i])
    'Set a new text box on his position.
    ArrTextBox[i] = Controls.AddTextBox(VarXPositionShape[i]+VarNumTabText-6, VarYPositionShape[i]-3)
    'Hide the text box.
    Controls.HideControl(ArrTextBox[i])
  EndFor

  Controls.SetSize(ArrTextBox[1], 100,22)
  Controls.SetSize(ArrTextBox[2], 230,22)

  MessageShape = Shapes.AddText("")
  Shapes.HideShape(MessageShape)
  Shapes.Move(MessageShape, 5, GraphicsWindow.Height - 30)
  '______________________________________________________________________
  ' Buttons
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  For i = VarNumNextField To VarLastButton
    'Set a new button on his position
    ArrButton[i] = Controls.AddButton(ArrTextButton[i], VarXPositionButton[i], VarYPositionButton[i] )
    LDShapes.BrushColour(ArrButton[i], "Transparent")
  EndFor

  ArrButton[VarLastButton + 1] = Controls.AddButton(" All ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 1], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 1], 510, 10+35*(1-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 1],80)

  ArrButton[VarLastButton + 2] = Controls.AddButton(" Organize",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 2], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 2], 510, 10+35*(2-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 2],80)

  ArrButton[VarLastButton + 3] = Controls.AddButton(" Fitness ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 3], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 3], 510, 10+35*(3-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 3],80)

  ArrButton[VarLastButton + 4] = Controls.AddButton(" Relax ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 4], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 4], 510, 10+35*(4-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 4],80)

  ArrButton[VarLastButton + 5] = Controls.AddButton(" Family ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 5], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 5], 510, 10+35*(5-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 5],80)

  ArrButton[VarLastButton + 6] = Controls.AddButton("Inventory",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 6], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 6], 510, 10+35*(6-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 6],80)

  ArrButton[VarLastButton + 7] = Controls.AddButton(" Job ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 7], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 7], 510, 10+35*(7-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 7],80)

  ArrButton[VarLastButton + 8] = Controls.AddButton(" Finance ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 8], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 8], 510, 10+35*(8-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 8],80)

  ArrButton[VarLastButton + 9] = Controls.AddButton(" Study ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 9], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 9], 510, 10+35*(9-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 9],80)

  ArrButton[VarLastButton + 10] = Controls.AddButton(" Projects ",0,0)
  LDShapes.BrushColour(ArrButton[VarLastButton + 10], "Transparent")
  Shapes.Move(ArrButton[VarLastButton + 10], 510, 10+35*(10-1))
  Shapes.SetOpacity(ArrButton[VarLastButton + 10],90)

  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  ' Brush PreSelectButton with nice colors
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  BrushPreSelectButtons()
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  ' Extract Button Text as PreSelectionName for Database Column 1
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  For i = 1 To 10
     PreSelect[i] = LDText.Trim(Controls.GetButtonCaption(ArrButton[VarlastButton + i ]))
     'TextWindow.WriteLine("Pre_Button:" + PreSelect[i])
  endfor
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  ' Database
  '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  'Create a new list view
  tdlist=LDControls.AddListView(480,200,"")
  Controls.Move(tdlist, 10, 45)
  'Set a fullpath for a database
  datFile = Program.Directory + "\" + DataBaseFile
  GraphicsWindow.DrawText(5,GraphicsWindow.Height-15,datFile)
  ' Is it a new database, so create it with a new table and table fields. Other wise open it.
' The following line could be harmful and has been automatically commented.
' If LDFile.Exists(datFile) = F Then
    database = LDDataBase.ConnectSQLite(datFile)
    command = "BEGIN TRANSACTION;"
    'The databse table has the fields Id with the field definition PRIMARY KEY and Columns with the field defination TEXT.
    command = command + "CREATE TABLE " + DataBaseTable + "(Id INTEGER PRIMARY KEY, " + Column_1 + " TEXT," + Column_2 + " TEXT);"
    command = command + "COMMIT;"
    LDDataBase.Command(database,command)
  Else
    database = LDDataBase.ConnectSQLite(datFile)
    GetDBData()
    LDFocus.SetFocus(tdlist)
  EndIf
EndSub 'Initialisation

'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' Subprogram BrushPreSelectButtons
'______________________________________________________________________
Sub BrushPreSelectButtons

  gradient[1] = "Gray"
  gradient[2] = "White"
  gradient[3] = "Gray"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(1-1),90,28,5)

  gradient[1] = "Khaki"
  gradient[2] = "Yellow"
  gradient[3] = "Goldenrod"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(2-1),90,28,5)

  gradient[1] = "Sienna"
  gradient[2] = "Gold"
  gradient[3] = "chocolate"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(3-1),90,28,5)

  gradient[1] = "Purple"
  gradient[2] = "Lavender"
  gradient[3] = "Blueviolet"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(4-1),90,28,5)

  gradient[1] = "Red"
  gradient[2] = "Pink"
  gradient[3] = "Orangered"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(5-1),90,28,5)

  gradient[1] = "Red"
  gradient[2] = "Tomato"
  gradient[3] = "Gold"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(6-1),90,28,5)

  gradient[1] = "Green"
  gradient[2] = "Lightgreen"
  gradient[3] = "Forestgreen"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(7-1),90,28,5)

  gradient[1] = "Silver"
  gradient[2] = "WhiteSmoke"
  gradient[3] = "Lightgray"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(8-1),90,28,5)

  gradient[1] = "Blue"
  gradient[2] = "LightBlue"
  gradient[3] = "DeepSkyBlue"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(9-1),90,28,5)

  gradient[1] = "DarkViolet"
  gradient[2] = "CornFlowerBlue"
  gradient[3] = "DarkOrchid"
  brush = LDShapes.BrushGradient(gradient,"V")
  LDShapes.BrushRoundedRectangle(brush,500,9+35*(10-1),90,28,5)

EndSub 'BrushPreSelectButtons


Copyright (c) Microsoft Corporation. All rights reserved.