none
LitDev instructions that do not work

    Question

  • I am building a financial program with Small Basic and I use the LitDev extensions. But some instructions insist on not working, for example: LDControls. DataViewSetRow

    The extract from my program has the following commands to insert data previously loaded:



      Table = LDControls. AddDataView (500, 300, HeadTab)
        Shapes. Move (Table, 500, 40)
        If TamFile [File] > 1 Then
          For i = 2 To TamFile [File]
            For j = 1 To Columns
              Fres [j] = FileDat [Arq] [i] [j]
            EndFor
            LDControls. DataViewSetRow (Table, i - 1, Fres)
          EndFor
        EndIf

    It turns out that nothing appears in the table.

    Where am I going wrong?

    Friday, April 07, 2017 3:16 AM

Answers

  • OK, I did look at your code - the issue is that you are not creating tables you think.

    Try - this:

    For i = 1 To 3   ' Number of Files : will be NumArq
      HeadTab = ""
      If i = 1 Then

    There are still issues with your code but this should get you going.

    By the way, I diagnosed by simplifying and adding Writelines in the code - the reason to ask for this is that this is the way to solve issues so you can do it - no need for folders and files to see the issue - it failed with:

        Controls.ShowControl(Table[Arq])
        TextWindow.WriteLine(TamFile[Arq])
        If TamFile[Arq] > 1 Then   
          For i = 2 To TamFile[Arq]
            For j = 1 To Col
              Fres[j] = FileDat[Arq][i][j]
              TextWindow.WriteLine(Fres[j])
            EndFor
            TextWindow.WriteLine(i+" == "+Fres)
            LDControls.DataViewSetRow(Table[Arq], i - 1, Fres)
          EndFor
        EndIf
        
        TextWindow.WriteLine(Arq)
        TextWindow.WriteLine(Table[Arq])
        LDControls.DataViewSetRow(Table[Arq], 1, "1=A;2=B;3=C;4=D;5=E;")
    
       If Array.GetItemCount(HeadTab) > Col Then        
          For i = Col + 1 To 7                          
            'LDControls.DataViewColumnVisible(Table[Arq], i, "False")
          EndFor
        EndIf 
    
        TabLevel = 1
      EndIf

    The tables have 7 columns, hidden columns still exist!  Test with this simplified version, commenting out bits...

    For i = 1 To 7
      HeadTab[i] = "Coll"
    EndFor

    For i = 1 To 3   ' Number of Files : will be NumArq
      'HeadTab = ""
      If i = 1 Then
        HeadTab[1] = "ORIGin"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "DESTINY"
        HeadTab[5] = "WHO"
      ElseIf i = 2 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      ElseIf i = 3 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      EndIf
      Table[i] = LDControls.AddDataView(500, 300, HeadTab)
      Controls.HideControl(Table[i])
    EndFor  

    Col = 5
    For i = Col + 1 To 7                          
      'LDControls.DataViewColumnVisible(Table[1], i, "False")
    EndFor
    Controls.ShowControl(Table[1])
    LDControls.DataViewSetRow(Table[1], 1, "1=A;2=B;3=C;4=D;5=E;")

    Perhaps this fixes it, but maybe better to refactor a bit more:

          For i = 2 To TamFile[Arq]
            For j = 1 To Col
              Fres[j] = FileDat[Arq][i][j]
            EndFor
            For j = Col+1 To 7
              Fres[j] = " "
            EndFor
            LDControls.DataViewSetRow(Table[Arq], i - 1, Fres)
          EndFor
    




    Saturday, April 08, 2017 9:02 AM
    Moderator

All replies

  • Is it possible that some of your arrays are not filled with rigth values?

    If I run the following extract of your extract, it works:

    HeadTab="1=head1;2=head2"
    GraphicsWindow.Width=1200
    Table = LDControls. AddDataView (500, 300, HeadTab)
    Shapes. Move (Table, 50, 40)
    fres="1=one;2=two"
    For i=1 To 3
      LDControls. DataViewSetRow (Table,  i, Fres)
    EndFor
    


    Jan [ WhTurner ] The Netherlands

    Friday, April 07, 2017 9:52 AM
    Answerer
  • Thank you WhTurner for responding.

    Arrays are actually filled with varying values ​​such as: names, dates, and integer numbers, but perfectly matched to the size of the Table.

    I understand that the recommendation of the 'AddDataView' command is followed by:

    'This control always appears on top of all other objects in the GraphicsWindow'

    However, before calling this 'DataView' I call other controls, such as: Textbox and control buttons, of course after setting up GraphicsWindow at the start of the program.

    Using this extract, it did not work either. I do not know if it's any limitation on the instruction library.

    Do you have any idea?

    Friday, April 07, 2017 3:28 PM
  • I have no experiance with the DataView commands. One thing you should check:

    There are three versions of the LitDev extension: for Small Basic versions 1.0 1.1 and 1.2. If you are using the wrong one for your version of SB, some things won't work.

    see also http://litdev.co.uk/


    Jan [ WhTurner ] The Netherlands


    Friday, April 07, 2017 4:19 PM
    Answerer
  • Do any LD commands work or appear in SB IDE intellisense, if not follow instruction to get the right version and possibly unblock dll.  Details on the link Jan suggested.
    Friday, April 07, 2017 5:23 PM
    Moderator
  • Ok. Thank you for the suggestions.

    Answering the above questions, SB and LitDev versions are compatible, both v 1.2.

    The LitDev Dlls are unblocked and appear in SB IDE intellisense.

    I would simply appreciate it if you would let me know the reasons that make the LDControls.DataViewSetRow command result 'False'.

    The DataView appears but the values, after insert it, not.

    Friday, April 07, 2017 8:10 PM
  • would simply appreciate it if you would let me know the reasons that make the LDControls.DataViewSetRow command result 'False'.

    The False return is a failure of some kind - could be anything depening on your code.

    It is open source so you could check the code, but hard to say without an example that fails...

    (any number of reasons an internal .Net exception could be thrown resulting in a "False" return).

    To be more helpful a simple sample we can run that fails and we can work with - please?

    Bascally can't fix or explain an issue we can't reproduce.

    Friday, April 07, 2017 10:37 PM
    Moderator
  • Very well

    I transcribe below a simplified extract of the code. To work you should create a directory called 'Data' in the place where to execute this code. Under 'Date' create a file through Notepad with the name ARRM. cap with 3 lines each containing 5 information separated by '-' even at the end. This information is: WORK-DATE-VALUE-DESTINATION-CLIENT-

    X1 = 1024 ' 64 X 16
    Y1 = 576  '64 X 9
    k = 0

    Clean = 0  
    Clos = 0
    TabLevel = 0
    ViewDat = 0  
    ViewCard = 0
    NumArq = 1

    FileDat[1][1][1] = "ARRM"

    For i = 1 To 7
      HeadTab[i] = "Coll"
    EndFor

    GraphicsWindow.BackgroundColor = "#FFFFE0"
    GraphicsWindow.BrushColor = "Black"
    GraphicsWindow.FontBold = "True"
    GraphicsWindow.FontName = "Arial"
    GraphicsWindow.FontSize = 12
    GraphicsWindow.CanResize = "False"
    GraphicsWindow.Title = "CAPTION"
    LDGraphicsWindow.ExitButtonMode(GraphicsWindow.Title,"Disabled")
    GraphicsWindow . Width = X1
    GraphicsWindow . Height = Y1
    GraphicsWindow.Show()

    Dway = Program.Directory
    Getpath = File.GetDirectories(Dway)
    n = Array.GetItemCount(Getpath)
    For i = 1 to n
      If Text.IsSubText(Getpath[i], "Date") = "True" Then
        Dat = Getpath[i]
      EndIf
    EndFor

    ' Here I Get NumArq from another Routine

    For i = 1 To 3   ' Number of Files : will be NumArq
      If i = 1 Then
        HeadTab[1] = "ORIGin"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "DESTINY"
        HeadTab[5] = "WHO"
      ElseIf i = 2 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      ElseIf i = 3 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      EndIf
      Table[i] = LDControls.AddDataView(500, 300, HeadTab)
      Controls.Move(Table[i], 500, 40)
      Controls.HideControl(Table[i])
    EndFor  

    GraphicsWindow.BrushColor = "Black"
    MenuList["File"]="Main"
    MenuList["User"]="File"
    MenuList["Exit"]="File"
    MenuList["Edit"]="Main"
    MenuList["Copy"]="Edit"
    MenuList["Change"]="Main"
    MenuList["Fill"]="Change"
    MenuList["Close Table"] = "Change"
    MenuList["Verify"]="Main"
    MenuList["Help"]="Main"
    MenuList["About"]="Help"
    MenuList["Manual"]= "Help"
    Menu = LDControls.AddMenu(360,20,MenuList,"","")

    LDShapes.BrushColour(Menu,"#FFE4B5")
    LDControls.MenuBackground(Menu,"#FFE4B5")
    LDControls.MenuClicked = OnMenuClicked
    Controls.ButtonClicked =  OnClickButton
    LDControls.DataViewSelectionChanged = OnSelectView
    LDControls.DataViewCellValueChanged = OnTableClicked
    LDControls.ContextMenuClicked = OnActionRow

    INIT()

    While k=0
      Program.Delay(1000)
    Endwhile

    Sub OnMenuClicked
      Title = LDControls.LastMenuItem
      If Title = "User" Then
        'Pass = LDControls.AddPasswordBox(120, 20, 30)
        'Controls.Move(Pass, 145, 20)
      ElseIf Title = "Exit" then
        Program.End()
      ElseIf Title = "Copy" Then
        TextWindow.WriteLine("Wait !!")
        Program.Delay(1500)
        TextWindow.Hide()
      ElseIf Title = "Fill" Then
        If Clos = 1 Then
          ' Message
        Else
          Choice()
        EndIf
      ElseIf Title = "Close Table" Then
        If Clos = 0 Then
          ' Message
        Else  
          Clos = 2
          OnTableClicked()
        EndIf  
      EndIf
    EndSub

    Sub INIT  
      For i = 1 To NumArq
        TamFile[i] = LDFile.Length(Dat + "/" + FileDat[i][1][1] + ".cap")
        FixFile[i] = TamFile[i]
        If TamFile[i] >  1 Then
          Clean = 1
          For j = 1 To FixFile[i]            
            Linha = File.ReadLine(Dat + "/" + FileDat[i][1][1] + ".cap", j)
            If Text.GetLength(Linha) = 0 Then
              TamFile[i] = TamFile[i] -1
            EndIf
          EndFor
          FixFile[i] = TamFile[i]
          GETDAT()
        EndIf
      EndFor
      If Clean = 0 Then
        'Message
      Else
        'Message
      EndIf
    EndSub

    Sub GETDAT  ' Get data from files
      lido = ""
      cota = ""
      For b = 2 to TamFile[i]
        lido = File.ReadLine(Dat + "/" + FileDat[i][1][1] + ".cap", b)
        unid = ""
        cart = ""
        j = 0
        c = Text.GetLength(lido)
        For a = 1 To c
          cart = Text.GetSubText(lido, a, 1)
          If cart = "-" Then
            j = j + 1
            FileDat[i][b][j] = unid
            unid = ""
          Else
            unid = Text.Append(unid,cart)
          EndIf
        EndFor
      EndFor
    EndSub

    Sub Choice  
      Esc[1] = Controls.AddButton("Income And Receipts", 145, 40)
      Controls.SetSize(Esc[i], 210, 40)
      LDControls.SetButtonStyle(Esc[11],"#483D8B","#6A5ACD","#66CDAA","#000000","#800000","#8B4513",9,"True")
    EndSub

    Sub OnClickButton
      If Clos = 1 Then
        ' message
      Else
        Clos = 1
        Butao = Controls.LastClickedButton
        If Butao = Esc[1] Then
          Arq = 1
          Col = 5
        EndIf
        Controls.ShowControl(Table[Arq])
        If TamFile[Arq] > 1 Then   
          For i = 2 To TamFile[Arq]
            For j = 1 To Col
              Fres[j] = FileDat[Arq][i][j]
            EndFor
            LDControls.DataViewSetRow(Table[Arq], i - 1, Fres)
          EndFor
        EndIf

       If Array.GetItemCount(HeadTab) > Col Then        
          For i = Col + 1 To 7                          
            LDControls.DataViewColumnVisible(Table[Arq], i, "False")
          EndFor
        EndIf 

        TabLevel = 1
      EndIf
    EndSub

    Sub OnActionRow
     
    EndSub

    Sub OnSelectView
     
    EndSub

    Sub OnTableClicked
    EndSub

    To work click on the CHANGE menu and then on FILL.

    To exit click FILE and then EXIT






    • Edited by Jackson Mello Saturday, April 08, 2017 12:38 AM wrong words
    Saturday, April 08, 2017 12:25 AM
  • Am I right that Jan's sample doesn't work for you - please verify.

    1] If it doesn't work then something specific to your setup.

    2] If it does work, then it is probably something in your code - so can you do a short sample that fails and doesn't require folders and files to be set up - i.e we can be certain to run exactly the same thing that fails.

    Saturday, April 08, 2017 8:24 AM
    Moderator
  • OK, I did look at your code - the issue is that you are not creating tables you think.

    Try - this:

    For i = 1 To 3   ' Number of Files : will be NumArq
      HeadTab = ""
      If i = 1 Then

    There are still issues with your code but this should get you going.

    By the way, I diagnosed by simplifying and adding Writelines in the code - the reason to ask for this is that this is the way to solve issues so you can do it - no need for folders and files to see the issue - it failed with:

        Controls.ShowControl(Table[Arq])
        TextWindow.WriteLine(TamFile[Arq])
        If TamFile[Arq] > 1 Then   
          For i = 2 To TamFile[Arq]
            For j = 1 To Col
              Fres[j] = FileDat[Arq][i][j]
              TextWindow.WriteLine(Fres[j])
            EndFor
            TextWindow.WriteLine(i+" == "+Fres)
            LDControls.DataViewSetRow(Table[Arq], i - 1, Fres)
          EndFor
        EndIf
        
        TextWindow.WriteLine(Arq)
        TextWindow.WriteLine(Table[Arq])
        LDControls.DataViewSetRow(Table[Arq], 1, "1=A;2=B;3=C;4=D;5=E;")
    
       If Array.GetItemCount(HeadTab) > Col Then        
          For i = Col + 1 To 7                          
            'LDControls.DataViewColumnVisible(Table[Arq], i, "False")
          EndFor
        EndIf 
    
        TabLevel = 1
      EndIf

    The tables have 7 columns, hidden columns still exist!  Test with this simplified version, commenting out bits...

    For i = 1 To 7
      HeadTab[i] = "Coll"
    EndFor

    For i = 1 To 3   ' Number of Files : will be NumArq
      'HeadTab = ""
      If i = 1 Then
        HeadTab[1] = "ORIGin"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "DESTINY"
        HeadTab[5] = "WHO"
      ElseIf i = 2 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      ElseIf i = 3 Then
        HeadTab[1] = "ITEM"
        HeadTab[2] = "DATE"
        HeadTab[3] = "VALUE"
        HeadTab[4] = "# DOC"
        HeadTab[5] = "ORIGIN"
        HeadTab[6] = "CLIENT"
      EndIf
      Table[i] = LDControls.AddDataView(500, 300, HeadTab)
      Controls.HideControl(Table[i])
    EndFor  

    Col = 5
    For i = Col + 1 To 7                          
      'LDControls.DataViewColumnVisible(Table[1], i, "False")
    EndFor
    Controls.ShowControl(Table[1])
    LDControls.DataViewSetRow(Table[1], 1, "1=A;2=B;3=C;4=D;5=E;")

    Perhaps this fixes it, but maybe better to refactor a bit more:

          For i = 2 To TamFile[Arq]
            For j = 1 To Col
              Fres[j] = FileDat[Arq][i][j]
            EndFor
            For j = Col+1 To 7
              Fres[j] = " "
            EndFor
            LDControls.DataViewSetRow(Table[Arq], i - 1, Fres)
          EndFor
    




    Saturday, April 08, 2017 9:02 AM
    Moderator
  • Thank you my friend for your attention. Actually the idea of ​​'emptying' the values ​​in the invisible columns is great. I'll test it on my code. For j = Col + 1 to 7 Fres [j] = '' EndFor Interestingly, the DataView was working in the original mode. It was to enter data, or to see the data. Suddenly he stopped showing the data on the DataView without making any changes to the code. It simply stopped working. I'll go back and say if it worked.
    Saturday, April 08, 2017 3:21 PM
  • Excellent solution. My thanks for the light in my mind.

    The simple and only alteration did enormous difference.

    For i = 1 To 3   ' Number of Files : will be NumArq
      HeadTab = ""
      If i = 1 Then

    Removing the initial HeadTab setting meant that each Table [i] had its own configuration, dispensing to hide the false columns and adapt the data to their respective table.

    I believe that this limitation is exclusive, but to be able to have the guidance of masters as you are gratifying.

    Thank you very much for your great help.

    Sunday, April 09, 2017 9:04 PM