Re: Why COBOL is losing the POWER struggle



See my other note. Although INSPECT REPLACING doesn't do what you want,
UNSTRING, INSPECT/REPLACING (or even MOVE) followed by STRING would do it.

Or as your original note indicated, a PERFORM loop would also do it.

--
Bill Klein
wmklein <at> ix.netcom.com
"Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7aaojaF1v66vqU1@xxxxxxxxxxxxxxxxxxxxx
docdwarf@xxxxxxxxx wrote:
In article <7a886lF1s84o2U1@xxxxxxxxxxxxxxxxxx>,
Pete Dashwood <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

[snip]

I wanted my buffer replaced in situ as a string. The ONLY reason I
needed a second buffer was because INSPECT wasn't up to the task.

Wait, I am confused. The situ of 'DATE' is four bytes and 'DATETIME'
requires eight. To place in the situ of a four-character string an
eight-character one requires a... curious bit of mathematics, to say
the least.

Perhaps a more carefulreading would reveal that what I said was "my BUFFER
replaced in situ". There is plenty of room in the buffer for expansion of
individual bits of it.

[snip]

I am not now, and never was, discussing the fault of COBOL, or any
faults of COBOL. I posted a fact. That fact contributes to the
perception of POWER in the language.

Mr Dashwood, once again: what language has the POWER to fill startpos
8, len 4 with an eight-byte string without some sort of compression?

C#, Java, and Visual Basic ALL do it easily. The actual operand(s) is/are not
compressed; the buffer which it/they occurs in is not changed in length
either. A Regular Expression can expand or compress replacement operands
within a buffer. If it runs out of expansion space then the last part of what
the buffer contains is truncated accordingly; if the string it contains
becomes shorter, then it is padded with whatever character you designate
(space by default). And all of this requires ONE line of code. (Actually,
that is not even scratching the surface of what you can do with Regular
Expressions in ONE line of code, it is just a simple example... have a look
at: http://www.design215.com/toolbox/regexp.php THAT is powerful.

If INSPECT ...REPLACING could do that it would be more powerful than it is.

Sure, the non-English-like syntax of Regex strings looks weird and unfamiliar
to COBOL people (It was devised by a mathematician and there is a mathematical
simplicity and elegance to it once you start to understand it), but there is
no denying the POWER of it...

Pete.
--
"I used to write COBOL...now I can do anything."



.



Relevant Pages

  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Secure C library
    ... I read much of the new "security TR", and gee, I don't know. ... the buffer from the buffer size. ... It is not hard to design a better form of buffer and string handling. ... but this is just one example of how thoughtful interface design can ...
    (comp.std.c)
  • Re: Secure C library
    ... >> string functions don't make much sense once you add bounds-checking ... >> designing an interface just for the purpose of reducing the frequency ... > make buffer size decisions more visible, ... Bstrlib is also very interoperable with char *'s, ...
    (comp.std.c)
  • Re: Calling dll functions from vb.net with pointer returns!
    ... (ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As ... OUT PTCHAR Buffer, ... Address of a buffer to receive a set of NULL-terminated device instance ... pszFilter must specify the name of a device ...
    (microsoft.public.dotnet.languages.vb)
  • Re: why I can not write to the file after initialize the MFC in a service program
    ... you check EVERY return from a call that can fail, ... Why do you need an intermedate buffer to write literal strings anyway? ... For example, if AfxWinInit fails, you copy a 45-character string into a ... So you are going to try to initialize MFC EACH TIME THROUGH THE LOOP? ...
    (microsoft.public.vc.mfc)