Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help converting VB to VFP 1

Status
Not open for further replies.

johncook

Programmer
Joined
Nov 24, 2002
Messages
154
Location
US
I have to convert the following into a FoxPro function. Can anyone help? I looked for VB documentation on Microsoft.com. I can find some commands but not the total% command. Perhaps someone knows what total% does.

'*** Value of the start char for subset A used to calculate
'*** the check digit for subset B use a value of 104.
total% = 103

'*** Add the subset A start character to the output string
'*** for subset B use a value of 202.
myData.Text = Chr$(135)

'*** Calculate check digit by looping through the users data
'*** string. At the same time add each character to the output.
'*** Note: Some characters require special handling because
'*** they are mapped to non-standard locations.

For I% = 1 To Len(UserText.Text)
'*** Get the character value and add it to the total
total% = total% + ((Asc(Mid$(UserText.Text, I%, 1)) - 32) * I%)

'*** character exception if character = 127 it is remapped to 139
'*** character exception if char = 32 (space) it is remapped to 192
'*** character exception if char = ' (quote) it is remapped to 193
'*** character exception if char = ` (accent) it is remapped to 194

If Asc(Mid$(UserText.Text, I%, 1)) = 127 Then
myData.Text = myData.Text + Chr$(195)

ElseIf Asc(Mid$(UserText.Text, I%, 1)) = 32 Then
myData.Text = myData.Text + Chr$(192)

ElseIf Asc(Mid$(UserText.Text, I%, 1)) = 39 Then
myData.Text = myData.Text + Chr$(193)

ElseIf Asc(Mid$(UserText.Text, I%, 1)) = 96 Then
myData.Text = myData.Text + Chr$(194)

Else
myData.Text = myData.Text & Mid$(UserText.Text, I%, 1)
End If

Next I%

'*** Calculate the mod 103 check digit
total% = total% Mod 103

Checkdigit = total%
'*** add the check digit and stop character to the data string
'*** substitute correct characters for check digit values
Select Case total%

Case 0 'Space
total% = 192

Case 7 'Single Quote
total% = 193

Case 64 'Accent
total% = 194

Case 95 'Del
total% = 195

Case 96 'FNC3
total% = 196

Case 97 'FNC 2
total% = 197

Case 98 'Shift
total% = 198

Case 99 'Code C
total% = 199

Case 100 'Code B/FNC 4
total% = 200

Case 101 'FNC4/Code A
total% = 201

Case Else
total% = total% + 32

End Select

myData.Text = myData.Text & Chr$(total%) & Chr$(138)
 
I think the % sign stands for integer.

In VFP, simply declare:
Public Total

Assign 103 to Total:
Total = 103

Paul Lai
 
Thanks Paul. I believe I will try this and see how far I get. It appears most everything else, I can figure out.
Thanks again,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top