Foros del Web » Programando para Internet » ASP Clásico »

ayuda pasar funcion a asp

Estas en el tema de ayuda pasar funcion a asp en el foro de ASP Clásico en Foros del Web. Gracias X leerlo amigos soy nuevo en asp y he estado tratando de pasar una funcion que trabaja sin problema en VB6 a asp pero ...
  #1 (permalink)  
Antiguo 14/08/2008, 10:04
Avatar de ACX_POISON  
Fecha de Ingreso: abril-2008
Ubicación: Talca-Chile
Mensajes: 750
Antigüedad: 16 años, 2 meses
Puntos: 7
Pregunta ayuda pasar funcion a asp

Gracias X leerlo
amigos soy nuevo en asp y he estado tratando de pasar una funcion que trabaja sin problema en VB6 a asp pero no me funciona correctamente.

¿Alguien me puede ayudar?

Cita:
Public Function EAN128$(chaine$)
'V 1.0.0
'Paramètres : une chaine
'Parameters : a string
'Retour : * une chaine qui, affichée avec la police CODE128.TTF, donne le code barre
' * une chaine vide si paramètre fourni incorrect
'Return : * a string which give the bar code when it is dispayed with CODE128.TTF font
' * an empty string if the supplied parameter is no good
Dim i%, checksum&, mini%, dummy%, tableB As Boolean
EAN128$ = ""
If Len(chaine$) > 0 Then
'Vérifier si caractères valides
'Check for valid characters
For i% = 1 To Len(chaine$)
Select Case Asc(Mid$(chaine$, i%, 1))
Case 32 To 126, 198, 202
Case Else
i% = 0
Exit For
End Select
Next
'Calculer la chaine de code en optimisant l'usage des tables B et C
'Calculation of the code string with optimized use of tables B and C
EAN128$ = ""
tableB = True
If i% > 0 Then
i% = 1 'i% devient l'index sur la chaine / i% become the string index
Do While i% <= Len(chaine$)
If tableB Then
'Voir si intéressant de passer en table C / See if interesting to switch to table C
'Oui pour 4 chiffres au début ou à la fin, sinon pour 6 chiffres / yes for 4 digits at start or end, else if 6 digits
mini% = IIf(i% = 1 Or i% + 3 = Len(chaine$), 4, 6)
GoSub TestNumOrFnc1
If mini% < 0 Then 'Choix table C / Choice of table C
If i% = 1 Then 'Débuter sur table C / Starting with table C
EAN128$ = Chr$(205)
Else 'Commuter sur table C / Switch to table C
EAN128$ = EAN128$ & Chr$(199)
End If
tableB = False
Else
If i% = 1 Then EAN128$ = Chr$(204) 'Débuter sur table B / Starting with table B
End If
End If
If Not tableB Then
'On est sur la table C, essayer de traiter 2 chiffres ou Ê/ We are on table C, try to process 2 digits or Ê
If Asc(Mid$(chaine$, i%, 2)) = 202 Then
'On traite le Fnc1 (Ê) / We process the Fnc1 (Ê)
EAN128$ = EAN128$ & Mid$(chaine$, i%, 1)
i% = i% + 1
Else
mini% = 2
GoSub TestNum
If mini% < 0 Then 'OK pour 2 chiffres, les traiter / OK for 2 digits, process it
dummy% = Val(Mid$(chaine$, i%, 2))
dummy% = IIf(dummy% < 95, dummy% + 32, dummy% + 100)
EAN128$ = EAN128$ & Chr$(dummy%)
i% = i% + 2
Else 'On n'a pas 2 chiffres, repasser en table B / We haven't 2 digits, switch to table B
EAN128$ = EAN128$ & Chr$(200)
tableB = True
End If
End If
End If
If tableB Then
'Traiter 1 caractère en table B / Process 1 digit with table B
EAN128$ = EAN128$ & Mid$(chaine$, i%, 1)
i% = i% + 1
End If
Loop
'Calcul de la clé de contrôle / Calculation of the checksum
For i% = 1 To Len(EAN128$)
dummy% = Asc(Mid$(EAN128$, i%, 1))
dummy% = IIf(dummy% < 127, dummy% - 32, dummy% - 100)
If i% = 1 Then checksum& = dummy%
checksum& = (checksum& + (i% - 1) * dummy%) Mod 103
Next
'Calcul du code ASCII de la clé / Calculation of the checksum ASCII code
checksum& = IIf(checksum& < 95, checksum& + 32, checksum& + 100)
'Ajout de la clé et du STOP / Add the checksum and the STOP
EAN128$ = EAN128$ & Chr$(checksum&) & Chr$(206)
End If
End If
Exit Function
TestNum:
'si les mini% caractères à partir de i% sont numériques, alors mini%=0
'if the mini% characters from i% are numeric, then mini%=0
mini% = mini% - 1
If i% + mini% <= Len(chaine$) Then
Do While mini% >= 0
If Asc(Mid$(chaine$, i% + mini%, 1)) < 48 Or Asc(Mid$(chaine$, i% + mini%, 1)) > 57 Then Exit Do
mini% = mini% - 1
Loop
End If
Return
TestNumOrFnc1:
'si les mini% caractères à partir de i% sont numériques ou FNC1, alors mini%=0
'if the mini% characters from i% are numeric or Fnc1, then mini%=0
mini% = mini% - 1
If i% + mini% <= Len(chaine$) Then
Do While mini% >= 0
If (Asc(Mid$(chaine$, i% + mini%, 1)) < 48 Or Asc(Mid$(chaine$, i% + mini%, 1)) > 57) And Asc(Mid$(chaine$, i% + mini%, 1)) <> 202 Then Exit Do
mini% = mini% - 1
Loop
End If
Return
End Function
y asi es como yo la deje
Cita:
<%
Public Function EAN128(chaine)
'V 1.0.0
'Paramètres : une chaine
'Parameters : a string
'Retour : * une chaine qui, affichée avec la police CODE128.TTF, donne le code barre
' * une chaine vide si paramètre fourni incorrect
'Return : * a string which give the bar code when it is dispayed with CODE128.TTF font
' * an empty string if the supplied parameter is no good
Dim i, checksum, mini, dummy
dim tableB
EAN128 = ""
If Len(chaine) > 0 Then
'Vérifier si caractères valides
'Check for valid characters
For i = 1 To Len(chaine)
CX = Asc(Mid(chaine, i, 1))
if (CX >=32 and CX<=126)or(CX=198)or(CX=202)then
ppp = 0
else
i=0
Exit for
end if

Next
'Calculer la chaine de code en optimisant l'usage des tables B et C
'Calculation of the code string with optimized use of tables B and C
EAN128 = ""
tableB = True
If i > 0 Then
i = 1 'i devient l'index sur la chaine / i become the string index
Do While i <= Len(chaine)
If tableB Then
'Voir si intéressant de passer en table C / See if interesting to switch to table C
'Oui pour 4 chiffres au début ou à la fin, sinon pour 6 chiffres / yes for 4 digits at start or end, else if 6 digits
If(i = 1 Or i + 3 = Len(chaine))then
mini =4
else
mini =6
end if

TestNumOrFnc1
response.Write("Despues de TestNumOrFnc1 <br>")
If mini < 0 Then 'Choix table C / Choice of table C
If i = 1 Then 'Débuter sur table C / Starting with table C
EAN128 = Chr(205)
Else 'Commuter sur table C / Switch to table C
EAN128 = EAN128 & Chr(199)
End If
tableB = False
Else
If i = 1 Then EAN128 = Chr(204) 'Débuter sur table B / Starting with table B
End If
End If
If Not tableB Then
'On est sur la table C, essayer de traiter 2 chiffres ou Ê/ We are on table C, try to process 2 digits or Ê
If Asc(Mid(chaine, i, 2)) = 202 Then
'On traite le Fnc1 (Ê) / We process the Fnc1 (Ê)
EAN128 = EAN128 & Mid(chaine, i, 1)
i = i + 1
Else
mini = 2
response.Write("antes de TestNum<br>")
TestNum
If mini < 0 Then 'OK pour 2 chiffres, les traiter / OK for 2 digits, process it
dummy = Val(Mid(chaine, i, 2))
If(dummy < 95)then
dummy = dummy + 32
else
dummy= dummy + 100
end if
EAN128 = EAN128 & Chr(dummy)
i = i + 2
Else 'On n'a pas 2 chiffres, repasser en table B / We haven't 2 digits, switch to table B
EAN128 = EAN128 & Chr(200)
tableB = True
End If
End If
End If
If tableB Then
'Traiter 1 caractère en table B / Process 1 digit with table B
EAN128 = EAN128 & Mid(chaine, i, 1)
i = i + 1
End If
Loop
'Calcul de la clé de contrôle / Calculation of the checksum
For i = 1 To Len(EAN128)
dummy = Asc(Mid(EAN128, i, 1))
response.Write("dummy "&dummy&"<br>")
If(dummy < 127)then
dummy=dummy - 32
response.Write("dummy menos32 "&dummy&"<br>")
else
dummy=dummy - 100
response.Write("dummy menos 100 "&dummy&"<br>")
end if

If i = 1 Then checksum = dummy
checksum = (checksum + (i - 1) * dummy) Mod 103
Next
'Calcul du code ASCII de la clé / Calculation of the checksum ASCII code
If(checksum < 95)then
checksum=checksum + 32
else
checksum=checksum + 100
end if
'Ajout de la clé et du STOP / Add the checksum and the STOP
EAN128 = EAN128 & Chr(checksum) & Chr(206)
End If
End If
Exit Function


End Function
function TestNum()
'si les mini caractères à partir de i sont numériques, alors mini=0
'if the mini characters from i are numeric, then mini=0
response.write("en TestNum<br>")
mini = mini - 1
If i + mini <= Len(chaine) Then
Do While mini >= 0
If Asc(Mid(chaine, i + mini, 1)) < 48 Or Asc(Mid(chaine, i + mini, 1)) > 57 Then Exit Do
mini = mini - 1
Loop
End If
end function

function TestNumOrFnc1()
'si les mini caractères à partir de i sont numériques ou FNC1, alors mini=0
'if the mini characters from i are numeric or Fnc1, then mini=0
response.write("en sub TestNumOrFnc1<br>")
mini = mini - 1
If i + mini <= Len(chaine) Then
Do While mini >= 0
If (Asc(Mid(chaine, i + mini, 1)) < 48 Or Asc(Mid(chaine, i + mini, 1)) > 57) And Asc(Mid(chaine, i + mini, 1)) <> 202 Then Exit Do
mini = mini - 1
Loop
End If
end function
%>
Cualquier ayuda sirve Gracias
__________________
Me junto con los que Saben, Queriendo Saber.
  #2 (permalink)  
Antiguo 14/08/2008, 10:31
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 4 meses
Puntos: 146
Respuesta: ayuda pasar funcion a asp

Donde marca error o que le falla a tu versión?
  #3 (permalink)  
Antiguo 18/08/2008, 11:01
Avatar de ACX_POISON  
Fecha de Ingreso: abril-2008
Ubicación: Talca-Chile
Mensajes: 750
Antigüedad: 16 años, 2 meses
Puntos: 7
Respuesta: ayuda pasar funcion a asp

Gracias X responder
Solucione el problema quite las dos ultimas funciones y las agrege directamente el ma funcion principal
__________________
Me junto con los que Saben, Queriendo Saber.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:09.