Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - durgensrun

Pages: [1]
1
QB64 Discussion / Re: search txt file for a certain number
« on: October 28, 2020, 01:53:26 am »
Solved it, for the curious how I did it.
Code: QB64: [Select]
  1.  
  2. show
  3.  
  4. SUB show
  5.     CLS
  6.     OPEN "durgenDB/consumerprofile.dat" FOR INPUT AS #1
  7.     INPUT " Profile number to find  ", searchnumber
  8.     DO UNTIL EOF(1)
  9.         INPUT #1, IDnumber
  10.         IF IDnumber = searchnumber THEN
  11.             INPUT #1, FirstName$
  12.             INPUT #1, LastName$
  13.             INPUT #1, Address1$
  14.             INPUT #1, Address2$
  15.             INPUT #1, City$
  16.             INPUT #1, State$
  17.             INPUT #1, Zip$
  18.             INPUT #1, Phone$
  19.             INPUT #1, Email$
  20.         END IF
  21.     LOOP
  22.     CLOSE #1
  23.     CLS
  24.     LOCATE 2, 10: PRINT "Costumer Profile": PRINT "-----------------------------------------------------------------"
  25.     LOCATE 4, 10: PRINT "Consumer No.: ": LOCATE 4, 22: PRINT searchnumber
  26.     LOCATE 6, 10: PRINT "Name: ": LOCATE 6, 16: PRINT RTRIM$(FirstName$); " "; RTRIM$(LastName$)
  27.     LOCATE 8, 10: PRINT "Mailing Address: ": LOCATE 8, 27: PRINT Address1$
  28.     LOCATE 10, 10: PRINT "Shipping Address: ": LOCATE 10, 28: PRINT Address2$
  29.     LOCATE 12, 10: PRINT "City: ": LOCATE 12, 16: PRINT City$
  30.     LOCATE 14, 10: PRINT "State: ": LOCATE 14, 17: PRINT State$
  31.     LOCATE 16, 10: PRINT "Zip: ": LOCATE 16, 15: PRINT Zip$
  32.     LOCATE 18, 10: PRINT "Phone: ": LOCATE 18, 17: PRINT Phone$
  33.     LOCATE 20, 10: PRINT "E-Mail: ": LOCATE 20, 18: PRINT Email$
  34.  
  35.     DIM hope AS STRING
  36.     hope = UCASE$(hope)
  37.     LOCATE 23, 10: INPUT "View another Y/N ", hope
  38.     IF UCASE$(hope) = "Y" THEN
  39.         show
  40.     ELSE
  41.         END 'menu
  42.     END IF
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  

2
QB64 Discussion / Re: search txt file for a certain number
« on: October 27, 2020, 11:24:12 pm »
I been working on the problem. This is what I have so far. "sub finder" scans the file, when it finds a match it stops and says found it.
"Sub display", reads the 10 variables in the line, and prints them to the screen. The "IDnumber" is always the first variable in the set of 10.
The next problem is how to combine the 2 subs. The sequence I need is, I input an "IDnumber" to search for. Then scans the file. When that number is found.
The program goes and reads in the 10 variables including the "IDnumber" found on that line and prints them on screen.

I am thinking if I count the variables during the search this would give me an address of sorts, then rescan the file counting the variables and stoping the scan -1 prior to the found variable.
Then load in the next 10 variables I need to print.

Code: QB64: [Select]
  1. SUB finder
  2.     CLS
  3.     OPEN "durgenDB/consumerprofile.dat" FOR INPUT AS #1
  4.     INPUT " Profile number to find  ", searchnumber
  5.  
  6.     DO UNTIL EOF(1)
  7.         INPUT #1, IDnumber
  8.         PRINT IDnumber
  9.         IF IDnumber = searchnumber THEN PRINT "found it   ": END
  10.     LOOP
  11.     CLOSE #1
  12.  
  13. SUB display
  14.     OPEN "durgenDB/consumerprofile.dat" FOR INPUT AS #1
  15.     INPUT #1, IDnumber
  16.     INPUT #1, FirstName$
  17.     INPUT #1, LastName$
  18.     INPUT #1, Address1$
  19.     INPUT #1, Address2$
  20.     INPUT #1, City$
  21.     INPUT #1, State$
  22.     INPUT #1, Zip$
  23.     INPUT #1, Phone$
  24.     INPUT #1, Email$
  25.     CLOSE #1
  26.  
  27.     LOCATE 2, 10: PRINT "Costumer Profile": PRINT "-----------------------------------------------------------------"
  28.     LOCATE 4, 10: PRINT "Consumer No.: ": LOCATE 4, 22: PRINT IDnumber
  29.     LOCATE 6, 10: PRINT "Name: ": LOCATE 6, 16: PRINT RTRIM$(FirstName$); " "; RTRIM$(LastName$)
  30.     LOCATE 8, 10: PRINT "Mailing Address: ": LOCATE 8, 27: PRINT RTRIM$(Address1$)
  31.     LOCATE 10, 10: PRINT "Shipping Address: ": LOCATE 10, 28: PRINT "bloop" 'RTRIM$(Adress2$)
  32.     LOCATE 12, 10: PRINT "City: ": LOCATE 12, 16: PRINT City$
  33.     LOCATE 14, 10: PRINT "State: ": LOCATE 14, 17: PRINT State$
  34.     LOCATE 16, 10: PRINT "Zip: ": LOCATE 16, 15: PRINT Zip$
  35.     LOCATE 18, 10: PRINT "Phone: ": LOCATE 18, 17: PRINT Phone$
  36.     LOCATE 20, 10: PRINT "E-Mail: ": LOCATE 20, 18: PRINT Email$

3
QB64 Discussion / Re: search txt file for a certain number
« on: October 26, 2020, 11:15:03 pm »
Long ago I did.

4
QB64 Discussion / Re: search txt file for a certain number
« on: October 26, 2020, 10:55:30 pm »
Hi bplus
It's been 30 years since I made my first program, I am relearning with a special project. I am making a small relational 3-page database.
the text file I posted will hold all the names and addresses and would be added to, so I don't know how many lines will be on it, same with the other 2 text files.

5
QB64 Discussion / Re: search txt file for a certain number
« on: October 26, 2020, 10:24:34 pm »
bplus, I am getting error 52 on line 19, "WHILE NOT EOF(1)"
thanks

6
QB64 Discussion / Re: search txt file for a certain number
« on: October 26, 2020, 10:00:11 pm »
this is what's in the text file, the data in it is only temporary for testing.

Quote
"123456","ZEF                 ","DURGEN              ","MOUNT                ","                         ","REYNO               ","AR","12345","0123456789","moo@zap.com              "
"098765","BOB                 ","MOLE                ","KIM DR                   ","                         ","BIGGERS             ","AR","65432","1234567890","bee@mook.com             "

the first numbers, a 6 digit number, is the unique identifier for that line of data.
what I need to do is search the text file for that unique number, and print all data items on the screen on that line only.
thanks

7
QB64 Discussion / search txt file for a certain number
« on: October 26, 2020, 09:24:13 pm »
I am trying to search a text file for data. Each data line has 10 items. the first data item is a 6 digit id number.
I input an id number to search for, then print all 10 items on the screen on that line. I think I am missing something.
thanks

Code: QB64: [Select]
  1. TYPE ContactType 'there are 10 items in the text file
  2.     idnum AS STRING * 6
  3.     consumerid AS STRING * 6
  4.     firstname AS STRING * 20
  5.     lastname AS STRING * 20
  6.     address1 AS STRING * 25
  7.     address2 AS STRING * 25
  8.     city AS STRING * 20
  9.     state AS STRING * 2
  10.     zip AS STRING * 5
  11.     phone AS STRING * 10
  12.     email AS STRING * 25
  13. DIM consumer AS ContactType
  14.  
  15. LOCATE 5, 30: INPUT "consumerid: ", idnum
  16. OPEN "durgenDB/contactlist.txt" FOR BINARY AS #1
  17. a$ = SPACE$(LOF(1))
  18. GET #1, 1, a$
  19.  
  20. foundError = INSTR(a$, "idnum")
  21. IF foundidnum THEN
  22.  
  23.     DO
  24.         PRINT consumer.consumerid, consumer.firstname, consumer.lastname, consumer.address1, consumer.address2, consumer.city, consumer.state, consumer.zip, consumer.phone, consumer.email
  25.         foundidnum = INSTR(foundidnum + 1, a$, "idnum")
  26.     LOOP WHILE foundidnum > 0

Pages: [1]