INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help for Clipper code

Help for Clipper code

(OP)
Hi every body,
I have a small clipper source code. can some explain what this code is doing as I have no experience in clipper and have to rewrite code in ABAP.
CODE:


sele 0
use kk
DO WHILE .NOT. EOF()
   imef=aa
   sele 0
   use &imef
DO WHILE !EOF()
   kb = GetMod97(alltrim(substr(poziv,3)))
   REPLACE POZIV WITH LEFT(KB,2)+substr(poziv,3)
   skip
enddo
   use SELE KK
   SKIP
ENDDO
***********************

FUNCTION GetMod97(cMod)
LOCAL nLe   := LEN(cMod)
if nLen > 10
   n5 := VAL(SUBSTR(cMod,1,8))
   nZ := n5-INT(n5/97)*97
   nMod97 := VAL(ALLTRIM(STR(nZ))+SUBSTR(cMod,9,nLen-)     +"00")
else
nMod := INT(nMod97 / 97)*97
RETURN pADDL(cAS(98 -(nod97-nMod)) ,2,"0"
********************
Func XAS
PARA DD
RETURN(ALLTRIM(STR(DD)))





Thanks for help.

 

RE: Help for Clipper code

You need a closing paren on this line:
RETURN pADDL(cAS(98 -(nod97-nMod)) ,2,"0"


What is your question?

RE: Help for Clipper code

(OP)
Hi DTracy,
thanks for prompt help.



I cant understand the source. Just wanted to know what is return value.
Thanks

sele 0
use kk
DO WHILE .NOT. EOF()
   imef=aa
   sele 0
   use &imef
DO WHILE !EOF()
   kb = GetMod97(alltrim(substr(poziv,3)))
   REPLACE POZIV WITH LEFT(KB,2)+substr(poziv,3)
   skip
enddo
   use SELE KK
   SKIP
ENDDO
***********************

FUNCTION GetMod97(cMod)
LOCAL nLe   := LEN(cMod)
if nLen > 10
   n5 := VAL(SUBSTR(cMod,1,8))
   nZ := n5-INT(n5/97)*97
   nMod97 := VAL(ALLTRIM(STR(nZ))+SUBSTR(cMod,9,nLen-)     +"00")
else
nMod := INT(nMod97 / 97)*97
RETURN pADDL(cAS(98 -(nod97-nMod)) ,2,"0")
********************
Func XAS
PARA DD
RETURN(ALLTRIM(STR(DD)))

RE: Help for Clipper code

What I see is it opening two files; using the first to
open the second, updating a field in the second.
This is what I see...
// Select area zero
sele 0
// Open the first file KK
use kk
// Begin a loop while not end of file KK
DO WHILE .NOT. EOF()
   // Let imef be equal to AA, imef must be a private or
   // public var.
   imef=aa
   // Select area zero--overwrites the first use.
   sele 0
   // Open the second file AA
   use &imef
   // Begin a loop while not end of file AA.
   DO WHILE !EOF()
      // Let kb be equal to the return of GetMod97().
      kb = GetMod97(alltrim(substr(poziv,3)))
      // Replace the value of field POZIV with the two
      // leftmost chars of KB and the first three chars
      // of poziv.
      // Potential problem here with ambiguious vars--
      // field and global.
      REPLACE POZIV WITH LEFT(KB,2)+substr(poziv,3)
      // Skip to the next record in AA.
      skip
      // Jump back to top of AA loop.
   enddo
   // Use the KK file again.
   use SELE KK
   // Skip to the next record in KK.
   SKIP
   // Jump back to top of KK loop.
ENDDO
***********************

// This function has several errors.  Perhaps is is doing
// some modulus math on the parameter passed, or it could
// be some kind of rounding routine, I don't
// know. I can't tell where all these vars came from:
// n5, nZ, nMod97.
FUNCTION GetMod97(cMod)
LOCAL nLen   := LEN(cMod)
if nLen > 10
   n5 := VAL(SUBSTR(cMod,1,8))
   nZ := n5-INT(n5/97)*97
   nMod97 := VAL(ALLTRIM(STR(nZ))+SUBSTR(cMod,9,nLen-)     +"00")
else // This is a potential problem.
nMod := INT(nMod97 / 97)*97
// Should have EndIf here, see above.

// Returns padded left with zeros the return of
// function XAS.
RETURN pADDL(XAS(98 -(nod97-nMod)) ,2,"0")
********************

// This function is a numeric to string conversion
// routine.
Func XAS
// DD is a numeric parameter for the XAX function.
PARA DD
// Returns the numeric DD converted to a string and
// trimed of leading and trailing spaces.
RETURN(ALLTRIM(STR(DD)))

RE: Help for Clipper code

(OP)
Hi Dtracy
Thanks for the help. It solves my problem

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close