Re: Converting numbers to comp fields (Cobol)
Don_at_home.com
Date: 06/15/04
- Next message: NickHK: "Re: Loading Word document into richtextbox"
- Previous message: niv: "View Full Path of Referenced Object"
- In reply to: BeastFish: "Re: Converting numbers to comp fields (Cobol)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Jun 2004 11:59:06 GMT
On Tue, 15 Jun 2004 00:51:18 -0400, "BeastFish" <beastfish@for-president.com>
wrote:
>Comp? Comp-3? Doesn't really matter since COMP is a COBOL thing, VB
>doesn't handle any type of COMP format natively. Seems like a box full of
>frustration just waiting to be opened. One of those things that even if you
>did get something working, you'd always wonder if you're twiddling those
>bits accurately. Consider the following...
>
>How COMP format is implemented depends on the specific COBOL compiler.
>Different compilers implement it in their own fashion. Usually, COMP is
>some form of fixed point BCD (binary-coded decimal), where 2 digits are
>stored in each byte (1 per nibble). Also, depending on which compiler, it
>can be little-endian or big-endian. Dealing with this in VB (or any other
>language besides COBOL) is something I wouldn't even think of doing.
Here is a snip of a routine that does the Endian-To-Endian conversion that I
have in one of my projects that is used to convert Big Endian Binary data to
Little Endian...
Each binary file is 56mgb in size and is the reason for *Chunking* it...
As far as COMP or COMP-X,Y or Z you are on your own... Haven't visited COBOL in
years and really didn't do much with it back then...
BTW: sData and sSwap are both String Varibles...
lInputFN = FreeFile
Open sInputFilename For Binary As #lInputFN
lInputFileLength = LOF(lInputFN)
lOutputFN = FreeFile
Open sOutPutFilename For Output As #lOutputFN 'delete and recreate temp file
Close #lOutputFN
Open sOutPutFilename For Binary As #lOutputFN
Do While lChunk < lInputFileLength
sData = Space$(100000) 'Could be bigger!!
Get #lInputFN, , sData
'This Loop swaps Big Endian to Little Endian...
For lLp = 1 To Len(sData) Step 2
sSwap = Mid$(sData, lLp, 1)
Mid$(sData, lLp, 1) = Mid$(sData, lLp + 1, 1)
Mid$(sData, lLp + 1, 1) = sSwap
Next lLp
Put #lOutputFN, , sData
lChunk = Loc(lInputFN)
lDoEventLp = lDoEventLp + 1
If lDoEventLp Mod 10 = 0 Then
DoEvents
If bCancel Then
Close
Kill sOutPutFilename 'Don't keep partial file...
lblWorking.Visible = False
CancelEnabled False
Exit Sub
End If
End If
Loop
Close
>
>The MicroFocus COBOL compiler I have on my box is a 12 year old DOS one. I
>haven't investigated any of the later MicroFocus ones, so I don't know what
>they've been up to. Does the version you're using have any Windows support?
>Can it create DLLs that can be utilized by Windows programs? If so, perhaps
>you can use it to write a DLL that writes the data to file, one that can be
>called from VB.
>
>
>
>"John" <anonymous@discussions.microsoft.com> wrote in message
>news:1c26d01c4525c$6b1c6b70$a301280a@phx.gbl...
>> I'm new to Visual Basic. I have written an little program
>> that creates a journal entry batch file which gets loaded
>> to our Unix box. We then run a utility to convert some of
>> the fileds in the batch to comp fields so that our
>> Accounting system can read it. We are using Micro Focus
>> as our Cobol provider.
>>
>> My question is can I use VB to generate the same comp
>> fields as Cobol. I would love to skip running the batch
>> through the conversion utility each time.
>>
>> Thanks in advance....
>>
>> John
>
Have a good day...
Don
- Next message: NickHK: "Re: Loading Word document into richtextbox"
- Previous message: niv: "View Full Path of Referenced Object"
- In reply to: BeastFish: "Re: Converting numbers to comp fields (Cobol)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|