locked
Help Combi Search don't function RRS feed

  • Question

  • In the program (show DHM036) are 3 Textboxes to search in the arrays. If search by one array it funktion. By combi search 1, 2 or 3 Textboxes filled and press the Button "Kombisuche" the search is empty. I don't why?

    Please help me.

     

    Best Regards Martin

    Wednesday, June 19, 2013 3:39 PM

Answers

  • Here is a sample of the way databases like this may be tackled.

    TMG571

    • Marked as answer by martmen Sunday, June 23, 2013 4:22 AM
    Saturday, June 22, 2013 1:26 PM

All replies

  • Hi,

    2 bugs

    1] You shouldn't delete the array LDArray.Delete(A_Result)- this removes it from memory so it can't be used.

    2] There is a bug with LDArray.Copy - now fixed and uploaded.

    By the way, quite hard to debug - lots of TextWindow.Writeline needed.

    I think it still doesn't work for multiple selections e.g. Frau + Heidi - you may need to rethink the logic for this.

    EDIT

    The reason for the multiple selections failure is that you are using SB array notation [] for some LDArrays, use LDArray.GetValue.
    Wednesday, June 19, 2013 6:15 PM
  • New Version its run i hope so. Show DHN122.  Have you an idea to do something better, tell me.


    Best Regards Martin


    • Edited by martmen Saturday, June 22, 2013 5:26 AM kjmkj
    Saturday, June 22, 2013 5:25 AM
  • Can't really suggest a simple fix to simplify it.  The general principal would be to carefully decide on which data variables you are going to use and what operations to do on them.  One problem I found debugging it was the copying and moving of data from one variable to another - perhaps there are too many small subroutines, but this is all subjective.  Apart from these it is well laid out and works well.

    You should also set Result = "" somewhere near the start of ManageCombiSearchAndShow to handle a second search.

    The unresponsiveness of the buttons is due to the Sub ManageInput which keeps moving focus.  Also LDFocus.GetFocus() may be a button, not a textbox.

    Sub ManageInput
      TB = LDFocus.GetFocus()
      TextWindow.WriteLine(TB)
      If TB <> OldTB Then 
    ...

    We could run this on a timer thread at a lower frequency, but perhaps consider what ManageInput is doing.

    Init()
    
    Timer.Interval = 1000
    Timer.Tick = ManageInput
    
    LoopInputSearch = 1
    While LoopInputSearch = 1
      If OBC = 1 Then
        ManageButton()
      ElseIf OKU = 1 Then 
        ManageKey()
      EndIf 
      Program.Delay(20)
    EndWhile
    Program.End()

    Saturday, June 22, 2013 9:41 AM
  • I have changed somthing and i hope it is simplier to follow the logic. It is a sample to search in an adress table with the address, first name and last name. You can combination the fields over there search in the table. it finds an entry or some entries in the table.

    Is there a trick to do it simply. By 10 search fields in a realy adress table with 10 data fields it is to complicated with the if statements.

    The new version is MCM191.


    Best Regards Martin

    A SQL-Statement ist easy: select tabadress where adress     = inputadress,
                                                                             firstname = inputfirstname,
                                                                             lastname = inputlastname.       :-)

    • Edited by martmen Saturday, June 22, 2013 12:56 PM 00001
    Saturday, June 22, 2013 12:53 PM
  • Is there a trick to do it simply. By 10 search fields in a realy adress table with 10 data fields it is to complicated with the if statements.

    Not really to 'do it simply' since it is getting quite complicated.  But the basic programming principles still apply.

    Use arrays and loops to do repeated things.  So you can loop over all your data fields, see if the user has any data in them and what rows match it. 

    As it gets more complicated it will become harder in Small Basic to manage it in a 'nice' way.  This is when some object orientated (OO) ideas like classes and other constructs available in VB and C# might be worth getting familiar with.

    Saturday, June 22, 2013 1:16 PM
  • Here is a sample of the way databases like this may be tackled.

    TMG571

    • Marked as answer by martmen Sunday, June 23, 2013 4:22 AM
    Saturday, June 22, 2013 1:26 PM
  • Martin,

    I couldn't quite follow your program MCM191 with all the subroutines (result12, result123 etc.)
    so I started from scratch without fancy forms with textboxes and buttons.
    I generated a database with 1000 records with each 10 fields of four characters each.
    The first field contains a recordnumber, the other 9 four random characters each,
    field 2: four random chars from a b and c
    field 3: four random chars from b c end d , etcetera
    The 15 line program to generate the database is FLF595.
    As an example of the contents, the first 5 records are:

    0001 cccb bdbd dcde edef fgge gfhf ghgi iihi ikjj
    0002 babc cddb ddde fddd fegg hhfg ihhi hjjj kkii
    0003 babb bccd cced dfff egfg fhff higi iihh iikj
    0004 babb cccc dcec fffd eeeg fgff hhhh hjhh ijji
    0005 aabb cccc cced fdff gefg hffh gigi jiji jjki

    Then I started on the searchprogram, It can search in from 1 to 3 fields if a certain text 
    is in the database. It is very basic, read the database and carry out one search.
    It is no longer then 50 lines, and is published as MRM410.
    The total time to write both programs was less then two hours.
    The program has to be adapted if the setup of the database is different.


    Jan [ WhTurner ] The Netherlands

    Sunday, June 23, 2013 10:39 AM
    Answerer
  • Hallo Jan,

    mein Programm sucht nach maximal 3 verschiedenen Kriterien (Anrede, Vorname und Nachname). Man kann nach Vorname und Nachname suchen. Man kann aber auch nur einen Teil des Nachnamen eingeben und das Programm findet die entsprechenden Daten.

    Dein Programm versteh ich nicht ganz. Um Daten zu finden muss ich die Satznummer wissen, diese ist mir aber nicht bekannt.

     


    Best Regards Martin

    Tuesday, June 25, 2013 8:14 AM
  • Hallo Martin,

    My German is not so good, I can read it but writing doesn't go well.

    My program asks for fieldnumber. This is not the recordnumber (Satznummer) , but the fieldnumber (number of the field in a record). In your program this would be 1 for Anrede, 2 for Vorname and 3 for Nachname.

    My program is a very basic testversion. In the reading of the file it assumes that all 10 fields are 4 characters long. The fields have no name.

    If you made a file with FLF595, and then read with MRM410, you can test e.g. fieldnumber 1 search for "aaaa". You get on average 16 or 17 records.

    You can then test e.g. field 1 aaaa  and field 2 one of the values in the second column after the number e.g. bbbb (or another from this column).

    I hope this clarifies the program a bit.


    Jan [ WhTurner ] The Netherlands

    Tuesday, June 25, 2013 11:22 AM
    Answerer
  • Hallo Jan,

    danke für deine Nachrichten und Programme. Ich bin dabei eine Datenbank in Small Basic zu programmieren. Du kannst Dir mal unter "Small basic problem in my first databease with 2 tables" von mir nachschauen. Bis jetzt hab ich aber nur ein Beispiel mit Adress- und Artikeldaten, die in 2 Tabellen (Dateien) gespeichert werden. Bei größeren Dateien werde ich die extention von LitDev verwenden, da die Verarbeitung von Arrays dort schneller und umfangreicher ist.


    Best Regards Martin

    Tuesday, June 25, 2013 12:16 PM