Home > Archive > Cobol > October 2005 > Inspect...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| EBille 2005-10-17, 6:55 pm |
| Hello,
I'm looking for a solution to validate datas :
Suppose you got first-name and want to display error message when you
encounter two spaces (and some other characters).
For exemple 'MIKE DANIEL ' is good (because there is only one space
between Mike and Daniel) but 'MIKE DANIEL ' is not. The problem is
trailing spaces. I have tried this :
inspect ws-firstname tallying ws-mytally for characters before ' '
but it doesn't works : first-name never validates because of trailing
spaces. Anybody has a solution ?
Thanks,
EB
Grenoble
France
| |
| Mike B 2005-10-17, 6:55 pm |
| "EBille" <billard.eric@free.fr> wrote in message
news:1129553966.407455.254520@f14g2000cwb.googlegroups.com
> Hello,
> I'm looking for a solution to validate datas :
> Suppose you got first-name and want to display error message when you
> encounter two spaces (and some other characters).
> For exemple 'MIKE DANIEL ' is good (because there is only one space
> between Mike and Daniel) but 'MIKE DANIEL ' is not. The problem is
> trailing spaces. I have tried this :
> inspect ws-firstname tallying ws-mytally for characters before ' '
> but it doesn't works : first-name never validates because of trailing
> spaces. Anybody has a solution ?
I am not the world's greatest COBOL programmer, but I've recently had to
solve a similar problem. I used COBOL reference modification and started at
the back of the data, reading forward until I found the first non-blank
character and then using a loop to the beginning of the field to check for
two adjacent spaces.
If you can't figure it out, post back. I need to dash off now and don't have
time to look for the code, but I'll check back this afternoon and post some
code if you need it.
--
Mike B
| |
| howard.brazee@cusys.edu 2005-10-17, 6:55 pm |
| On 17 Oct 2005 05:59:26 -0700, "EBille" <billard.eric@free.fr> wrote:
>I'm looking for a solution to validate datas :
"datas"?
>Suppose you got first-name and want to display error message when you
>encounter two spaces (and some other characters).
>For exemple 'MIKE DANIEL ' is good (because there is only one space
>between Mike and Daniel) but 'MIKE DANIEL ' is not. The problem is
>trailing spaces. I have tried this :
>inspect ws-firstname tallying ws-mytally for characters before ' '
>but it doesn't works : first-name never validates because of trailing
>spaces. Anybody has a solution ?
There are several solutions for this, but my favorite is using
reference modification loops here.
| |
| bmuralidharan@gmail.com 2005-10-17, 6:55 pm |
| Try this...
Move "MIKE DANIEL " to ws-name
Unstring ws-name delimited by all spaces
INTO First-name
Last-name
-Murali
Mike B wrote:
> "EBille" <billard.eric@free.fr> wrote in message
> news:1129553966.407455.254520@f14g2000cwb.googlegroups.com
>
> I am not the world's greatest COBOL programmer, but I've recently had to
> solve a similar problem. I used COBOL reference modification and started at
> the back of the data, reading forward until I found the first non-blank
> character and then using a loop to the beginning of the field to check for
> two adjacent spaces.
>
> If you can't figure it out, post back. I need to dash off now and don't have
> time to look for the code, but I'll check back this afternoon and post some
> code if you need it.
>
> --
> Mike B
| |
| Judson McClendon 2005-10-17, 6:55 pm |
| "EBille" <billard.eric@free.fr> wrote:
> Suppose you got first-name and want to display error message when you
> encounter two spaces (and some other characters).
> For exemple 'MIKE DANIEL ' is good (because there is only one space
> between Mike and Daniel) but 'MIKE DANIEL ' is not. The problem is
> trailing spaces. I have tried this :
> inspect ws-firstname tallying ws-mytally for characters before ' '
> but it doesn't works : first-name never validates because of trailing
> spaces. Anybody has a solution ?
It's a little more complete than your example, but you can download file
NAME.ZIP from my website below under "COBOL Source Files." It was programmed
to work using COBOL 74, COBOL 85 or COBOL 2002.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Donald Tees 2005-10-17, 6:55 pm |
| Mike wrote:
> howard.brazee@cusys.edu wrote:
>
>
>
> You should forgive him, he is French. Data has a plural in French. ;)
>
>
Data *is* plural in english. The singular is datum.
Donald
;< )
| |
| howard.brazee@cusys.edu 2005-10-17, 6:55 pm |
| On 17 Oct 2005 08:23:49 -0700, "Mike" <MPBrede@gmail.com> wrote:
>
>You should forgive him, he is French. Data has a plural in French. ;)
Interesting. We use the Latin in English, where data *is* the plural
of datum. While I knew that the French fight the inclusion of
foreign words and grammar, but didn't know it went back that far. I
suspect it was a retro-fit. Having a consistent grammar is
attractive to programmers such as myself.
But we're well in the process of forgetting that "data" is plural -
people in data processing rarely use the word "datum" and often say
"my data indicates that..."
But even worse, people in the media rarely use the word "medium".
I like the optional plural for "schema" of "schemata". As in "I
modified some subschemata in our database".
| |
| Christopher Pomasl 2005-10-17, 6:55 pm |
| Adding comment inline with CJP prefix....
On Mon, 17 Oct 2005 08:23:49 -0700, Mike wrote:
>
> Here is a sample I wrote. Serves two purposes. Solves your problem and
> I can also get some feedback on my way of writing COBOL. Be kind,
> gentle reader. :-)
> IDENTIFICATION DIVISION.
> PROGRAM-ID. NameTest.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 GoodName pic x(20) value 'Daniel Miller'.
> 01 BadName pic x(20) value 'Daniel Miller'.
> 01 Ptr pic 9(02) value zero.
> 01 Ptr2 pic 9(02) value zero.
> 01 EndLoopFlag Pic x(01) value '0'.
> 88 EndLoop value '1'.
> 88 RunLoop value '0'.
> 01 DblSpace pic xx value ' '.
CJP - Not sure what compiler you use and how it processes in this
light....but on MVS, each 01 level starts on a doubleword boundary (8 byte
boundary). So your Working storage would take up
24+24+8+8+8+2 = 74 bytes
vs.
20+20+2+2+1+2 = 47 bytes
Also make sure your pointers are in a format that does not need to be
changed in order for the compiler to use them efficiently. On MVS, PIC
9(2) would need to be converted from character to binary, manipulated,
then converted back to put it back into the variable.
Not horrible items given the program's purpose, but food for thought when
writing your programs. Always write with efficiency of the runtime in
mind.
> PROCEDURE DIVISION.
>
> If BadName not = space
> Perform varying ptr from length of BadName
> by -1
> Until EndLoop
> if Badname(ptr:1) = space
> Continue
> else
> Set EndLoop to true
> End-If
> End-perform
>
CJP I'd write this:
CJP Perform varying ptr from length of BadName
CJP by -1
CJP Until ptr < 1
CJP or Badname (ptr:1) not = space
CJP Continue
CJP End-perform
CJP You are doing the comparison already in the IF statement so you lose
nothing putting it in the PERFORM, but you gain the loss of the ELSE and
manipulation of the flag which in THIS case is not really necessary (but
handy sometimes).
> Set runloop to true
> Perform varying ptr2 from ptr
> by -1
> Until EndLoop
> If BadName(ptr2:2) = DblSpace
> Display "Name is rotten at " ptr2
> set EndLoop to True
> Else
> if ptr2 = 0
> Set EndLoop to true
> End-if
> End-if
> End-perform
CJP When ptr2 makes it to 0, the refmod will be attempted first....
CJP Try...
CJP Perform varying ptr2 from ptr
CJP by -1
CJP Until ptr2 < 1
CJP or BadName(ptr2:2) = Spaces
CJP continue
CJP End-perform
CJP
CJP if ptr2 > 0
CJP Display "Name is rotten at " ptr2
CJP End-if
CJP
CJP Note also, that DblSpace is not necessary in this example as the
SPACES word can be use to the same effect. Again a space issue.
> End-if
>
> Display 'End of Run'
> Stop Run.
CJP:
I also like to make flag settings in code rather than rely on VALUE
clauses for the initial setting. Again on MVS, you can be set to reuse
the working storage so COBOL does not have to reallocate it every time.
It is also better documentation as to what is happening in the program if
you set data items in the run. Otherwise you need to go back to W-S to
figure out what you're initialized to. In a large program, that can be a
lot of scrolling to find it out. It is also safer if you have a runtime
environment that may reuse the W-S as-is without re-initializing it.
Initialize it yourself.
I usually only use VALUE clauses for items that I know will not change in
the code.
| |
| Richard 2005-10-17, 6:55 pm |
| >> If BadName not = space[color=darkred]
CJP I'd write this:
CJP Perform varying ptr from length of BadName
CJP by -1
CJP Until ptr < 1
CJP or Badname (ptr:1) not = space
If efficiency is what you require then the initial 'If badname not =
spaces' eliminates the need to check for 'ptr < 1' as there is
guaranteed to be a non-space character.
If efficiency is what you require then your compiler may do better with
an OCCURS and an index rather than reference notation.
| |
| Rick Smith 2005-10-17, 9:55 pm |
|
"EBille" <billard.eric@free.fr> wrote in message
news:1129553966.407455.254520@f14g2000cwb.googlegroups.com...
> Hello,
> I'm looking for a solution to validate datas :
> Suppose you got first-name and want to display error message when you
> encounter two spaces (and some other characters).
> For exemple 'MIKE DANIEL ' is good (because there is only one space
> between Mike and Daniel) but 'MIKE DANIEL ' is not. The problem is
> trailing spaces. I have tried this :
> inspect ws-firstname tallying ws-mytally for characters before ' '
> but it doesn't works : first-name never validates because of trailing
> spaces. Anybody has a solution ?
> Thanks,
> EB
> Grenoble
> France
move 1 to ws-mytally
inspect ws-firstname tallying ws-mytally
for characters before ' '
if ws-firstname (ws-mytally:) not = spaces
display 'bad name'
end-if
| |
| EBille 2005-10-18, 7:55 am |
| Hello,
Thanks for all your response. I will try all your solutions, but
thought INSPECT was faster than any hand-written code... the program
i'm writing has a lot of data to validate (name, age, address and
more...).
You're right also for my poor usage of grammar. I use lots of english
terms, (sorry, Mr Toubon) and apply plural to them, even when they are
yet... And the worst of it is that I have learn Latin when I was 11 to
14. Forgot it quickly. Have better PHP or FoxPro... ;-)) and cobol.
Have a nice day,
EB
Grenoble
France
| |
| Judson McClendon 2005-10-18, 6:55 pm |
| "John Culleton" <john@wexfordpress.com> wrote:
>
> In current usage in English "data" is both the singular and the plural.
> Some
> purists still say "the data are" but it sounds affected to me.
The distinction between data and datum implies that data are in discreet
units, which is not always true. I prefer the connotation that data is, at
least potentially, not in discreet units, such as is implied in the names
for liquids (e.g. milk, water), where there is no singular/plural, at least
in English.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Ian Dalziel 2005-10-18, 6:55 pm |
| On Tue, 18 Oct 2005 08:17:13 -0500, "Judson McClendon"
<judmc@sunvaley0.com> wrote:
>"John Culleton" <john@wexfordpress.com> wrote:
>
>
>The distinction between data and datum implies that data are in discreet
>units, which is not always true. I prefer the connotation that data is, at
>least potentially, not in discreet units, such as is implied in the names
>for liquids (e.g. milk, water), where there is no singular/plural, at least
>in English.
Used any half bits lately?
;-)
--
Ian
| |
|
| In article <wz65f.24389$MG.14681@bignews2.bellsouth.net>,
Judson McClendon <judmc@sunvaley0.com> wrote:
>"John Culleton" <john@wexfordpress.com> wrote:
>
>The distinction between data and datum implies that data are in discreet
>units, which is not always true.
How interesting... I usually think that the difference between datum and
data is similar to the difference between rope and ropes.
>I prefer the connotation that data is, at
>least potentially, not in discreet units, such as is implied in the names
>for liquids (e.g. milk, water), where there is no singular/plural, at least
>in English.
Odd... I recall hearing reference to 'the waters of (body of water)', as
in 'the waters of the Atlantic' or 'the waters of the mighty Niagara'...
NNNIIIIAAAAGGGAAARRRAAAA FFFAAAALLLLSSSSS!... *sloooooowly* I turned,
*step* by step, *inch* by inch... sorry... where was I? Oh yes... and it
would seem to be appropriate to use the plural when referring to different
kinds of milk ('mare's milk has a specific gravity of (m) while hamster's
milk has a specific gravity of (n); if the two milks are mixed to obtain a
specific gravity of (o) the aggregate fat content is found to be...')...
.... while on the other hand an individual's age, for instance, is a datum
and whether a person had an automobile-accident in a given age-range is a
datum (accident while 16 - 24 (Y/N)? accident while 25 - 38 (Y/N)?, etc.)
but 'the data on accidents during ages (y - z)' refers to
multiples/plurals.
DD
| |
| Howard Brazee 2005-10-18, 6:55 pm |
| On 17 Oct 2005 15:52:28 -0700, "Richard" <riplin@Azonic.co.nz> wrote:
>CJP I'd write this:
>CJP Perform varying ptr from length of BadName
>CJP by -1
>CJP Until ptr < 1
>CJP or Badname (ptr:1) not = space
>
>If efficiency is what you require then the initial 'If badname not =
>spaces' eliminates the need to check for 'ptr < 1' as there is
>guaranteed to be a non-space character.
With all compilers?
| |
| Judson McClendon 2005-10-18, 6:55 pm |
| "EBille" <billard.eric@free.fr> wrote:
> ... but [I] thought INSPECT was faster than any hand-written code...
Bad assumption. In some speed tests we did in this newsgroup a few years
ago, it turned out that hand coded loops using reference modification were
usually faster (sometimes significantly so), than most of the intrinsic text
manipulation functions. This was surprising to many of us. Below is a
message Peter Dashwood posted during that exchange, including a sample
benchmark program.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
"Peter E. C. Dashwood" <dashwood@enternet.co.nz> wrote in message
news:b3638c46.0312041726.549b62cf@posting.google.com...
> "Judson McClendon" <judmc@sunvaley0.com> wrote in message
> news:<20031204103714.391$XB@news.newsreader.com>...
>
> Hmmm...
>
> I did <G>...
>
> I currently use REVERSED because I like the elegance of it (although
> some of this was lost in the "benchmark" implementation).
>
> I therefore decided to re-run the old benchmark you provided and see
> just how "bad" it is...
>
> Ouch! I won't be using it in future...
>
> Here're my results...
>
> I took Judson's string length measuring benchmark and amended it
> (slightly) so it could
> compile on the Fujitsu NETCOBOL v6 compiler.
>
> It was run on a pentium 4 (2.6 GHz) Notebook, under Windows XP
> Professional.
>
> Apart from system tasks, nothing else was running; Task Manager
> reported 40 active tasks...
>
> Here are the results, conclusions, and Source code...
>
>
> * Benchmark in original form
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:40:25
> RJUST-2 00:57:51
> RJUST-3 00:10:72
> RJUST-4 00:15:33
> RJUST-5 00:15:70
>
> Running it again to ensure clock fetches are OK...
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:40:54
> RJUST-2 00:57:78
> RJUST-3 00:10:61
> RJUST-4 00:15:23
> RJUST-5 00:15:52
>
> The total of these seconds does NOT agree with wall clock time (around
> 100 seconds)
> so the calculations of elapsed time are suspect before we start.
>
> However, as they ARE consistent, let's continue...
>
> Changing the Stringing of output in RJUST-1 to be a MOVE...
>
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:39:90
> RJUST-2 00:57:14
> RJUST-3 00:10:71
> RJUST-4 00:15:26
> RJUST-5 00:15:62
>
> Didn't help much...<G>
>
> Now calculate the parameters to the MOVE as a separate step, using
> efficient arithmetic...
>
> NOTE: COUNTER was changed to comp-5, and two comp-5 fields (J and K)
> were added, as parameters
> to the MOVE.
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:34:34
> RJUST-2 00:51:38
> RJUST-3 00:10:68
> RJUST-4 00:15:23
> RJUST-5 00:15:43
>
> Better. Changing COUNTER has affected all the processes...
>
> Now change ALL the COMP fields to COMP-5...
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:34:36
> RJUST-2 00:40:71
> RJUST-3 00:07:24
> RJUST-4 00:06:27
> RJUST-5 00:06:27
>
> Holy Efficiency, Batman! Just allowing efficient arithmetic has
> changed the order of the Techniques!
>
> Now lets try something REALLY SIMPLE...
>
> Add code for RJUST-6, as follows:
>
>
> RJUST-6.
> *
> * Using Fujitsu-specific Function...
> *
> MOVE TEST-VALUE TO INPUT-FIELD
> IF (INPUT-FIELD NOT = SPACES)
> move INPUT-FIELD (1: function STORED-CHAR-LENGTH (INFIELD))
> to OUTPUT-FIELD
> END-IF.
>
>
> Starting Benchmark...
> 50,000,000 Iterations
> RJUST-1 00:35:01
> RJUST-2 00:41:52
> RJUST-3 00:07:33
> RJUST-4 00:06:42
> RJUST-5 00:06:43
> RJUST-6 00:06:44
>
> CONCLUSIONS:
>
> 1. The REVERSED function, while elegant, is SIGNIFICANTLY less
> efficient at measuring string length
> than alternative approaches.
> 2. Efficent arithmetic on different platforms can make SIGNIFICANT
> differences to performance.
> 3. COBOL "Benchmarks" that rely on fetching the clock, without
> consistently converting to
> ticks for time arithmetic, are suspect. In multi-processing
> environments like Windows it
> is difficult to compare results without doing multiple runs of the
> same test. Even then it is
> STILL suspect...
> 4. Despite NOT being platform independent I shall continue to use the
> Fujitsu intrinsic
> "STORED-CHAR-LENGTH" because it requires less source and came out
> well in this benchmark.
>
> Finally, here is the Benchmark code with the amendments I made so it
> could run in the Fujitsu
> environment and do so efficiently.
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. RJUSTEST.
> *
> * 50,000,000 Iterations on PIII 550
> * RJUST-1 37:47:43 (HH:MM:SS)
> * RJUST-2 00:31:80
> * RJUST-3 00:29:66
> * RJUST-4 00:35:70
> * RJUST-5 00:35:54
> *
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 INPUT-FIELD.
> 03 INPUT-CHAR PIC X(01) OCCURS 30 TIMES
> INDEXED BY ICX.
> 01 INFIELD redefines INPUT-FIELD pic x(30). *> STORED-CHAR-LENGTH
> function needs
> *> an elementary field.
> 01 OUTPUT-FIELD PIC X(30).
> 01 CHAR PIC X(01).
> 01 COUNTER PIC S9(04) COMP-5.
> 01 INPUT-PTR PIC S9(04) COMP-5.
> 01 INPUT-SIZE PIC S9(04) COMP-5.
> 01 OUTPUT-PTR PIC S9(04) COMP-5.
> 01 J pic s9(4) comp-5.
> 01 K pic s9(4) comp-5.
>
> 01 TEST-VALUE PIC X(30) VALUE
> "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
> 01 LOOP PIC 9(08) COMP VALUE 50000000.
> 01 LOOP-DISP PIC ZZ,ZZZ,ZZ9 VALUE SPACES.
> 01 TIME-START PIC 9(06).
> 01 TIME-RJUST-1 PIC 9(06).
> 01 TIME-RJUST-2 PIC 9(06).
> 01 TIME-RJUST-3 PIC 9(06).
> 01 TIME-RJUST-4 PIC 9(06).
> 01 TIME-RJUST-5 PIC 9(06).
> 01 TIME-RJUST-6 PIC 9(06).
>
> 01 TIME-WORK.
> 03 TW-T1 PIC 9(06).
> 03 TW-T1-R REDEFINES TW-T1.
> 05 TW-T1-MM PIC 9(02).
> 05 TW-T1-SS PIC 9(02).
> 05 TW-T1-TH PIC 9(02).
> 03 TW-T2 PIC 9(06).
> 03 TW-T2-R REDEFINES TW-T2.
> 05 TW-T2-MM PIC 9(02).
> 05 TW-T2-SS PIC 9(02).
> 05 TW-T2-TH PIC 9(02).
> 03 TW-TD.
> 05 TW-DESC PIC X(08) VALUE "RJUST-X ".
> 05 TW-TD-MM PIC 9(02) VALUE 0.
> 05 PIC X(01) VALUE ":".
> 05 TW-TD-SS PIC 9(02) VALUE 0.
> 05 PIC X(01) VALUE ":".
> 05 TW-TD-TH PIC 9(02) VALUE 0.
> PROCEDURE DIVISION.
> TEST-3-START.
> display 'Starting Benchmark...' upon syserr
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-START.
> PERFORM RJUST-1 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-1.
> PERFORM RJUST-2 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-2.
> PERFORM RJUST-3 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-3.
> PERFORM RJUST-4 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-4.
> PERFORM RJUST-5 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-5.
> PERFORM RJUST-6 LOOP TIMES.
> MOVE FUNCTION CURRENT-DATE (11:6) TO TIME-RJUST-6.
>
> MOVE LOOP TO LOOP-DISP.
> DISPLAY LOOP-DISP " Iterations" upon syserr.
> MOVE "RJUST-1 " TO TW-DESC.
> MOVE TIME-START TO TW-T1.
> MOVE TIME-RJUST-1 TO TW-T2.
> PERFORM DISPLAY-TIME.
> MOVE "RJUST-2 " TO TW-DESC.
> MOVE TIME-START TO TW-T1.
> MOVE TIME-RJUST-2 TO TW-T2.
> PERFORM DISPLAY-TIME.
> MOVE "RJUST-3 " TO TW-DESC.
> MOVE TIME-RJUST-2 TO TW-T1.
> MOVE TIME-RJUST-3 TO TW-T2.
> PERFORM DISPLAY-TIME.
> MOVE "RJUST-4 " TO TW-DESC.
> MOVE TIME-RJUST-3 TO TW-T1.
> MOVE TIME-RJUST-4 TO TW-T2.
> PERFORM DISPLAY-TIME.
> MOVE "RJUST-5 " TO TW-DESC.
> MOVE TIME-RJUST-4 TO TW-T1.
> MOVE TIME-RJUST-5 TO TW-T2.
> PERFORM DISPLAY-TIME.
> MOVE "RJUST-6 " TO TW-DESC.
> MOVE TIME-RJUST-5 TO TW-T1.
> MOVE TIME-RJUST-6 TO TW-T2.
> PERFORM DISPLAY-TIME.
>
> STOP RUN.
>
> DISPLAY-TIME.
> IF (TW-T1-TH > TW-T2-TH)
> IF (TW-T2-SS < 1)
> ADD 60 TO TW-T1-SS
> SUBTRACT 1 FROM TW-T2-MM
> END-IF
> COMPUTE TW-TD-TH = TW-T2-TH + 100 - TW-T1-TH
> SUBTRACT 1 FROM TW-T2-SS
> ELSE
> COMPUTE TW-TD-TH = TW-T2-TH - TW-T1-TH
> END-IF.
> IF (TW-T1-SS > TW-T2-SS)
> COMPUTE TW-TD-SS = TW-T2-SS + 60 - TW-T1-SS
> SUBTRACT 1 FROM TW-T2-MM
> ELSE
> COMPUTE TW-TD-SS = TW-T2-SS - TW-T1-SS
> END-IF.
> COMPUTE TW-TD-MM = TW-T2-MM - TW-T1-MM.
> DISPLAY TW-TD upon syserr.
>
> RJUST-1.
> MOVE TEST-VALUE TO INPUT-FIELD.
> MOVE 1 TO COUNTER.
> IF INPUT-FIELD NOT = SPACES
> MOVE FUNCTION REVERSE(INPUT-FIELD) TO OUTPUT-FIELD
> INSPECT OUTPUT-FIELD TALLYING COUNTER FOR LEADING SPACES
> * STRING INPUT-FIELD DELIMITED BY SIZE
> * INTO OUTPUT-FIELD WITH POINTER COUNTER
> compute J = counter + 1
> compute K = function LENGTH (INPUT-FIELD) - counter
> move output-field (J: K)
> to output-field
> END-IF.
>
> RJUST-2.
> MOVE TEST-VALUE TO INPUT-FIELD.
> IF INPUT-FIELD NOT = SPACES
> compute INPUT-SIZE = FUNCTION LENGTH (INPUT-FIELD)
> move INPUT-SIZE to INPUT-PTR
> PERFORM UNTIL INPUT-FIELD (INPUT-PTR:1) NOT = SPACE
> SUBTRACT 1 FROM INPUT-PTR
> END-PERFORM
> SUBTRACT INPUT-PTR FROM INPUT-SIZE
> ADD 1 INPUT-SIZE GIVING OUTPUT-PTR
> MOVE INPUT-FIELD (1:INPUT-PTR)
> TO OUTPUT-FIELD (OUTPUT-PTR:INPUT-PTR)
> IF INPUT-SIZE > 0
> MOVE SPACES TO OUTPUT-FIELD (1:INPUT-SIZE)
> END-IF
> END-IF.
>
> RJUST-3.
> MOVE TEST-VALUE TO INPUT-FIELD
> IF INPUT-FIELD NOT = SPACES
> compute INPUT-SIZE = FUNCTION LENGTH (INPUT-FIELD)
> PERFORM VARYING ICX
> FROM INPUT-SIZE BY -1
> UNTIL INPUT-CHAR (ICX) NOT = SPACE
> END-PERFORM
> SET INPUT-PTR TO ICX
> SUBTRACT INPUT-PTR FROM INPUT-SIZE
> ADD 1 INPUT-SIZE GIVING OUTPUT-PTR
> MOVE SPACES TO OUTPUT-FIELD
> MOVE INPUT-FIELD (1:INPUT-PTR)
> TO OUTPUT-FIELD (OUTPUT-PTR:INPUT-PTR)
> END-IF.
>
> RJUST-4.
> MOVE TEST-VALUE TO INPUT-FIELD
> MOVE SPACES TO OUTPUT-FIELD.
> IF (INPUT-FIELD NOT = SPACES)
> compute INPUT-PTR = FUNCTION LENGTH(INPUT-FIELD)
> PERFORM UNTIL INPUT-FIELD(INPUT-PTR:1) NOT = SPACE
> SUBTRACT 1 FROM INPUT-PTR
> END-PERFORM
> COMPUTE OUTPUT-PTR = FUNCTION LENGTH(OUTPUT-FIELD)
> - INPUT-PTR + 1
> MOVE 1 TO INPUT-PTR
> PERFORM UNTIL OUTPUT-PTR > 0
> ADD 1 TO INPUT-PTR OUTPUT-PTR
> END-PERFORM
> MOVE INPUT-FIELD(INPUT-PTR:) TO OUTPUT-FIELD(OUTPUT-PTR:)
> END-IF.
>
> RJUST-5.
> MOVE TEST-VALUE TO INPUT-FIELD
> MOVE SPACES TO OUTPUT-FIELD.
> IF (INPUT-FIELD NOT = SPACES)
> compute INPUT-PTR = FUNCTION LENGTH(INPUT-FIELD)
> PERFORM UNTIL INPUT-FIELD(INPUT-PTR:1) NOT = SPACE
> SUBTRACT 1 FROM INPUT-PTR
> END-PERFORM
> COMPUTE OUTPUT-PTR = FUNCTION LENGTH(OUTPUT-FIELD)
> - INPUT-PTR + 1
> IF (OUTPUT-PTR < 1)
> COMPUTE INPUT-PTR = 2 - OUTPUT-PTR
> MOVE 1 TO OUTPUT-PTR
> ELSE
> MOVE 1 TO INPUT-PTR
> END-IF
> MOVE INPUT-FIELD(INPUT-PTR:) TO OUTPUT-FIELD(OUTPUT-PTR:)
> END-IF.
>
> RJUST-6.
> *
> * Using Fujitsu-specific Function...
> *
> MOVE TEST-VALUE TO INPUT-FIELD
> IF (INPUT-FIELD NOT = SPACES)
> move INPUT-FIELD (1: function STORED-CHAR-LENGTH (INFIELD))
> to OUTPUT-FIELD
> END-IF.
| |
| Judson McClendon 2005-10-18, 6:55 pm |
| "Ian Dalziel" <iandalziel@lineone.net> wrote:
> "Judson McClendon" <judmc@sunvaley0.com> wrote:
>
> Used any half bits lately?
> ;-)
Data isn't bits, of course. We only use bits to represent (sometimes
approximate) data. :-)
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Judson McClendon 2005-10-18, 6:55 pm |
| <docdwarf@panix.com> wrote:
> Judson McClendon <judmc@sunvaley0.com> wrote:
>
> Odd... I recall hearing reference to 'the waters of (body of water)', as
> in 'the waters of the Atlantic' or 'the waters of the mighty Niagara'...
> NNNIIIIAAAAGGGAAARRRAAAA FFFAAAALLLLSSSSS!... *sloooooowly* I turned,
> *step* by step, *inch* by inch... sorry... where was I? Oh yes... and it
> would seem to be appropriate to use the plural when referring to different
> kinds of milk ('mare's milk has a specific gravity of (m) while hamster's
> milk has a specific gravity of (n); if the two milks are mixed to obtain a
> specific gravity of (o) the aggregate fat content is found to be...')...
You're begging the issue here, as you well know. One can always make a
plural of a noun by creating subsets. It also has nothing to do with my
point, again as you well know.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Howard Brazee 2005-10-18, 6:55 pm |
| On Tue, 18 Oct 2005 09:06:56 -0500, "Judson McClendon"
<judmc@sunvaley0.com> wrote:
>You're begging the issue here, as you well know.
Hmm. Google shows "begging the issue" is a common phrase. I'm
familiar with "begging the question", both the official definition
"The fallacy of reasoning committed when one assumes the truth of what
one is attempting to prove in an argument.", and the assumed meaning
of "encouraging a question".
But I'm not finding a definition of "begging the issue".
| |
|
| In article <7i75f.24401$MG.8798@bignews2.bellsouth.net>,
Judson McClendon <judmc@sunvaley0.com> wrote:
><docdwarf@panix.com> wrote:
[snip - today I feel free to interrupt myself]
[color=darkred]
>
>You're begging the issue here, as you well know. One can always make a
>plural of a noun by creating subsets. It also has nothing to do with my
>point, again as you well know.
Perhaps I am , Mr McClendon; your point, as I read it, was
supported by 'as is implied in the names for liquids (e.g. milk, water),
where there is no singular/plural, at least in English', which, I believe,
is demonstrated above to be inaccurate.
DD
| |
| Judson McClendon 2005-10-18, 6:55 pm |
| <docdwarf@panix.com> wrote:
>
> Perhaps I am , Mr McClendon;
"Ornery" would be a better description, I suppose.
> your point, as I read it, was
> supported by 'as is implied in the names for liquids (e.g. milk, water),
> where there is no singular/plural, at least in English', which, I believe,
> is demonstrated above to be inaccurate.
Have you ever posted a legitimate contribution, or are you only capable of
harping on others? Offhand, I can't recall you ever giving sample code, or
instructions on how to do a useful thing in programming. I would be
pleasantly surprised to be shown otherwise.
Technically, you are correct. But with the exception of archaic and
contrived (pointless?) examples like yours, the usage of words for liquids,
such as water and milk are not differentiated by singular and plural, as
classical English rules say data and datum should be. When do you hear
someone saying in English "I gave him several waters?" You may hear "I gave
him water several times" or "I gave him several glasses of water." This, as
you certainly know, was the meaning of my statement. Your comments
contributed nothing of value. Typical. Too bad you apply your intellect and
education to such paltry purpose, and not for meaningful contribution.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
|
| In article <ak95f.85005$5l.11643@bignews6.bellsouth.net>,
Judson McClendon <judmc@sunvaley0.com> wrote:
><docdwarf@panix.com> wrote:
>
>"Ornery" would be a better description, I suppose.
One does not rule out the other, Mr McClendon.
>
[snip]
[color=darkred]
>
>Technically, you are correct.
Thanks much for acknowledging this, most gracious of you.
>But with the exception of archaic and
>contrived (pointless?) examples like yours, the usage of words for liquids,
>such as water and milk are not differentiated by singular and plural, as
>classical English rules say data and datum should be. When do you hear
>someone saying in English "I gave him several waters?"
Such a thing can be heard during comparison-tastings of bottled beverages,
Mr McClendon, and I've seen such events more than once... did you know
that what comes out of the taps in New York City is often a taste-test
winner?
[snip]
>Too bad you apply your intellect and
>education to such paltry purpose, and not for meaningful contribution.
Meaning, as Wittgenstein tells it, is the result of interpretation, Mr
McClendon; that you see none may speak more of your ability to interpret
than of the phenomenon. Thanks much, though, for your most... charitable
evaluations.
DD
| |
| Richard 2005-10-18, 6:55 pm |
| >If efficiency is what you require then the initial 'If badname not =
>spaces' eliminates the need to check for 'ptr < 1' as there is
>guaranteed to be a non-space character.
> With all compilers?
Yes, after an 'If badname not = >spaces' there is guaranteed to be a
non-space character if the field with all compilers.
| |
| Richard 2005-10-18, 6:55 pm |
| >> ... but [I] thought INSPECT was faster than any hand-written code...
> Bad assumption. In some speed tests we did in this newsgroup a few years
> ago, it turned out that hand coded loops using reference modification were
> usually faster (sometimes significantly so), than most of the intrinsic text
> manipulation functions.
That is a misleading statement because the only use of INSPECT being
tested was with FUNCTION REVERSE.
There is nothing in the test program that compares the general use of
INSPECT with hand coded loops except where REVERSE is likely to mask
the performance.
| |
| john@wexfordpress.com 2005-10-18, 6:55 pm |
|
Judson McClendon wrote:
> The distinction between data and datum implies that data are in discreet
> units, which is not always true. I prefer the connotation that data is, at
> least potentially, not in discreet units, such as is implied in the names
> for liquids (e.g. milk, water), where there is no singular/plural, at least
> in English.
Sometimes data is discreet, and sometimes it is most indiscreet. It
depends on the subject matter. However a single item of information,
whatever the subject, is a discrete quantity or value.
Have you never heard of the bridge over troubled waters? Perhaps you
are too young...
John Culleton
| |
| Arnold Trembley 2005-10-18, 6:55 pm |
|
Judson McClendon wrote:
> <docdwarf@panix.com> wrote:
>
>
>
> "Ornery" would be a better description, I suppose.
>
>
>
>
>
> Have you ever posted a legitimate contribution, or are you only capable of
> harping on others? Offhand, I can't recall you ever giving sample code, or
> instructions on how to do a useful thing in programming. I would be
> pleasantly surprised to be shown otherwise.
Judson, don't be so hard on the Doc. Sure, he's a character
sometimes, but I find him entertaining. And I have seem him post code
examples in this forum, and also instructions on how to do useful, on
topic, things in programming. He's very polite in private email.
Although I have never met the Doc in real life, I consider him a friend.
With kindest regards,
--
http://arnold.trembley.home.att.net/
| |
| Judson McClendon 2005-10-19, 7:55 am |
| <john@wexfordpress.com> wrote:
>
> Judson McClendon wrote:
>
>
> Sometimes data is discreet, and sometimes it is most indiscreet. It
> depends on the subject matter. However a single item of information,
> whatever the subject, is a discrete quantity or value.
>
> Have you never heard of the bridge over troubled waters? Perhaps you
> are too young...
Hardly, John. I enjoyed S&G in real-time. :-)
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Judson McClendon 2005-10-19, 7:55 am |
| "Richard" <riplin@Azonic.co.nz> wrote:
>
>
> That is a misleading statement because the only use of INSPECT being
> tested was with FUNCTION REVERSE.
>
> There is nothing in the test program that compares the general use of
> INSPECT with hand coded loops except where REVERSE is likely to mask
> the performance.
Richard, that was one example test program out of several. In every case,
IIRC, hand coded loops using reference modification were at least as fast
as, or faster than, intrinsic text functions. But, it is easy enough to
write a small benchmark program to verify this. I was not making a specific
point about INSPECT, but simply pointing out the error of assuming an
intrinsic would be faster than hand coded logic.
--
Judson McClendon judmc@sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
| |
| Michael Wojcik 2005-10-19, 9:55 pm |
|
In article <wz65f.24389$MG.14681@bignews2.bellsouth.net>, "Judson McClendon" <judmc@sunvaley0.com> writes:
> "John Culleton" <john@wexfordpress.com> wrote:
>
> The distinction between data and datum implies that data are in discreet
> units, which is not always true. I prefer the connotation that data is, at
> least potentially, not in discreet units, such as is implied in the names
> for liquids (e.g. milk, water), where there is no singular/plural, at least
> in English.
It's certainly possible that many speakers view "data" as a
continuous entity - though in this context it's ironic, since the
very definition of digital computation is that it treats data as
discrete. It'd be more logical to say "the data is ..." if we were
using analog computers.
It's also reasonable to argue that "data" is popularly treated as a
"collective noun", that is a noun which names a group but "occur[s]
in the singular", as _The Oxford Companion to the English Language_
puts it. (And since there is no generally-recognized authority for
English usage, popular treatment is arguably the most eligible metric
for "correct" use.)
In British English, collective nouns often have plural number and
take a plural verb, etc; but in American English, they generally have
singular number. Thus in the US it's common to say for example "the
audience was quiet", while in the UK "the audience were quiet" would
be preferred by many speakers.
_The Oxford Companion_, incidentally, has this to say about "data":
*Data* is currently both plural ('The data are available') and
collective ('How much data do you need?'), and is often therefore
a controversial usage issue.
and goes on to note:
Such usages ... are disliked (often intensely) not only by purists
but by many who consider themselves liberal in matters of usage.
Purism, however, also has its barbarisms, such as the quasi-
classical plurals *octopi* and *syllabi*...
("Classical Ending", 218)
(Of course the "correct" plural for "syllabus", which is a Gr
derivation and not a Latin one, would be something like
"syllabontes". I expect all teachers to begin using it immediately.)
The most important ideas there, I think, are that some usages are
controversial, and that "purism also has its barbarisms".
--
Michael Wojcik michael.wojcik@microfocus.com
Painful lark, labouring to rise!
The solemn mallet says:
In the grave's slot
he lies. We rot. -- Basil Bunting
| |
| Michael Wojcik 2005-10-19, 9:55 pm |
|
In article <r4u9l1dhi0c1gdiq2r1j2pjhre75i9kr65@4ax.com>, Ian Dalziel <iandalziel@lineone.net> writes:
> On Tue, 18 Oct 2005 08:17:13 -0500, "Judson McClendon"
> <judmc@sunvaley0.com> wrote:
>
> Used any half bits lately?
Seriously, partial bits come up quite often in information theory,
compression, and other areas of study. There's a surprising amount
of work done on trits (unbiased three-state entities), which encode
the same amount of information as lg(3) = 1.5849... bits. I think
I've seen some references to work using notional information quanta
equivalent to e (= 2.7182...) bits - so there you have irrational
(even transcendental) partial bits.
While the bit is clearly the smallest discrete integral information
quantum, and thus "natural" in that sense, it's not the only
conceivable or useful information quantum.
Moreover, as I noted in another post, while digital computers by
definition work on discrete data, analog computers do not, and for
them using data as a continuous noun is quite sensible.
--
Michael Wojcik michael.wojcik@microfocus.com
Duck: No secret what's worth a hoot ought to be kept quiet.
Pogo: Secrets is usually perty doggone fascinatin'.
Duck: Egg-zackly ... it's completely illogical to keep a secret secret.
Pogo: An' unfair. -- Walt Kelly
| |
| Michael Wojcik 2005-10-19, 9:55 pm |
|
In article <1129664973.366304.317280@g47g2000cwa.googlegroups.com>, john@wexfordpress.com writes:
> Judson McClendon wrote:
>
>
> Sometimes data is discreet, and sometimes it is most indiscreet. It
> depends on the subject matter. However a single item of information,
> whatever the subject, is a discrete quantity or value.
A single item of information, like a single item of anything, is by
definition discrete; but information is not partitioned into items
ab initio.
--
Michael Wojcik michael.wojcik@microfocus.com
| |
|
| In article <uHd5f.456861$5N3.134893@bgtnsc05-news.ops.worldnet.att.net>,
Arnold Trembley <arnold.trembley@worldnet.att.net> wrote:
[snip]
>Although I have never met the Doc in real life, I consider him a friend.
Pfoo, you'se jes' easily impressed... I'd blush, were I able to remember
how.
DD
| |
|
| Judson McClendon wrote:
> "Richard" <riplin@Azonic.co.nz> wrote:
>
>
> Richard, that was one example test program out of several. In every case,
> IIRC, hand coded loops using reference modification were at least as fast
> as, or faster than, intrinsic text functions. But, it is easy enough to
> write a small benchmark program to verify this. I was not making a specific
> point about INSPECT, but simply pointing out the error of assuming an
> intrinsic would be faster than hand coded logic.
From what I've seen, in my environment, the best speed is done by
defining the data area as a table of characters (hey, wonder where that
idea came from!), with an index, then using the index to spin through
the data... i.e.,
01 my80charLine pic X(80).
01 my80charBreakout.
12 mySingleChar occurs 80 times
indexed by myCharIdx
pic X(01).
....
if my80charLine = spaces then
*> We've got a blank line
move [CR] to mySingleChar (1)
move [LF] to mySingleChar (2)
set myCharIdx to 2
else
if mySingleChar (80) > space then
*> The line is full
set myCharIdx to 80
else
perform varying myCharIdx from 79 by -1
until myCharIdx < 2
or mySingleChar (myCharIdx) > space
continue
end-perform
end-if
end-if
Once this code has executed, myCharIdx now points to the last character
in the string. This has tested quicker on our mainframe (although I
can't put my hands on the exact numbers) than any other method,
including reference modification and "inspect function reverse".
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ daniel@thebelowdomain ~
~ _____ / \ | ~ http://www.djs-consulting.com ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|