How to SCAN substrings in a dbf - Summer 87

Fórum sobre a linguagem CA-Clipper.

Moderador: Moderadores

alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

Command Needed

Mensagem por alxsts »

Hi!

If I have understood it, now you have a DbEdit() window showing two columns and what you need is to make it shows one column only, like in the first version. Furthermore, you need to merge in this column the company names or their owners' last names and first names containning the search argument. All this sorted ascending and case insensitive. Ok?

Clipper has been a nice language since it appeared but it's is not a magician. There is no built-in functionality to perform this task automatically. Code must be written.

I think the best solution is to perform a full table scan writing the right records only to our tmpTable. After, you have two choices: SORT or INDEX ON tmpTable. And submit it to the DBedit(), after a few adjusts to it's parameters. Are you ready?
[]´s
Alexandre Santos (AlxSts)
marge0512
Usuário Nível 3
Usuário Nível 3
Mensagens: 121
Registrado em: 20 Mai 2011 12:42
Localização: United States

Command Needed

Mensagem por marge0512 »

Well, I'm not sure I'm ready if I'm ready, but I'm sure going to try! Lol!!

In a nutshell, yes, you are correct as to what I need for my system. It's all about pleasing the user. I just wish i knew Clipper well. I'm so used to working with object oriented languages that I have gotten spoiled.

Well, back to my Clipper journey!!
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

Command Needed

Mensagem por Pablo César »

I prefer to use TBrowses in place of DbEdit. It is more flexible.
Nota de Moderação:
por Pablo César: This topic is full of different matters. Please marge0512 take in mind for next messages to open a new topic when you need to see different matters and then put differents descriptions at subject of your posts.
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

Command Needed

Mensagem por alxsts »

Hi!

TBrowe() does not exist in Clipper Summer' 87.
[]´s
Alexandre Santos (AlxSts)
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

Command Needed

Mensagem por Pablo César »

ohhh yeah !

Better to upgrade your tools with Clipper 5 or Harbour, to get more resources and not still suffering so much...
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
marge0512
Usuário Nível 3
Usuário Nível 3
Mensagens: 121
Registrado em: 20 Mai 2011 12:42
Localização: United States

Command Needed

Mensagem por marge0512 »

Hi! I really tried to upgrade to Harbour but it became a total nitemare since there were so many missing libraries. This is going to be hard to believe, but I can debug in Harbour so i use it for that but that's it. I cannot debug in Summer87.
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

Command Needed

Mensagem por Pablo César »

Missing libraries to upgrade in Harbour ? Try to use HMG IDE.

See others posts like this:

https://pctoledo.org/forum/viewto ... hmg#p78661

HMG had helped me much to imigrate from Clipper to Harbour. This IDE installation resumes all configurations and avoid many other installations tools. Try it.
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
marge0512
Usuário Nível 3
Usuário Nível 3
Mensagens: 121
Registrado em: 20 Mai 2011 12:42
Localização: United States

Command Needed

Mensagem por marge0512 »

Great! Thank you! That will be my next project.
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

Command Needed

Mensagem por Pablo César »

You can try to convert Summer´s project into 32bits...

Of course there is one step left from Summer to Clipper5

You should use Functions, Variables types declarations, includes. But still an excellent option.
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

Command Needed

Mensagem por alxsts »

Hi!
marge0512 escreveu:it became a total nitemare since there were so many missing libraries.
I think she means third part libraries that would also be missing using HMG.

The problem was solved, then changes were made by the user to the specification. But the solution is still one step away. To go back now and try to convert to another tool would delay a lot, mainly considering there are missing libraries.

Marge: if you're in trouble to alter the code, tell us. After all this time working with you in this thread, it has became familiar to me. I can easily do this and post if you want me to do.
[]´s
Alexandre Santos (AlxSts)
marge0512
Usuário Nível 3
Usuário Nível 3
Mensagens: 121
Registrado em: 20 Mai 2011 12:42
Localização: United States

Command Needed

Mensagem por marge0512 »

Do you think that would be ok? I got this message:
Nota de Moderação:
por Pablo César: This topic is full of different matters. Please marge0512 take in mind for next messages to open a new topic when you need to see different matters and then put differents descriptions at subject of your posts.
Or should I start a new topic?

I have been working with the code and have to admit that I'm beating my head against the wall right now. Lol! I am trying to do a table scan but SELECT statements are different in Clipper. To be quite honest, i don't know what I'm doing. New topic??
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

How to SCAN table

Mensagem por Pablo César »

Yes MArge, you can continue in this topic taking in mind that your difficulties are scanning data in the table.
I have changed your topic´s title just to give more sense to all topic.

My appologies for any disturbing.
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
Avatar do usuário
Pablo César
Usuário Nível 7
Usuário Nível 7
Mensagens: 5312
Registrado em: 31 Mai 2006 10:22
Localização: Curitiba - Paraná

How to SCAN substrings in a dbf - Summer 87

Mensagem por Pablo César »

Marge, I believe that you will need to make a search menu for user takes different options. When you need to search in only one field or in both. Then you will know the right command to use for SORT it.
Um clip-abraço !

Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
marge0512
Usuário Nível 3
Usuário Nível 3
Mensagens: 121
Registrado em: 20 Mai 2011 12:42
Localização: United States

How to SCAN substrings in a dbf - Summer 87

Mensagem por marge0512 »

Sure, no problem!

Well, like I said, I'm not sure what I'm doing so don't laugh.......I've been playing with code and trying and changing to no avail. I have this now but I get: Error DBFNTX/1020 Data type error: Compny_nam.

INDEX ON COMPNY_NAM TO tmpTable FOR (REC2FIND $ UPPER(COMPNY_NAM) .or. REC2FIND $ UPPER(CASE_LNAME))

SELECT CASES <-------original table name.
Go top
Do while !eof()
Cascomp = (REC2FIND $ UPPER(cases->COMPNY_NAM)) <-------Here is where i get the error.
Caslnam = (REC2FIND $ UPPER(cases->CASE_LNAME))

USE tmpTable SHARED
If tmptable->(dbappend())
Tmptable->compny_nam = cascomp
tmptable->case_lname = caslnam
Endif
Select CASES
Skip
enddo

When debugging, "Cascomp" has a value of .F. and "Caslnam" has a value of .T. which is not my intention. I wanted a field value stored in these variables. Not sure what I'm doing wrong but I think i have a slight mess on my hands!
alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

How to SCAN substrings in a dbf - Summer 87

Mensagem por alxsts »

Hi!

The dollar operator returns a logical value (.T. or .F.) , indicating whether or not the search argument was found in the target string.

Código: Selecionar todos


PRIVATE cString

DECLARE a Struct[2]

aStruct[1] = { "COMPNY_NAM", "C", 40, 0 }
aStruct[2] = { "CASE_LNAME", "C", 40, 0 }

DbCreate( "tmpTable", aStruct)

USE tmpTable EXCLUSIVE

&& tmpTable is the current selected work area
Do WHILE cases->(  ! Eof() )
   cString = ""
   && search LNAME first cause if REC2FIND exists in both fields, it takes precedence
   IF (REC2FIND $ UPPER(cases->CASE_LNAME))
      cString = cases->CASE_LNAME
   ELSEIF (REC2FIND $ UPPER(cases->COMPNY_NAM)) 
      cString = cases->COMPNY_NAM
   ENDIF

   IF Len( cString) > 0
      && something was found. Write it...      
      Itmptable->(dbappend())
       IF .Not. NetErr()
         tmpTable->COMPNY_NAM = cases->COMPNY_NAM
         tmpTable->CASE_LNAME = cString
       ELSE
         && Error. Display some message and quit
         QUIT 
      ENDIF 

   ENDIF
   cases->( dBsKIP() )
ENDDO

&& tmpTable is still the current selected work area
INDEX ON COMPNY_NAM TO tmpTable

After this point, adjust the DbEdit() call and let it run.

After DbEdit() ran, check the exit state: if ESC pressed, move the cases table record pointer to the one saved at the beginning. Otherwise, you'll have tmpTable positioned on the selected record. Move tmpTable->COMPNY_NAM to the REC2FIND variable. Close tmpTable, delete it and the index file. Now let the flow proceed as already coded: use the REC2FIND variable to SEEK the cases table. If found, terminate else move cases table pointer to saved recno and exit... and so on. I haven't compiled this code. Pease test it.

Edited: Note that DbEdit() will show the tmpTable->CASE_LNAME field, where we stored the matches found. The other field (tmpTable->COMPNY_NAM) contains the key you'll use to SEEK the cases table when user selects something in DbEdit().
[]´s
Alexandre Santos (AlxSts)
Responder