How to SCAN substrings in a dbf - Summer 87
Moderador: Moderadores
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Ok, I tried copying over the code from the forum again and I tried several other things.....like deleting the .ntx files, reindexing the databases and packing them but i still get the same error. I don't know what could have happened. I've had strange things like this happen before when i debug in Harbour and usually I can copy over old files to start fresh but that isn't working either. I will keep trying.
As far as sorting........i guess that means to use the SORT command.
Another question.........when I use the EXCLUSIVE with USE, will the system crash if another user is using the system? I was researching the difference between EXCLUSIVE and SHARED.
Also, I fixed the code you told me too.
Thanks!!
As far as sorting........i guess that means to use the SORT command.
Another question.........when I use the EXCLUSIVE with USE, will the system crash if another user is using the system? I was researching the difference between EXCLUSIVE and SHARED.
Also, I fixed the code you told me too.
Thanks!!
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
I figured out what the problem is and you won't believe it!! Well, you will but I can't because I'm not very familiar with Clipper. Lol! My mistake, after I copied the information from the forum again, I did this:
Copy to tmpTable FIELDS (COMPNY_NAM) FOR (REC2FIND $ UPPER(COMPNY_NAM)). For some reason I put paranthesis around COMPNY_NAM!!! As soon as i took them off it worked. UGH!!! I've wasted so much time!!! And all of yours too actually! Well, the good news is that it is solved.
Ok, i will work on sorting now.
Copy to tmpTable FIELDS (COMPNY_NAM) FOR (REC2FIND $ UPPER(COMPNY_NAM)). For some reason I put paranthesis around COMPNY_NAM!!! As soon as i took them off it worked. UGH!!! I've wasted so much time!!! And all of yours too actually! Well, the good news is that it is solved.
Ok, i will work on sorting now.
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hi!
Great! I'm glad to hear you!
And finally, I'm curious to see the results of all your big effort. If possible, post a screen shot of the app in action.
Great! I'm glad to hear you!
You've closed it before the time... sometimes we get crazy for a foolish thing... sorry.marge0512 escreveu:Copy to tmpTable FIELDS (COMPNY_NAM) FOR (REC2FIND $ UPPER(COMPNY_NAM))
When USEd with EXCLUSIVE, the system prevents other users to open the table. The application will crash if the programmer didn't handle the situation. You can check for open errors with the NetErr() function. Using a table in SHARED mode allows everyone to read or write to the table, so you must handle record locks with RLock()/DBUnlock().marge0512 escreveu:Another question.........when I use the EXCLUSIVE with USE, will the system crash if another user is using the system? I was researching the difference between EXCLUSIVE and SHARED.
Good! That's right. Remember that the SORT Command copies records from one table to another. So, you won't need the COPY TO command anymore. Try to replace that line with one which will SORT the table, generating the same tempTable and setting the same company name filter. It's the last change you'll need, I guess.marge0512 escreveu:As far as sorting........i guess that means to use the SORT command.
And finally, I'm curious to see the results of all your big effort. If possible, post a screen shot of the app in action.
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hi again!
Another tip:
I dont' know how data was entered in the company name field. Maybe they are in mixed case. To avoid head ache, use the /C switch of the SORT command. This will produce a case insensitive sorting.
Another tip:
I dont' know how data was entered in the company name field. Maybe they are in mixed case. To avoid head ache, use the /C switch of the SORT command. This will produce a case insensitive sorting.
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Hello again! I'm having a little trouble with the SORT command and the examples i have found have not been much help. Here is an example of my SORT:
SORT TO tmpTable ON COMPNY_NAM WHILE !EOF() FOR (REC2FIND $ UPPER(COMPNY_NAM))
This line sorts in ascending order just beautifully. But when I add this to the line: [/[A][C]]
SORT TO tmpTable ON COMPNY_NAM [/[A][C]]
WHILE !EOF() FOR (REC2FIND $ UPPER(COMPNY_NAM))
it does not sort at all. I also tried [/[C]] and [/C] but this doesn't work either. I added the [A] but I don't believe i need it. I think it ascends by default.
What am I doing wrong? I really just wanted the /C switch. Thanks!!
SORT TO tmpTable ON COMPNY_NAM WHILE !EOF() FOR (REC2FIND $ UPPER(COMPNY_NAM))
This line sorts in ascending order just beautifully. But when I add this to the line: [/[A][C]]
SORT TO tmpTable ON COMPNY_NAM [/[A][C]]
WHILE !EOF() FOR (REC2FIND $ UPPER(COMPNY_NAM))
it does not sort at all. I also tried [/[C]] and [/C] but this doesn't work either. I added the [A] but I don't believe i need it. I think it ascends by default.
What am I doing wrong? I really just wanted the /C switch. Thanks!!
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hi!
In Clipper's manual writing conventions, all options enclosed in square brackets ( [] ) are optional and the square brackets themselves should not be included in the source code. Sometimes you don't need some options and then you can omit them.
In your code, the WHILE condition is unnecessary. If you place it, the SORT runs while the condition is true ((REC2FIND $ UPPER(COMPNY_NAM))
). When it finds the first record where (REC2FIND $ UPPER(COMPNY_NAM)) is false the SORT is finished. That's what you're getting.
The line you have to include should look like this: Try it and let us know what happens.
In Clipper's manual writing conventions, all options enclosed in square brackets ( [] ) are optional and the square brackets themselves should not be included in the source code. Sometimes you don't need some options and then you can omit them.
In your code, the WHILE condition is unnecessary. If you place it, the SORT runs while the condition is true ((REC2FIND $ UPPER(COMPNY_NAM))
). When it finds the first record where (REC2FIND $ UPPER(COMPNY_NAM)) is false the SORT is finished. That's what you're getting.
The line you have to include should look like this:
Código: Selecionar todos
SORT ON COMPNY_NAM /C TO tmpTable FOR (REC2FIND $ UPPER(COMPNY_NAM))[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hello!
I have not seen the result but I think it was very good.
Congratulations for the excellent work! If you need, you can count on us.
Tight hug.
I have not seen the result but I think it was very good.
Congratulations for the excellent work! If you need, you can count on us.
Tight hug.
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Hello and here i go again!! I learned Friday that the information I will need to do a search from is not only from the field "COMPNY_NAM" but also from the field "CASE_LNAME". I've been beating my head trying different ways to make the SORT command work to extract information from both fields but I have not succeeded. Then.....it occurred to me that maybe I cannot use the SORT command to search and sort from 2 fields. Is it possible?
Thanks in advance!
Thanks in advance!
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hello!
Yes, it's possible.
Now you need to filter and sort using an additional field. Will you need to display the other field in the selection window also? If so, changes will be necessary in the DbEdit() call configuration.
Yes, it's possible.
Now you need to filter and sort using an additional field.
Código: Selecionar todos
SORT ON COMPNY_NAM /C, CASE_LNAME /C TO tmpTable FOR (REC2FIND $ UPPER(COMPNY_NAM) .OR. REC2FIND $ UPPER(CASE_LNAME) )
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Ok, i did have the same code as you sent and it displays nothing but I did not make any changes with the DBEdit() call configuration. I will take a look at that. Thanks!!
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Command Needed
Hello!
Try to replace the DbEdit() line as shown below:
Try to replace the DbEdit() line as shown below:
Código: Selecionar todos
*---------------------
cOldScreen = SAVESCREEN(5, 2, 20, 78)
* Draw a box with single border
*---------------------
@ 5, 2, 20, 78 BOX cBorder
* Browse records in tmp table until user
* cancels browsing (ESC) or a record is selected (ENTER)
*---------------------
DBEDIT(6, 03, 19, 77, {"COMPNY_NAM", "CASE_LNAME"} , "_REC_FND_",NIL,{" Select Company Name","Person"}) *==> replace with this line
* Restore screen region
*---------------------
RESTSCREEN(5, 2, 20, 78, cOldScreen)[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Thank you! I will try this tomorrow sometime. I just received a bunch of files i have to work with and distribute. Bummer. Lol! Thanks!
-
marge0512
- Usuário Nível 3

- Mensagens: 121
- Registrado em: 20 Mai 2011 12:42
- Localização: United States
Command Needed
Hi! I made the necessary changes this morning and it all works very well. I want to change something though. I did a search on the name "Green" to test. I noticed in my database that there are some individuals with the last name "Green" that have businesses that do not have the word "Green" in them and they show up in the Company Name list, which would be correct but the user said he wants everything to show up in one list.
For example, he wants to do a search on the word "Green" and if their last name is "Green" but their business is "ABC Co", he only wants the last name "Green" to appear under the Company Name list and "ABC Co" to not show up at all. Of course, I will have to change the column name and add the customer's first name to make sense to it all.
I don't think this is a command issue though. I believe i will need to code so that this happens. I have researched other commands but I didn't see anything so I am working on changing the code.
Thank you for your help and i will come back if i have any more questions. It seems that i'm only working in Clipper only once or twice a year or maybe I could become an expert someday. Lol!!
For example, he wants to do a search on the word "Green" and if their last name is "Green" but their business is "ABC Co", he only wants the last name "Green" to appear under the Company Name list and "ABC Co" to not show up at all. Of course, I will have to change the column name and add the customer's first name to make sense to it all.
I don't think this is a command issue though. I believe i will need to code so that this happens. I have researched other commands but I didn't see anything so I am working on changing the code.
Thank you for your help and i will come back if i have any more questions. It seems that i'm only working in Clipper only once or twice a year or maybe I could become an expert someday. Lol!!