ASORT no me ordena
Moderator: Rathinagiri
ASORT no me ordena
Buenas a todos,
Estoy con un problema con la funcion ASOFT, de un tiempo a esta parte, no me ordena el array,
Tengo la versión HMG.3.4.3 y el caso es que hace unos días si que me iba.
No se que pueda estar pasando.
he implementado algo el programa , pero nada que le deba afectar.
Gracias
Good morning everyone,
I'm having a problem with the ASOFT function, for a while this part, I do not order the array,
I have version HMG.3.4.3 and the case is that a few days ago if I was leaving.
I do not know what may be happening.
I've implemented the program somewhat, but nothing that should affect it.
Thank you
Estoy con un problema con la funcion ASOFT, de un tiempo a esta parte, no me ordena el array,
Tengo la versión HMG.3.4.3 y el caso es que hace unos días si que me iba.
No se que pueda estar pasando.
he implementado algo el programa , pero nada que le deba afectar.
Gracias
Good morning everyone,
I'm having a problem with the ASOFT function, for a while this part, I do not order the array,
I have version HMG.3.4.3 and the case is that a few days ago if I was leaving.
I do not know what may be happening.
I've implemented the program somewhat, but nothing that should affect it.
Thank you
Skydone Solutions
www.skydone.com
www.skydone.com
-
- Posts: 684
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: ASORT no me ordena
Hi AidTic:
Please post a sample to see what is going wrong.-
With regards.
Eduardo
Please post a sample to see what is going wrong.-
With regards.
Eduardo
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: ASORT no me ordena
Do you noticed ANSI / Unicode difference ?AidTIC wrote: I'm having a problem with the ASOFT function, for a while this part, I do not order the array,
...]
Happy HMG'ing

Viva INTERNATIONAL HMG 

Re: ASORT no me ordena
La verdad es que solo he probado un Unicode.
Esta es la función:
Function SelecEnvios ()
Local aEnvio := {}
Local aCEnv := {}
DO CASE
CASE dTrans->(DBSetOrder()) = "ITEMP" .and. Win_Alert.Label_1.VALUE ="Filtro por Cliente " + CLIENTES->CLI_NOMBRE // indexkey() = "str(CLI_CODIGO)+DTOS(DB_CADUCA)"
EnviarCorreo( "Productos a punto de caducar" , "body.html", "1" , clientes->CLI_CEMAIL ,) // clientes->CLI_CEMAIL )
CASE dTrans->(DBSetOrder()) = "CADUCAN" .or. dTrans->(DBSetOrder()) = "CADUCAR" .or. (dTrans->(DBSetOrder()) = "ITEMP" .and. Win_Alert.Label_1.VALUE = "Oculto Productos Caducados")
dTrans->(DBGOTOP())
aEnvio := {}
While ! dTrans->(Eof())
nDIAS := dTrans->db_caduca - date()
if nDias >= 0 .and. nDias < 31
If dTrans->DB_precli < 0.01
DO CASE
CASE ALLTRIM(dTrans->db_ARTICU) = "Alta Dominio" .OR. ALLTRIM(dTrans->db_ARTICU) = "Renovación de Dominio"
IDet := "Renovación del dominio " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "IP Dedicada"
IDet := "Renovación de la IP Dedicada " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "Alojamiento Web"
IDet := "Renovación del Alojamiento " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "Hosting"
IDet := "Renovación del Hosting " + AllTrim(dTrans->db_descri) + " :"
OTHERWISE
IDet := "Producto " + ALLTRIM(aEnviar [rEnv] [4]) + " " + AllTrim(dTrans->db_descri) + " :"
ENDcase
pventa := InputBox ( IDet , "Precio de Producto a Cero" , "Importe" , , , , 400 )
dTrans->DB_PreCli := VAL(pventa)
EndIf
IF nDIAS < 1 .and. dTrans->db_SNDCNF = "No"
dTrans->db_SNDCNF := "Si"
dTrans->db_SND005 := "Si"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
ElseIF nDIAS < 6 .and. dTrans->db_SND005 = "No"
dTrans->db_SND005 := "Si"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
elseif nDIAS < 16 .and. dTrans->db_SND015 = "No"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
elseif nDIAS < 31 .and. dTrans->db_SND030 = "No"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
EndIf
Endif
dTrans->(DBSkip())
enddo
trEnv := Len(aEnvio)
If trEnv > 0
ASort(aEnvio)
CliEnv := aEnvio [1] [1]
Aadd( aCEnv , aEnvio [1] )
For ii := 2 to trEnv
msginfo(aEnvio [ii])
IF aEnvio [ii-1] [1] <> aEnvio [ii] [1]
EnviarCorreo( "Productos a punto de caducar" , "body.html", "3" , aEnvio [ii-1] [3] , aCEnv ) // clientes->CLI_CEMAIL )
aCEnv := {}
Endif
Aadd( aCEnv , aEnvio [ii] )
Next ii
EnviarCorreo( "Productos a punto de caducar" , "body.html", "3" , clientes->CLI_CEMAIL , aCEnv ) // clientes->CLI_CEMAIL )
EndIf
OTHERWISE
msginfo (" Envio No Contemplado ")
ENDCASE
Win_Alert.grid_1.Refresh
Return
Esta es la función:
Function SelecEnvios ()
Local aEnvio := {}
Local aCEnv := {}
DO CASE
CASE dTrans->(DBSetOrder()) = "ITEMP" .and. Win_Alert.Label_1.VALUE ="Filtro por Cliente " + CLIENTES->CLI_NOMBRE // indexkey() = "str(CLI_CODIGO)+DTOS(DB_CADUCA)"
EnviarCorreo( "Productos a punto de caducar" , "body.html", "1" , clientes->CLI_CEMAIL ,) // clientes->CLI_CEMAIL )
CASE dTrans->(DBSetOrder()) = "CADUCAN" .or. dTrans->(DBSetOrder()) = "CADUCAR" .or. (dTrans->(DBSetOrder()) = "ITEMP" .and. Win_Alert.Label_1.VALUE = "Oculto Productos Caducados")
dTrans->(DBGOTOP())
aEnvio := {}
While ! dTrans->(Eof())
nDIAS := dTrans->db_caduca - date()
if nDias >= 0 .and. nDias < 31
If dTrans->DB_precli < 0.01
DO CASE
CASE ALLTRIM(dTrans->db_ARTICU) = "Alta Dominio" .OR. ALLTRIM(dTrans->db_ARTICU) = "Renovación de Dominio"
IDet := "Renovación del dominio " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "IP Dedicada"
IDet := "Renovación de la IP Dedicada " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "Alojamiento Web"
IDet := "Renovación del Alojamiento " + AllTrim(dTrans->db_descri) + " :"
CASE ALLTRIM(dTrans->db_ARTICU) = "Hosting"
IDet := "Renovación del Hosting " + AllTrim(dTrans->db_descri) + " :"
OTHERWISE
IDet := "Producto " + ALLTRIM(aEnviar [rEnv] [4]) + " " + AllTrim(dTrans->db_descri) + " :"
ENDcase
pventa := InputBox ( IDet , "Precio de Producto a Cero" , "Importe" , , , , 400 )
dTrans->DB_PreCli := VAL(pventa)
EndIf
IF nDIAS < 1 .and. dTrans->db_SNDCNF = "No"
dTrans->db_SNDCNF := "Si"
dTrans->db_SND005 := "Si"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
ElseIF nDIAS < 6 .and. dTrans->db_SND005 = "No"
dTrans->db_SND005 := "Si"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
elseif nDIAS < 16 .and. dTrans->db_SND015 = "No"
dTrans->db_SND015 := "Si"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
elseif nDIAS < 31 .and. dTrans->db_SND030 = "No"
dTrans->db_SND030 := "Si"
Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
EndIf
Endif
dTrans->(DBSkip())
enddo
trEnv := Len(aEnvio)
If trEnv > 0
ASort(aEnvio)
CliEnv := aEnvio [1] [1]
Aadd( aCEnv , aEnvio [1] )
For ii := 2 to trEnv
msginfo(aEnvio [ii])
IF aEnvio [ii-1] [1] <> aEnvio [ii] [1]
EnviarCorreo( "Productos a punto de caducar" , "body.html", "3" , aEnvio [ii-1] [3] , aCEnv ) // clientes->CLI_CEMAIL )
aCEnv := {}
Endif
Aadd( aCEnv , aEnvio [ii] )
Next ii
EnviarCorreo( "Productos a punto de caducar" , "body.html", "3" , clientes->CLI_CEMAIL , aCEnv ) // clientes->CLI_CEMAIL )
EndIf
OTHERWISE
msginfo (" Envio No Contemplado ")
ENDCASE
Win_Alert.grid_1.Refresh
Return
Skydone Solutions
www.skydone.com
www.skydone.com
Re: ASORT no me ordena
Hola AidTIC
El ejemplo que pongas, debe de ser funcional ya que de otra forma no lo podemos probar...
--------------------------------------------------------------------------------------------------------------
Hi AidTIC
The example that you put, must be functional since otherwise we can not prove ...
Lo siguiente demuestra que la funcion ASort() está funcionando, quizá es algo mas de tu programa.
------------------------------------------------------------------------------------------------------------------------
The following shows that the ASort () function is working, maybe it is something more than your program.
El ejemplo que pongas, debe de ser funcional ya que de otra forma no lo podemos probar...
--------------------------------------------------------------------------------------------------------------
Hi AidTIC
The example that you put, must be functional since otherwise we can not prove ...
Lo siguiente demuestra que la funcion ASort() está funcionando, quizá es algo mas de tu programa.
------------------------------------------------------------------------------------------------------------------------
The following shows that the ASort () function is working, maybe it is something more than your program.
Code: Select all
FUNCTION Sortea()
LOCAL aPSort:= {}
Aadd( aPSort , "5" )
Aadd( aPSort , "1" )
Aadd( aPSort , "7" )
Aadd( aPSort , "2" )
Aadd( aPSort , "9" )
Aadd( aPSort , "4" )
ASort( aPSort )
MSGDEBUG( aPSort )
RETURN NIL
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
ASORT no me ordena
En primero lugar, estás creando un ARRAY multidimensional y para ASort se necesita que sea UNIDIRECCIONAL (un solo campo digamos).AidTIC wrote:Aadd( aEnvio , { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
..//..
ASort(aEnvio)
Y en segundo precisarias atribuir a otra ARRAY o a la misma con el resultado del ASort.
Ejemplificando de forma sintética:
Code: Select all
aEnvio1:={"001","002,"003",004"}
aEnvio2:={}
AADD(aEnvio2, { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
SKIP
AADD(aEnvio2, { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
SKIP
AADD(aEnvio2, { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
SKIP
AADD(aEnvio2, { dTrans->CLI_CODIGO , clientes->CLI_NOMBRE , clientes->CLI_CEMAIL , dTrans->DB_Articu , dTrans->DB_Descri , dTrans->DB_precli , dTrans->db_caduca } )
aOrdenado:=ASort(aEnvio1)
Code: Select all
aResultado:={}
For i=1 Len(aOrdenado)
cBusca:=aOrdenado[i]
nPosArray:= AScan(aEnvio1,cBusca)
AADD(aResultado,{aEnvio2[1,i],aEnvio2[2,i],aEnvio2[3,i], aEnvio2[4,i]... hasta 7)
Hay otras formas de hacerlo tambien. Esta es la que se me ocurrio ahora. Fijate aEnvio1 que yo utilizo string para campos numéricos y de preferencia con StrZero(dTrans->CLI_CODIGO,4,0) el 4 es por asi decir el tamaño máximo, puede ser otro valor para que lo arrebiente con la capacidad máxima. Pero al hacerlo con ceros es más seguro que hacer con espacios vacios.
AidTIC, como es tu nombre ? Seria bueno, que en tu próximos mensajes coloques tus códigos entre la TAG Code, asi se puede leer mejor.
Espero que hayas podido entenderme. Sinó posteá tu código y tus dudas.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- srvet_claudio
- Posts: 2220
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: ASORT no me ordena
Los array multidimensional se ordenan pasando un cb a Asort, ej
Code: Select all
bSort := {|a,b| a [3] > b [3]}
Re: ASORT no me ordena
srvet_claudio wrote:Los array multidimensional se ordenan pasando un cb a Asort, ejCode: Select all
bSort := {|a,b| a [3] > b [3]}
Que quieres decir con "cb"
Skydone Solutions
www.skydone.com
www.skydone.com
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
ASORT no me ordena
cb = CodeBlock, Sr. AidTICAidTIC wrote:Que quieres decir con "cb"
Parece que fué lo único que te importó...

Lo tendré en cuenta for next time...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: ASORT no me ordena
Solucionado,
No había caído en los array multidimensional . Muchas gracias por vuestro tiempo y sabiduría.
Por cierto mi nombre es Martin.
Code: Select all
[color=#000080] ASort(aEnvio ,,, {| x, y | x [1] <y [1]})[/color]
Por cierto mi nombre es Martin.
Skydone Solutions
www.skydone.com
www.skydone.com