Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

SALINETAS24 wrote: Thu Mar 10, 2022 9:36 am Aquí, por arte de mágia se le añaden espacios en Blanco delante del numero en cuestión, :shock: por lo tanto (y esta es mi humilde opinión), no es un problema del GRID, más bien fruto de la función VAL y del tamaño de la cifra. ;)
SALINETAS24, the results you get are different from wat you expect because of the STR function, NOT because of the VAL function. Here the syntax:

https://vivaclipper.wordpress.com/2014/01/19/str/

When you do not pass the second and third parameter of the STR function is does not know how many spaces to return. You can fix this with the alltrim() function.

https://vivaclipper.wordpress.com/2014/01/19/alltrim/

Here your modified code with the expected result:

Code: Select all

cValor="12345678901"
MSGBOX(cValor,LEN(cValor))
nValor:=VAL(cValor)
MSGBOX(nValor,len(alltrim(str(nValor))))
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

andyglezl wrote: Thu Mar 10, 2022 8:12 pm Try with ...
@ Ren , Col GRID Gridx OF FormMain . . . . . . . FONT "Consolas" // Font Ancho fijo - Font fixed width
Andrés, thanks for your suggestion but also with the unifont "LUCIDA CONSOLE" the result is not OK...

1.png
1.png (3.68 KiB) Viewed 3099 times
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by SALINETAS24 »

trmpluym wrote: Sat Mar 12, 2022 10:13 am
----
Here your modified code with the expected result:

Code: Select all

cValor="12345678901"
MSGBOX(cValor,LEN(cValor))
nValor:=VAL(cValor)
MSGBOX(nValor,len(alltrim(str(nValor))))

Hola trmpluym, gracias por contestar. ;)

Conozco la función alltrim, :idea: pero no es ese el problema detectado en el GRID. :?:

Prueba este codigo, verás que hasta el digito 10 la respuesta es correcta, la LEN es OK con el numero, pero a partir del dígito 11 cambia la respuesta, cambia la longitud

Code: Select all

	cvar:="1234567"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)) )
	cvar:="12345678"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)))
	cvar:="123456789"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)))
	cvar:="1234567890"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)))
	cvar:="12345678901"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)))
	cvar:="123456789012"
	cvar:=val(cVar)
	msgbox(cVar,Len(STR(cVar)))



El problema que se ha detectado en el GRID esta situado en el programa "h_grid.prg", se utiliza un TEXTBOX numérico, (linea 1080), y cuando se pulsa ENTER entonces actualiza (linea 1487), simplemente coje el valor del control y lo actualiza. No utiliza ALLTRIM, no necesita saber que tipo de datos es (Alfabetico o Numerico), simplemente lo actualiza y es entonces cuando pasa ese valor y cambia la longitud si los dígitos superan 10...

No se si me he explicado, :oops: pero creo que es un problema de la "precision de los caracteres numericos en clipper".

Lo dicho, una serveseta fresqueta que esta ronda la pago yo. :lol: :lol:
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

SALINETAS24 wrote: Sat Mar 12, 2022 12:07 pm Prueba este codigo, verás que hasta el digito 10 la respuesta es correcta, la LEN es OK con el numero, pero a partir del dígito 11 cambia la respuesta, cambia la longitud
SALINETAS24 I think you are right :D It is has something to do with the STR transformation of numeric value !

I took a look at the "h_grid.prg" source.

Can you also tell me if you are using HMG 3.4.4 or 3.4.5 ( to reference the right line number ) ?
In 3.4.5 line 1487 is:

2.png
2.png (7.31 KiB) Viewed 3081 times

Or do you mean line 1486 ?

But I cannot find the line where the numeric value is converted into a string.

Theo
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by SALINETAS24 »

trmpluym wrote: Sat Mar 12, 2022 3:39 pm
... /...

SALINETAS24 I think you are right :D It is has something to do with the STR transformation of numeric value !
Gracias, creía que no me entendía nadie :lol:


Can you also tell me if you are using HMG 3.4.4 or 3.4.5 ( to reference the right line number ) ?
In 3.4.5 line 1487 is:
Uso la version 3.4.4

Or do you mean line 1486 ?

But I cannot find the line where the numeric value is converted into a string.
La linea donde asigna el valor es la 1486.., y al GRID en la linea 1568 pero no hay conversión. Directamente se asigna el valor.
Eso es lo "raro", que cuando crea el GRID tiene el ancho correcto, (será porque lo lee del DBF) y cuando lo edita ..., ya sabemos el resultado.

Un saludo,
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

SALINETAS24,

I actually found a good workaround using DYNAMICDISPLAY to fix the STR conversion.

For the numeric columns of the GRID i use the function {||AllTrim(Str(This.CellValue)) }

Here a new demo with the result ( see attachment ).

Maybe in the future some guru who understands the "Inplace Edit" better then me, can modify the "h_grid.prg" to fix this bug.

For now my workaround is the best option to work around the issue.

Thanks for taking the time to help me !

Theo
Attachments
Demo3.zip
(1.52 MiB) Downloaded 147 times
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by Claudio Ricardo »

Hi... I use cValue := Hb_NtoS ( nValue )
It work like: cValue := AllTrim ( Str ( nValue )) or cValue := Str ( nValue, LenNum ( nValue ))
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Post Reply