Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fixes to run worldcities #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions samples/worldcities/README.ocamlpro
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@


Download files from:

http://download.geonames.org/export/dump/

mkdir -p $HOME/worldcityfiles




## worldcities0

### Prerequisites

wget http://download.geonames.org/export/dump/CA.zip
unzip -x CA.zip
mv CA.txt $HOME/worldcityfiles/
wc -L $HOME/worldcityfiles/CA.txt

Verify that the size is the record in city-record.copy is at least 500
bytes longer than the max line length (output of wc -L).

### Execution

To build and execute:
./worldcities0.sh

### Dependencies

Depends on:
* city-record.cpy





## worldcities1

### Prerequisites

wget http://download.geonames.org/export/dump/countryInfo.txt
mv countryInfo.txt $HOME/worldcityfiles/

### Execution

To build and execute:
./worldcities1.sh

### Dependencies

Depends on:
* city-record.cpy
* country-record.cpy
* checkfilestatus.cpy





## worldcities2

### Prerequisites

wget http://download.geonames.org/export/dump/cities15000.zip
unzip -x cities15000.zip
mv cities15000.txt $HOME/worldcityfiles/

### Execution

To build and execute:
./worldcities2.sh

### Dependencies

Depends on:
* city-record.cpy
* country-record.cpy
* checkfilestatus.cpy





## worldcities3

### Prerequisites

wget http://download.geonames.org/export/dump/allCountries.zip
unzip -x allCountries.zip
mv allCountries.txt $HOME/worldcityfiles/

### Execution

To build and execute:
./worldcities3.sh

### Dependencies

Depends on:
* city-record.cpy
* country-record.cpy
* commonroutines.cbl
* printrunreport.cbl

48 changes: 24 additions & 24 deletions samples/worldcities/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export FILES=$HOME/worldcityfiles
cobc -x -W -free worldcities2.cbl
./worldcities2 $FILES/cities15000.txt $FILES/countryInfo.txt
rm worldcities2
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
#rm run-file
#rm report-file
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
rm run-file
rm report-file
# Enter your print queue name here
export PRINTQUEUE=Brother-HL-2170W-wireless
export FILES=$HOME/worldcityfiles
Expand All @@ -33,21 +33,21 @@ cobc -x -W worldcities3.cbl commonroutines.cbl
./worldcities3 $FILES/allCountries.txt $FILES/countryInfo.txt ErrorContinent
./worldcities3 $FILES/allCountries.txt $FILES/countryInfo.txt Oceania
rm worldcities3
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
#rm run-file
#rm report-file
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
rm run-file
rm report-file
# Enter your print queue name here
export PRINTQUEUE=Brother-HL-2170W-wireless
export FILES=$HOME/worldcityfiles
cat $FILES/CA.txt $FILES/US.txt > $FILES/CAUS.txt
cobc -x -W worldcities4.cbl commonroutines.cbl
./worldcities4 $FILES/CAUS.txt $FILES/countryInfo.txt
rm worldcities4
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
#rm run-file
#rm report-file
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
rm run-file
rm report-file
export PRINTQUEUE=Brother-HL-2170W-wireless
export FILES=$HOME/worldcityfiles
export countryfile=$FILES/countryInfo.txt
Expand All @@ -58,10 +58,10 @@ cobc -x -W worldcities5.cob commonroutines.cbl
./worldcities5 $FILES/CAUS.txt $FILES/countryInfo.txt
rm worldcities5.cob
rm worldcities5
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
#rm run-file
#rm report-file
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
rm run-file
rm report-file
export PRINTQUEUE=Brother-HL-2170W-wireless
export FILES=$HOME/worldcityfiles
cat $FILES/CA.txt $FILES/US.txt > $FILES/CAUS.txt
Expand All @@ -78,10 +78,10 @@ export CSV=$FILES/worldcities6.csv
google-earth $KML
rm worldcities6.cob
rm worldcities6
#lpr -P PRINTQUEUE run-file
#lpr -P PRINTQUEUE report-file
#rm run-file
#rm report-file
lpr -P PRINTQUEUE run-file
lpr -P PRINTQUEUE report-file
rm run-file
rm report-file
# Enter your print queue name here
export PRINTQUEUE=Brother-HL-2170W-wireless
export FILES=$HOME/worldcityfiles
Expand All @@ -91,10 +91,10 @@ rm $kmlfile
./worldcities7 $FILES/allCountries.txt $FILES/countryInfo.txt $FILES/Vienna.kml
google-earth $kmlfile
rm worldcities7
##lpr -P PRINTQUEUE run-file
##lpr -P PRINTQUEUE report-file
#rm run-file
#rm report-file
#lpr -P PRINTQUEUE run-file
#lpr -P PRINTQUEUE report-file
rm run-file
rm report-file
export PRINTQUEUE=Brother-HL-2170W-wireless
export BROWSER=firefox
export MAPS=google-earth
Expand Down
10 changes: 6 additions & 4 deletions samples/worldcities/checkfilestatus.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ start-checkfilestatus.
if file-status = '00' or '10'
goback
end-if
move 'UNKNOWN STATUS' to status-message.
evaluate file-status
when 00 move 'SUCCESS.' TO status-message
when 02 move 'SUCCESS DUPLICATE.' TO status-message
when 04 move 'SUCCESS INCOMPLETE.' TO status-message
when 05 move 'SUCCESS OPTIONAL.' TO status-message
when 06 move 'TRUNCATED READ.' TO status-message
when 07 move 'SUCCESS NO UNIT.' TO status-message
when 10 move 'END OF FILE.' TO status-message
when 14 move 'OUT OF KEY RANGE.' TO status-message
Expand Down Expand Up @@ -48,13 +50,13 @@ start-checkfilestatus.
when 61 move 'FILE SHARING FAILURE.' TO status-message
when 91 move 'FILE NOT AVAILABLE.' TO status-message
end-evaluate
string 'ERROR ' delimited by size
string
file-name delimited by space
space delimited by size
status-message delimited by '.'
' : ' delimited by size
status-message delimited by '.'
into display-message
end-string
display display-message end-display
display 'ERROR (' file-status ') ON ' display-message end-display
stop run
.
end program checkfilestatus.
Expand Down
2 changes: 2 additions & 0 deletions samples/worldcities/city-record.cpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
01 city-record pic x(14000).

10 changes: 6 additions & 4 deletions samples/worldcities/commonroutines.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ start-checkfilestatus.
if file-status = '00' or '10'
goback
end-if
move 'UNKNOWN STATUS' to status-message.
evaluate file-status
when 00 move 'SUCCESS.' TO status-message
when 02 move 'SUCCESS DUPLICATE.' TO status-message
when 04 move 'SUCCESS INCOMPLETE.' TO status-message
when 05 move 'SUCCESS OPTIONAL.' TO status-message
when 06 move 'TRUNCATED READ.' TO status-message
when 07 move 'SUCCESS NO UNIT.' TO status-message
when 10 move 'END OF FILE.' TO status-message
when 14 move 'OUT OF KEY RANGE.' TO status-message
Expand Down Expand Up @@ -48,13 +50,13 @@ start-checkfilestatus.
when 61 move 'FILE SHARING FAILURE.' TO status-message
when 91 move 'FILE NOT AVAILABLE.' TO status-message
end-evaluate
string 'ERROR ' delimited by size
string
file-name delimited by space
space delimited by size
status-message delimited by '.'
' : ' delimited by size
status-message delimited by '.'
into display-message
end-string
display display-message end-display
display 'ERROR (' file-status ') ON ' display-message end-display
stop run
.
end program checkfilestatus.
Expand Down
1 change: 1 addition & 0 deletions samples/worldcities/country-record.cpy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01 country-record pic x(1000).
12 changes: 7 additions & 5 deletions samples/worldcities/worldcities0.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ file-control.
data division.
file section.
fd city-file.
01 city-record pic x(1000).
copy city-record.

working-storage section.

Expand Down Expand Up @@ -342,11 +342,13 @@ start-checkfilestatus.
if file-status = '00' or '10'
goback
end-if
move 'UNKNOWN STATUS' to status-message.
evaluate file-status
when 00 move 'SUCCESS.' TO status-message
when 02 move 'SUCCESS DUPLICATE.' TO status-message
when 04 move 'SUCCESS INCOMPLETE.' TO status-message
when 05 move 'SUCCESS OPTIONAL.' TO status-message
when 06 move 'TRUNCATED READ.' TO status-message
when 07 move 'SUCCESS NO UNIT.' TO status-message
when 10 move 'END OF FILE.' TO status-message
when 14 move 'OUT OF KEY RANGE.' TO status-message
Expand Down Expand Up @@ -374,13 +376,13 @@ start-checkfilestatus.
when 61 move 'FILE SHARING FAILURE.' TO status-message
when 91 move 'FILE NOT AVAILABLE.' TO status-message
end-evaluate
string 'ERROR ' delimited by size
string
file-name delimited by space
space delimited by size
status-message delimited by '.'
' : ' delimited by size
status-message delimited by '.'
into display-message
end-string
display display-message end-display
display 'ERROR (' file-status ') ON ' display-message end-display
stop run
.
end program checkfilestatus.
Expand Down
4 changes: 2 additions & 2 deletions samples/worldcities/worldcities1.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ file-control.
data division.
file section.
fd country-file.
01 country-record pic x(1000).
copy country-record.

fd city-file.
01 city-record pic x(1000).
copy city-record.

working-storage section.
01 command-file-name pic x(128) value 'worldcities1.sh'.
Expand Down
4 changes: 2 additions & 2 deletions samples/worldcities/worldcities2.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ fd report-file.
01 report-record pic x(72).

fd country-file.
01 country-record pic x(1000).
copy country-record.

fd city-file.
01 city-record pic x(1000).
copy city-record.

working-storage section.
01 command-file-name pic x(128) value 'worldcities2.sh'.
Expand Down
4 changes: 2 additions & 2 deletions samples/worldcities/worldcities2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export FILES=$HOME/worldcityfiles
cobc -x -W -free worldcities2.cbl
./worldcities2 $FILES/cities15000.txt $FILES/countryInfo.txt
rm worldcities2
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
8 changes: 4 additions & 4 deletions samples/worldcities/worldcities3.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ file-control.
assign to report-file-name
file status is report-file-status.

select sort-file.
select sort-file assign to sortwork.

data division.
file section.
fd report-file.
01 report-record pic x(72).

fd country-file.
01 country-record pic x(1000).
copy country-record.

fd city-file.
01 city-record pic x(1000).
copy city-record.

sd sort-file.
01 sort-record.
Expand Down Expand Up @@ -475,7 +475,7 @@ start-worldcities3.
call 'printrunreport' using print-run-control end-call

move 'close' to print-run-function
call 'printrunreport' end-call
call 'printrunreport' using print-run-control end-call
stop run
.
sort-input.
Expand Down
6 changes: 3 additions & 3 deletions samples/worldcities/worldcities3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export FILES=$HOME/worldcityfiles
cobc -x -W worldcities3.cbl commonroutines.cbl
./worldcities3 $FILES/allCountries.txt $FILES/countryInfo.txt ErrorContinent
./worldcities3 $FILES/allCountries.txt $FILES/countryInfo.txt Oceania
rm worldcities3
lpr -P $PRINTQUEUE run-file
lpr -P $PRINTQUEUE report-file
# rm worldcities3
#lpr -P $PRINTQUEUE run-file
#lpr -P $PRINTQUEUE report-file
4 changes: 2 additions & 2 deletions samples/worldcities/worldcities4.cbl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ file-control.
assign to report-file-name
file status is report-file-status.

select sort-file.
select sort-file assign to sortwork.

data division.
file section.
Expand All @@ -70,7 +70,7 @@ fd country-file.
01 country-record pic x(1000).

fd city-file.
01 city-record pic x(1000).
copy city-record.

sd sort-file.
01 sort-record.
Expand Down
Loading