Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

relative

Status
Not open for further replies.

D2BEA

Technical User
Mar 13, 2001
41
0
0
US
I am having problems reading and verifying-what am I doing wrong.
one program.

PROCEDURE DIVISION using HMFN-COUNTY, HMFN-LOCATION,
CNTY-LOC-TABLE, CNTY-LOC-NAME.

A000-BEGIN.
MOVE SPACES TO countys, cnty-loc-table.
OPEN INPUT CNTY-LOC-FILE.
PERFORM B000-READ.
CLOSE CNTY-LOC-FILE.
STOP RUN.

B000-READ.
display message 'cnty-loc-.cbl reading '.
PERFORM UNTIL ENDOFFILE

READ CNTY-LOC-FILE INTO CNTY-LOC-TABLE
INVALID KEY
MOVE "E" TO END-OF-FILE
DISPLAY MESSAGE 'INVALID KEY'
CLOSE CNTY-LOC-FILE
END-READ
ADD 1 TO CL-KEY
END-PERFORM.
B000-EXIT.
EXIT.


2 program

IF HMFN-COUNTY > SPACE
MOVE 'COUNTY.TBL ' TO CL-FILE
CALL "CNTY-LOC" USING HMFN-COUNTY, HMFN-LOCATION,
CNTY-LOC-TABLE, CNTY-LOC-NAME
CANCEL "CNTY-LOC"
display message 'cnty-loc-table=' cnty-loc-table
display message 'hmfn-county=' hmfn-county
DISPLAY MESSAGE 'CLV-(HHIDX)' CLV(HH-IDX)
IF HMFN-COUNTY NOT = CLV(HH-IDX)
DISPLAY MESSAGE ' INVALID COUNTY CODE '
END-IF
END-IF
.
 
If you are having a problem with this code, could you tell us what it is?
 
It is not finding the code the user enters. I put in display and it is reading the tables. I am trying to take what the User enters and check that against a table for verification.
 
A couple of issues:

There is not attempt made in 'one' program to match HMFN-COUNTY with what is read.

Try the following (I am not using all of your variables - for simplicity):

one program.

PROCEDURE DIVISION using HMFN-COUNTY,
HMFN-FOUND.

A000-BEGIN.
OPEN INPUT CNTY-LOC-FILE.
PERFORM B000-READ.
CLOSE CNTY-LOC-FILE.
STOP RUN.

B000-READ.
MOVE "YES" TO HMFN-FOUND
PERFORM UNTIL ENDOFFILE

READ CNTY-LOC-FILE INTO CNTY-LOC-TABLE
AT END
MOVE "E" TO END-OF-FILE
END-READ

IF HMFN-COUNTY = DATABASE-COUNTY
MOVE "YES" TO HMFN-FOUND
MOVE "E" TO END-OF-FILE
END-IF

END-PERFORM.


2 program

IF HMFN-COUNTY > SPACE
CALL "CNTY-LOC" USING HMFN-COUNTY, HMFN-FOUND
IF HMFN-FOUND NOT = "YES"
DISPLAY MESSAGE ' INVALID COUNTY CODE '
END-IF
END-IF
.
 
DOESN'T A RELATIVE FILE USE "INVALID AND NOT INVALID" INSTEAD OF AT END?
 
I keep getting wrun32 errors (iam using acubench).
 
I did not compile the example code; but, if "INVALID AND NOT INVALID" works for you, then, use it.
 
Yes, at end is not acdeptable according to the compiler. But I am still getting a freeze on the program-I do not know why?
 
Now when it comes bake to the user screen it freezes.
Program 1

IF HMFN-COUNTY > SPACE
MOVE 'COUNTY.TBL ' TO CL-FILE
CALL "CNTY-LOC2" USING HMFN-COUNTY, CNTY-FOUND,
HMFN-LOCATION, LOC-FOUND.
CANCEL "CNTY-LOC2"
IF CNTY-FOUND NOT = 'Y'
DISPLAY MESSAGE 'INVALID COUNTY CODE'
END-IF
END-IF.

Program 2
PROCEDURE DIVISION using HMFN-COUNTY, CNTY-FOUND,
HMFN-LOCATION, LOC-FOUND.


A000-BEGIN.
OPEN INPUT CNTY-LOC-FILE.
PERFORM B000-READ.
CLOSE CNTY-LOC-FILE.
STOP RUN.

B000-READ.
MOVE 'N' TO END-OF-FILE.
PERFORM UNTIL ENDOFFILE
READ CNTY-LOC-FILE INTO CNTY-LOC-TABLE
INVALID KEY
MOVE "E" TO END-OF-FILE
DISPLAY MESSAGE 'INVALID KEY' cnty-loc-stat
* NOT INVALID KEY
* PERFORM C000-CHECK
end-read

IF CL-FILE = 'COUNTY.TBL'
IF HMFN-COUNTY= CLV(HH-IDX)
MOVE 'Y' TO CNTY-FOUND
MOVE 'E' TO END-OF-FILE
END-IF
END-IF
IF CL-FILE = 'LOCATION.TBL'
IF HMFN-LOCATION= CLV(HH-IDX)
MOVE 'Y' TO LOC-FOUND
MOVE 'E' TO END-OF-FILE
END-IF
END-IF
END-PERFORM.


 
This may be because you are using STOP RUN in the called program. Use EXIT PROGRAM or GOBACK in the called program.

Also, CANCEL may not be needed.

Let me know how you are progressing.

Dimandja
 
It will bring it back to the user field on the screen, but it freezes at that point.
 
1. Have you used EXIT PROGRAM or GOBACK in the called program?
2. Are the results (finding county code, etc...) satisfactory?
3. Have you tested for 'INVALID COUNTY CODE'?
4. When you say that "it freezes at that point", can you be more specific? What exactly happens? Could you list the user screen code?

You need to check/test/list the above: it will help us understand what is going on.

Dimandja
 
Yes, I used exit program and it does go back to the program calling it.
Yes, it is finding the county codes
Yes, I have testied for invalid-it goes through what seems a loop, like it tests it and states invalid code on the screen, and then it goes to the users screen code field and highlights it, but when I press a tab or return or even move the cursur it runs throught the testing again.

I can't get the screen to print on here.
 
It sounds like the screen handling code is not working properly. You need to let the user choose to execute the code, exit, and whatever other function is needed.

We don't need to see the screen picture, only the code that handles it.

Dimandja
 
This is the screen code.


CS-HHINFO-CS1-county-EF-ADD-Aft-Procedure.
PERFORM COUNTY-CHECK.


COUNTY-CHECK.
IF HMFN-COUNTY > SPACE
move spaces to cl-file, cnty-found
MOVE 'COUNTY.TBL ' TO CL-FILE
CALL "CNTY-LOC2" USING HMFN-COUNTY, CNTY-FOUND,
HMFN-LOCATION, LOC-FOUND,
CNTY-LOC-name, CNTY-LOC-table
CANCEL "CNTY-LOC2"
IF CNTY-FOUND NOT = 'Y'
DISPLAY MESSAGE 'INVALID COUNTY CODE'
END-IF
END-IF.


This is the code in the called program

PROCEDURE DIVISION using HMFN-COUNTY, CNTY-FOUND,
HMFN-LOCATION, LOC-FOUND,
CNTY-LOC-name, CNTY-LOC-table.


A000-BEGIN.
MOVE SPACES TO cnty-loc-table.
OPEN INPUT CNTY-LOC-FILE.
PERFORM B000-READ.
CLOSE CNTY-LOC-FILE.
EXIT PROGRAM.

A000-EXIT.
EXIT.



B000-READ.
MOVE 'N' TO END-OF-FILE.
PERFORM UNTIL ENDOFFILE
READ CNTY-LOC-FILE INTO CNTY-LOC-TABLE
INVALID KEY
MOVE "E" TO END-OF-FILE
DISPLAY MESSAGE 'INVALID KEY' cnty-loc-stat
NOT INVALID KEY
PERFORM C000-CHECK
end-read
END-PERFORM.

B000-EXIT.
EXIT.


C000-CHECK.
IF CL-FILE = 'COUNTY.TBL'
PERFORM C100-COUNTY
ELSE
PERFORM C200-LOCATION
END-IF.
C000-EXIT.
EXIT.

C100-COUNTY.
MOVE 'N' TO CNTY-FOUND.
perform varying hh-idx from 1 by 1
UNTIL HH-IDX > 33
OR
CLV(HH-IDX) = SPACES
IF HMFN-COUNTY = CLV(HH-IDX)
MOVE 'Y' TO CNTY-FOUND
move 'E' to end-of-file
END-IF
END-PERFORM.
IF CNTY-FOUND = 'N'
MOVE 'E' TO END-OF-FILE
move spaces to hmfn-county
END-IF.

C100-EXIT.
EXIT.
"I am still working on location"
C200-LOCATION.
MOVE 'N' TO LOC-FOUND.
perform varying hh-idx from 1 by 1
UNTIL HH-IDX > 33
OR
CLV(HH-IDX) = SPACES
IF HMFN-LOCATION = CLV(HH-IDX)
MOVE 'Y' TO LOC-FOUND
move 'E' to end-of-file
END-IF
END-PERFORM.

C200-EXIT.
EXIT.


 
This code is questionable:

CS-HHINFO-CS1-county-EF-ADD-Aft-Procedure.
PERFORM COUNTY-CHECK.


COUNTY-CHECK.


After the PERFORM, it will fall through to COUNTY-CHECK: there is nothing there to direct it to do anything else.

You need to decide what to do after PERFORM COUNTY-CHECK.
By the way, where does the user get to supply input?

I think what you need to do is come up with a design. For example:

STARTING-POINT-PAR.
DISPLAY "Input County code: "
ACCEPT <county code variable>
PERFORM COUNTY-CHECK
DISPLAY <results>
DISPLAY &quot;Enter 1 to Repeat or 2 to Stop&quot;
ACCEPT <option>
IF <option> = 1
GO TO STARTING-POINT-PAR
END-IF
STOP RUN.

Dimandja

 
This is part of Acucobol acubench in the event area

When the User enters a county code, I set an after procedure.
CS-HHINFO-CS1-county-EF-ADD-Aft-Procedure.
then I tell it to perform county-check, it should come right back to the county code in the user screen, which it does, but if the user pressess enter or tab or anything it keeps performing the check, I am confused, since I had end-if?
PERFORM COUNTY-CHECK.


COUNTY-CHECK.


 
END-IF is not an executable statement - it is a statement delimiter. It shows the compiler where an IF statement ends.

I have not used Acucobol. But, when you say &quot;When the User enters a county code, I set an after procedure&quot;, I assume that you are triggering/loading an event procedure.

It sounds like, when the user presses enter, the &quot;after procedure&quot; which was previously loaded, starts executing automatically on any event. Each time, after county-check is performed, I suggest that you undo/reset the &quot;after procedure&quot; - or at least specify which event it should respond to.

In any case, before executing &quot;county-check&quot;, you need to provide options to the user. The user may want to EXIT, for example - how do they do that?

I suggest not using an event handler for this logic. You need to obtain the user input, then analyze it to figure out what to do next.

Dimandja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top