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)
'*** 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)