Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
The file I'm working with has ~31,000 records in this format:
State,City,Area Code,Number AB,Calgary,403,537-0222 AB,Edmonton,780,424-4785 AK,Anchorage,907,274-9832 AR,Arkadelphia,870,568-0005 . . .I'm attempting to search for the area code and get the entire record line that corresponds to the area code searched for and then allow the user to select the entire record (in an AskList box for example).
Thanks in advance for any help...
AddExtender("Laffd34i.dll") ;***************************************************** ;** Example Database ;***************************************************** filename = "C:\Temp\Laffdb Sample\Address.txt" delimiter = "," If !FileExist(filename) str = "Make sure the database exists before attempting to run this example." str2 = "See the dbOpen example in this help file, it will create the example database for you." Message("Database doesn't exist", StrCat(str, @CRLF,str2)) Exit EndIf ;***************************************************** ;** dbOpen - open the test database ;***************************************************** bCreateOK = 0 ;File MUST exist model = 2 ;Traditional numcols = -1 ;Number of columns match first line, names them, starts reading at 2nd line format = 0 optionstring = "" handle = dbOpen (filename, bCreateOK, model, numcols, format, delimiter, optionstring) If handle == @LAFFDBERROR err = dbGetLastError() Message("Error Opening the database specified", err) Exit EndIf record = -1 ;search entire database flags = 1|4; fixed record number column = "Area Code"; column nmae to search in findvalue = "907" matchcase = 0 ;NOT case sensitive reclist = "" ;***************************************************** ;** dbFindRecord ;***************************************************** While @TRUE record = dbFindRecord(handle,record,flags,column,findvalue,matchcase) If record == @LAFFDBERROR err = dbGetLastError() Message("Error finding record", err) Exit EndIf If record == -1 Then Break ;No matching record found ret = dbBindCol(handle, 1, "State") If ret == @LAFFDBERROR err = dbGetLastError() Message("Error Binding the column", err) EndIf ret = dbBindCol(handle, 2, "City") If ret == @LAFFDBERROR err = dbGetLastError() Message("Error Binding the column", err) EndIf ret = dbBindCol(handle, 3, "AreaCode") If ret == @LAFFDBERROR err = dbGetLastError() Message("Error Binding the column", err) EndIf ret = dbBindCol(handle, 4, "Number") If ret == @LAFFDBERROR err = dbGetLastError() Message("Error Binding the column", err) EndIf ret = dbGetEntireRecord(handle, record, 1) If ret == @LAFFDBERROR err = dbGetLastError() Message("Error getting entire record", err) EndIf reclist = StrCat(reclist,@TAB,State,',',City,',',AreaCode,',',Number) EndWhile AskItemlist("Records that contain the area code", StrTrim(reclist), @TAB, @UNSORTED, @SINGLE) ;***************************************************** ;** Closes Database handle ;***************************************************** ret = dbClose(handle) If ret == @LAFFDBERROR err = dbGetLastError() Message("Error Closing the database", err) EndIf Exit
Article ID: W16832
File Created: 2007:07:03:14:26:28
Last Updated: 2007:07:03:14:26:28