Re: Newbie Question



Oliver Wong<owong@xxxxxxxxxxxxxx> 05/31/06 11:05 AM >>>

"Michael Mattias" <michael.mattias@xxxxxxx> wrote in message
news:qPjfg.2694$VE1.1338@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I had this small cobol routine dropped on my desk and need to convert
it into a vb app, but I am not all that familiar with most of cobol. I
can read most of it and decipher what is going on, but having trouble
with this move.

var1 pic 9 comp.
var2 pic 9(10)

If var2 had the value of 138755482 and

MOVE VAR2 TO VAR1 is executed, what is actually stored in var1.

I apologize if this is a no brainer.

MOVE= assignment

MOVE A TO B (cobol) ===> [ LET] B = A (BASIC)

DIM VAR1 AS LONG, VAR2 AS LONG

VAR1 = VAR2

WARNING: a long integer will not hold Var2, where PIC 9(10) specifies a
numeric data item with ten digits before the decimal. You may need to go

to
a SINGLE or DOUBLE here.

It takes 34 bits to store an unsigned 10 digit number, and 35 bits to
store a signed 10 digit number, so you're right that LONG INTEGER (32 bit
signed) won't be enough to store all values of the PIC 9(10). However, if
you move to floating point numbers (e.g. SINGLE or DOUBLE), you're opening

yourself up to problems with rounding, which may also yield big headaches.

In such a case, you'll want to use a "Big Integer" package, such as the

one which can be downloaded from
http://www.codeproject.com/com/BigInteger.asp

Seems to me it might make most sense to treat it as a character string and
loop through it digit by digit, doing the proper calculation.

I haven't done BASIC since jr high, but... (And this assumes we're doing a
mod-11 check...)

Loop through the string, converting each character to its corresponding
integerdata type (ASCII 030 becomes 0, ASCII 031 becomes 1, etc - most
likely VB offers some function to perform this conversion). Multiply that
integer by the proper "weight" and add the result to a long integer data
type (which had been initialized to zero prior to entering the loop). When
you're done your "result" will be the long integer, which you will then
"mod" by the modulus value (11 in this case). If the result is zero then
your account number has passed the mod-11 test.

I think that's about right. I glanced through our COBOL code that performs
this, so I hope I've read it correctly.

Frank


---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO USA
.



Relevant Pages

  • Re: Newbie Question
    ... var2 pic 9 ... MOVE VAR2 TO VAR1 is executed, what is actually stored in var1. ... loop through it digit by digit, ... Converting the string into a long might get you into problems though. ...
    (comp.lang.cobol)
  • Re: Newbie Question
    ... var2 pic 9 ... MOVE VAR2 TO VAR1 is executed, what is actually stored in var1. ... digit integer) won't hold it either. ... has done something "cute" and if you don't know COBOL you are in for a VERY ...
    (comp.lang.cobol)
  • Re: Newbie Question
    ... can read most of it and decipher what is going on, ... var2 pic 9 ... MOVE VAR2 TO VAR1 is executed, what is actually stored in var1. ... What version of CoBOL are you using? ...
    (comp.lang.cobol)
  • Re: Newbie Question
    ... What version of CoBOL are you using? ... clue what version of CoBOL was being used or compiler. ... 03 VAR1 PIC 9 ... Sounds like a mod-10 or mod-11 check, with the last digit of the number ...
    (comp.lang.cobol)
  • Re: Not memorizing an output of a function
    ... variables var1 and var2. ... but MLint should warn the user to control this manually. ... I would probably also explain, with a short comment, why you're suppressing M-Lint ...
    (comp.soft-sys.matlab)