Página 6 de 9
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 18:42
por esgici
Hi Alex
Sorry, but I don't understood, what "unpredictable results" may lead ?
I suggest adding SELECT 2 before USE command because when you USE a table without changing current work area, new table will open in the current WA; and after closed the table (if any) reside this area. This is because further references to CASES alias produce "Alias not found" error.
New versions of Clipper ( after S87) have "NEW" keyword in USE command and SELECT 0 for "first empty /avaliable work area"; but in S87 we should define new work area by using SELECT command; I think.
Regards
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 18:46
por marge0512
Here is the code that brings the system to choosing CO_FND:
Código: Selecionar todos
*------------------------------------------------------------------------------*
* File......: MAIN.PRG
* Date......: 4/16/90
* Purpose...: CASES.DBF maintenance
* *------------------------------------------------------------------------------*
private HEADING1, HEADING2, LAYOUT
external ZTRIM, CSTR
* Open database, return if fails
*-------------------------------
if .not. USE_DBFS( "CASES, CAS_NAME, CAS_NAM2")
return
endif
select CASES
* Set up for U_READ
*------------------
do VAR_INIT
* Present ADD option if database is empty
*----------------------------------------
EMPTY_DB = .F.
BM_SELECT = 0
FIRST_TIME = .T.
OP_CL_ALL = 'A'
BM_SIZE = iif(ACCESS='S',6,3)
go top
* Loop until the 7th choice of the menu is chosen (Quit)
*-------------------------------------------------------
do while BM_SELECT <> BM_SIZE
* Display borders
*----------------
do BORDERS with "BROWSE DATABASE"
* If the database is empty, let the user add a record
*----------------------------------------------------
if eof()
* Give user opportunity to add a record
*--------------------------------------
EMPTY_DB = .T.
OP_CL_ALL = 'A'
if YES_TO( "The database is empty. Add now? ")
do SAV_SCRN
do CO_ADD
do RST_SCRN
endif
* If user didn't want to add, or abandoned add, return
*-----------------------------------------------------
if EMPTY_DB
close data
return
endif
endif
* Set up menu
*------------
*0....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....
* Add Update Delete Inquire Find Quit
if ACCESS = 'S'
if OP_CL_ALL = 'C'
BM_1 = "2300A Add "
BM_2 = "2305U Update "
BM_3 = "2313D Delete "
BM_4 = "2321I Inquire "
BM_5 = "2330F Find "
BM_6 = "2336O Open/Closed/All "
BM_7 = "2353Q Quit "
else
BM_1 = "2300A Add "
BM_2 = "2305U Update "
BM_3 = "2313I Inquire "
BM_4 = "2322F Find "
BM_5 = "2328O Open/Closed/All "
BM_6 = "2345Q Quit "
endif
else
BM_1 = "2300I Inquire "
BM_2 = "2309F Find "
BM_3 = "2315Q Quit "
endif
* Display menu & force return
*----------------------------
keyboard chr( ESC_KEY)
U_MENU( "BM_", BM_SELECT, BM_SIZE, "", 1)
* Display headings & prompt & browse the database
*------------------------------------------------
do DISP_MSG with BROWSE_MSG
set color to &LBL_CLR
@ SCRL_T-1, SCRL_L say HEADING1
do U_SCROLL with SCRL_T, SCRL_L, SCRL_B, SCRL_R, LAYOUT, "CO_MENU"
enddo
* Return
*-------
close data
return
*
*-----------------------------------------------------------------------------*
* MAIN.PRG: CO_MENU The menu routine for the CASES BROWSE screen
* scroll
*-----------------------------------------------------------------------------*
procedure CO_MENU
private KEY_CHAR
* Save browse screen
*-------------------
DO SAV_SCRN
* Menu
*-----
KEY_CHAR = SCRL_MNU( "BM_", BM_OPTIONS, @BM_SELECT)
* Act on menu selection
*----------------------
do case
case KEY_CHAR = "Q"
do SCRL_RET
case KEY_CHAR = "A"
do CO_ADD
case KEY_CHAR = "U"
do CO_UPD
case KEY_CHAR = "D"
do CO_DEL
case KEY_CHAR = "I"
do CO_INQ
case KEY_CHAR = "O"
do CO_TOG
do SCRL_RET
case KEY_CHAR = "F"
do CO_FND
endcase
* Restore browse screen, update menu display
*-------------------------------------------
if KEY_CHAR $ " QO"
do DIS_SCRN
else
do RST_SCRN
keyboard chr( ESC_KEY)
U_MENU( "BM_", BM_SELECT, BM_SIZE, "", 1)
endif
return
*
Does this help any??
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:00
por esgici
Pablo César escreveu:I think "!" beguns after 5.0
Amigo, please look at here :
http://www.ousob.com/ng/sum87/ng5ebcc.php
Regards
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:05
por Pablo César
Marge how i you USE_DBFS function ? Could you list your code for us ?
Sorry, I thought "!" is begins to use at Clipper 5 version.
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:10
por marge0512
Sure, I'm surprised that I found the code because things are a mess sometimes. Lol! Here it is:
Código: Selecionar todos
*----------------------------------------------------------------------
* USE_DBFS() Open a list of files & indices
*----------------------------------------------------------------------
function USE_DBFS
parameters P_1, P_2, P_3, P_4, P_5, P_6, P_7, P_8, P_9, P_10, P_11, P_12, P_13, P_14, P_15, P_16, P_17, P_18, P_19, P_20
private I, S, P, DBF, NDX, K, USER_QUIT
USER_QUIT = .F.
I = 1
do while I <= pcount() .and. .not. USER_QUIT
* Get the parm
*-------------
S = ltrim( str( I))
P = alltrim( P_&S)
* Parse out the database & index names
*-------------------------------------
K = at( [,], P)
if K = 0
DBF = P
else
DBF = left( P, K-1)
NDX = right( P, len( P)-K)
endif
* Try and open the files
*-----------------------
select &S
if .not. USE_DBF( DBF)
USER_QUIT = .T.
elseif K <> 0
if .not. USE_NDXS( NDX)
USER_QUIT = .T.
endif
endif
* Next database
*--------------
I = I + 1
enddo
return .not. USER_QUIT
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:14
por alxsts
Hi!
esgici escreveu:Sorry, but I don't understood, what "unpredictable results" may lead ?
Since we don't not know if a file was open in WA number 2, if we open a table there could cause errors when returning to the caller procedure.
esgici escreveu:when you USE a table without changing current work area, new table will open in the current WA
Yes, you're right. In Summer, as you said, we don't have the NEW clause in the USE command. But we have it's equivalent, as you said also. And this is the solution to the problem.
Marge, before the line:
insert the line:
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:35
por alxsts
Hi,
after reading Marge's last post, I must suggest what follows:
replace the 2 occurences of the line
with
It's because I don't know what kind of indices you're using. It appears to be .NDX.
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:39
por esgici
alxsts escreveu:In Summer, as you said, we don't have the NEW clause in the USE command. But we have it's equivalent, as you said also. And this is the solution to the problem.
I said also "open table count + 1".
Anyway, SELECT 0 is better, because with it programmer doesn't should know how many area used at any time.
And, thank to remember; I was not sure if S87 has this usage.
How to SCAN substrings in a dbf - Summer 87
Enviado: 28 Jan 2013 19:41
por marge0512
I believe it is .ndx. I will start again tomorrow morning. Again, i am getting compiling errors and I'm not sure what I did so I will have to do "process of elimination" again to correct the problem.
Thanks for everyone's help!!
How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 03:43
por Pablo César
I am still not sure of operator use "!" for Summer 87. Not sure this documentation in
http://www.ousob.com/ng/sum87/ng5ebcc.php is really Summer 87. Please note file name (php page)
ng5ebcc.php (ng ? Only at version 5 appears for first time in Clipper) and 5 ?
Here is also a comment of this operator in version 5, including !EOF()
Text extracted from:
https://docs.google.com/viewer?a=v&q=ca ... FTCkRl8zBQ
How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 08:35
por esgici
Hi Pablo, my dear amigo
Pablo César escreveu:I am still not sure of operator use "!" for Summer 87. Not sure this documentation in
http://www.ousob.com/ng/sum87/ng5ebcc.php is really Summer 87. Please note file name (php page) ng5ebcc.php (ng ? Only at version 5 appears for first time in Clipper) and 5 ?
Here is also a comment of this operator in version 5, including !EOF()
Definitely, you like "going until to the end" ( like me

); I like much this attitude.
Now, I'm sure that this "!" operator exists in S87 !
First, your extracted text doesn't say "first introduced in Vers. 5"
Second I still have S87 Ref. Guide, and a little quote from there :

- A little quote from S87 Ref. Guide
And third, our friend Marge still has S87 Compiler, it's very simple a "try and see" test.
By the way, it's very pleasant, for prove that I'm wrong, you are using a quote from my blog

)
Thanks also for this.
Everything is for advance and for learning something new :*
Happy Clippering,
Viva Clipper Language

How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 10:19
por Pablo César
First thank you for clarifying all about this matter and for your kind of words. I keep very good feelings motivated by his great strength to help people and his great knowledge in our programming language.
esgici escreveu:Second I still have S87 Ref. Guide
That is what I was looking for... that´s it !
Sorry for all of this inconveniencies.
How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 10:50
por esgici
Hi Pablo, my dear amigo
Thank you very much your kind words
Pablo César escreveu:Sorry for all of this inconveniencies.
Please, there isn't any "inconvenience", did you remember ?
Combat of ideas emerges the light of truth !
Viva friendship

)
How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 13:01
por marge0512
Wow! I finally found the compile error and this seems to be working beautifully now! All I can say is.........HAPPY HAPPY JOY JOY!!!!!!!!!!! Thank you so much!!!!
Now, I'm working on how to match the first names with the last names. All of the last names show but the first do not. Time for me to do.........
trial and error! I am starting to see a big smile on my user's face! Lol!
How to SCAN substrings in a dbf - Summer 87
Enviado: 29 Jan 2013 13:12
por marge0512
Now, I'm really looking at this code and there are a couple of things that I don't understand. Could someone explain what it happening here:
Código: Selecionar todos
IF LEN(cString) > 0
*something was found, save it.
APPEND BLANK <-----------------Why do we need to APPEND here?
IF .Not. NetErr()
tmpTable->CAS_COMPNY = Cases->CAS_COMPNY
tmpTable->CAS_LNAME = UPPER(cString)
ELSE
*Error. Display some message and Exit
DO DISP_MSG with [Error writing temporary file. Press a key to exit.]
SELECT CASES
Go SAV_REC
RETURN
ENDIF
ENDIF
Cases->(DbSkip()) <--------------What does this statement do?
Also, i know this was the original code our programmer put in here but after researching this I still don't understand what this statement really does:
*-----------------------------------
*Get client index
*-----------------------------------
Set Order to 7 <-------------------
Thanks in advance!