grid problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

grid problem

Post by franco » Fri Feb 03, 2017 11:57 pm

Hi to all,
Using hmg3.2.1
Am still having some troubles with grid. I used to have this problem before but has not happened for quit a while.
As the picture shows, it looks to me as the foreground and backround become the same so you can not read grid lines.
It looks like the grid can not refresh or link to table. If I go out of the grid and back in from main menu
the lines are still black. I need to close the whole program then restart everything is ok again.
This screen is a review of a finalized invoice. new items can not be added but available function keys can still be used and work.
This grid is linked to a table.
Any ideas... All the best to all Franco
Attachments
IMG_20170203_114849 (1).jpg
IMG_20170203_114849 (1).jpg (1.68 MiB) Viewed 666 times

User avatar
Rathinagiri
Posts: 5166
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 129 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sat Feb 04, 2017 3:46 am

Can you give a small sample?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Sat Feb 04, 2017 5:13 am

This is the heart of my pos system and goes to many procedures. I was hoping someone may have had same problem of having the grid
blank this way. I can post a sample of the grid, but it is straight forward. This does not happen very often. I can do 50 invoices without a problem.
Then by just opening the invoice window it can happen. I am using a fairly big file and to filter the right items I index to a temporary index for the
items = the right field value. This is the fastest and safest way I found to filter items without using a temp table or array. The table is updated right away with no chance of data loss. I then delete the temp index file. What would cause the grid to loose visiblity, the rows still are there but blank.
when I restart program everything is fine. When the window starts and on every change I do a grid.save, could this do it.
Franco

User avatar
Rathinagiri
Posts: 5166
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 129 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sat Feb 04, 2017 5:53 am

Are you using Virtual Grid? If your user has to be in the grid for more time, better the data for the grid being managed by you and not the windows.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Sat Feb 04, 2017 8:00 am

I do not know how to set for code ,but here is the window, grid and savecell procedure where problem is.
You may be able to see something wrong in here. If we need to make it run I may have take out some update code
but this is the whole grid and window.
******************************************************************
#include <hmg.ch>

Function Main
private mord:=0, v_tot:=0, V_tax1:=0, V_tax2:=0, where, ptotal:=0, chprint:= 'T'
IF .NOT. ISWINDOWACTIVE(FORM_GRID_IN2)
DEFINE WINDOW Form_Grid_IN2 ;
AT 30, 5 ;
WIDTH 1050 ;
HEIGHT 560 ;
TITLE 'Invoicing' ;
MODAL ;
NOSIZE

ON KEY F1 OF Form_Grid_IN2 ACTION HELPING('CRSWIN.HLP')
ON KEY F3 OF FORM_GRID_IN2 ACTION { || DelFromInv() }
ON KEY F4 OF FORM_GRID_IN2 ACTION { || AddToInvoice('Add to Invoice') }
ON KEY ALT+I OF FORM_GRID_IN2 ACTION { || {Minsert := .T.},{AddToInvoice('Insert Above Current On Invoice')},{Minsert:=.F.} }
ON KEY F9 OF FORM_GRID_IN2 ACTION { || DISINV() }
ON KEY F5 OF FORM_GRID_IN2 ACTION { || {FORM_GRID_IN2.BUTTON_3.SETFOCUS} , ;
{ if(typ='R',Refliney('P_INV'),Refliney('INVOICE')) },{FORM_GRID_IN2.LABEL_1.VALUE := 'CUSTOMER '+CUSTOMER->NAME},;
{FORM_GRID_IN2.GRID_2.SETFOCUS}}
ON KEY F6 OF FORM_GRID_IN2 ACTION { || INVPROFIT() }
ON KEY F11 OF FORM_GRID_IN2 ACTION{ modmem(alltrim(inv_no)) }
ON KEY F12 OF FORM_GRID_IN2 action { msgbox('Not in Use at This Time') }
ON KEY F10 OF FORM_GRID_IN2 ACTION { || ADJINVCOST(),{Form_Grid_IN2.Grid_2.SETFOCUS} }


DEFINE GRID Grid_2
ROW 60
COL 280 //140
WIDTH 750 //1100
HEIGHT 310 //370
BACKCOLOR { 180, 180, 200}
FONTCOLOR { 0, 0, 0 }
HEADERS {'Item','Qty','Description','Retail','Sellprice','Total','Pst/Gst'}
WIDTHS {130,70,195,90,100,100,60 } //sellprice, sellpricee,cost,100}
COLUMNCONTROLS { {'TEXTBOX','CHARACTER','!!!!!!!!!!!!!!!'},{'TEXTBOX','NUMERIC','9999.99'},;
{'TEXTBOX','CHARACTER','!!!!!!!!!!!!!!!!!!!!!!!!!!'},{'TEXTBOX','NUMERIC','9999999.99'},{'TEXTBOX','NUMERIC','9999999.99'},;
{'TEXTBOX','NUMERIC','9999999.99'},{'TEXTBOX','CHARACTER','!!!!!'} }

ROWSOURCE "pinv_it"
COLUMNFIELDS { 'ITEM' , 'QTY','DESC', 'LIST','UNIT_PRICE','VAL(STR(QTY*UNIT_PRICE,10,2))',;
'STR(TAX1,1,0)+" / "+STR(TAX2,1,0)'}
JUSTIFY { GRID_JTFY_LEFT,GRID_JTFY_RIGHT, GRID_JTFY_LEFT,GRID_JTFY_RIGHT,GRID_JTFY_RIGHT,GRID_JTFY_RIGHT }
IF TYP = 'R'
COLUMNWHEN { { || .F. },{ || .F. }, { || .F. },{ || .F. },{ || .F. },{ || .F. },{ || .F. }}
ELSE
COLUMNWHEN { { || .T. },{ || .T. }, { || .T. },{ || .T. },{ || .T. },{ || .F. },{ || .F. }}
ENDIF
VALUE {1,1}
TABSTOP .F.
ONCHANGE { || SAVEINVOICECELL()}
ongotfocus { ||{WHERE := 'G'},{SAVEINVOICECELL()}}
onlostfocus { || {Form_Grid_IN2.button_1.setfocus}} //for touch screen
IF SUBSTR(PINV_IT->PRODUCT,1,4) <> 'FUEL'
ALLOWEDIT .T.
ENDIF
ALLOWAPPEND .T.
ALLOWDELETE .T.
END GRID

END WINDOW
select pinv_it

PO = ''
Form_Grid_IN2.Text_1.Readonly := .T.
Form_Grid_IN2.Text_2.Readonly := .T.
Form_Grid_IN2.Text_3.Readonly := .T.
Form_Grid_IN2.Text_4.Readonly := .T.
Form_Grid_IN2.Label_12.Visible := .F.

If Controls->Shipto <> 'Y'
Form_Grid_IN2.Button_144.Visible := .F.
Form_Grid_IN2.Label_11.Visible := .F.
Endif
Form_Grid_IN2.GRID_2.SetFocus
IF TYP = 'R'
Form_Grid_IN2.BUTTON_1.ENABLED := .F.
Form_Grid_IN2.BUTTON_2.ENABLED := .F.
Form_Grid_IN2.BUTTON_5.ENABLED := .F.
Form_Grid_IN2.BUTTON_6.ENABLED := .F.
Form_Grid_IN2.BUTTON_7.ENABLED := .F.
Form_Grid_IN2.BUTTON_11.ENABLED := .F.
ENDIF
Form_Grid_IN2.Activate
ELSE
MSGINFO('ALREADY IN USE')
ENDIF
RETURN NIL


*------------------------------------------------------------------------------SAVEINVOICECELL
PROCEDURE SAVEINVOICECELL
*------------------------------------------------------------------------------
Local aValCell, MQ, VQ, OQ, NQ, INUM1
PRIVATE MTOT ,MTOTAL, MTAX1, MTAX2, VPROD2
MTOT := 0
MTOTAL := 0
MTAX1 := 0
MTAX2 := 0
OQ:=0
NQ:=0
VPROD2 := ''
SELECT PINV_IT
*UPINV()
INUM1 := PINV_IT->ITEM_NO
aValCell := Form_Grid_IN2.Grid_2.VALUE
IF SUBSTR(PRODUCT,1,4) = 'FUEL'
Form_Grid_IN2.Label_12.value := "Fuel: "+ alltrim(str(pinv_it->fuel_qty,10,3))+' @ '+ ;
alltrim(str(pinv_it->fuel_price,10,3))+ ' Gst Included: '+ ;
alltrim(str(pinv_it->fueltax,10,2))
Form_Grid_IN2.Label_12.Visible := .T.
IF AVALCELL[2] = 2 .OR. AVALCELL[2] = 3 .OR. AVALCELL[2] = 4 .OR. AVALCELL[2] = 5
Form_Grid_IN2.Grid_2.ClearBuffer
ENDIF
SUM ROUND(PINV_IT->QTY*PINV_IT->UNIT_PRICE,2) TO MTOT
SUM (PINV_IT->QTY*PINV_IT->UNIT_PRICE)*CONTROLS->TAX1 TO MTAX1 FOR PINV_IT->TAX1 = 1
MTAX1 := ROUND(MTAX1,2)
SUM (PINV_IT->QTY*PINV_IT->UNIT_PRICE)*CONTROLS->TAX2 TO MTAX2 FOR PINV_IT->TAX2 = 1
MTAX2 := ROUND(MTAX2,2)
MTOTAL := MTOT+MTAX1+MTAX2
Form_Grid_IN2.TEXT_1.VALUE := MTOT
Form_Grid_IN2.TEXT_2.VALUE := MTAX1
Form_Grid_IN2.TEXT_3.VALUE := MTAX2
Form_Grid_IN2.TEXT_4.VALUE := MTOTAL
Form_Grid_IN2.Grid_2.value := AVALCELL[1]
RETURN
ELSE
Form_Grid_IN2.Label_12.Visible := .F.
ENDIF
IF AVALCELL[2] = 1
SELECT INV
SEEK INUM1
VPROD2 := Pinv_it->PRODUCT
REM_DUP()
SELECT PINV_IT
*INUM1 := PINV_IT->ITEM
IF INV->STOCKING = 'Y'
IF ITEM <> ITEM_NO
IF RLOCK()
REPLACE ITEM WITH ITEM_NO
UNLOCK
ENDIF
ENDIF
ENDIF
ENDIF

IF AVALCELL[2] = 2
INUM1 := PINV_IT->ITEM_NO
SELECT INV
SEEK INUM1 //INV_ITEM->ITEM_NO
IF ! EOF()
IF INV->STOCKING = 'Y' //ALLTRIM(NUM2) <> '0'
VPROD2 := Pinv_it->PRODUCT
REM_DUP() // CHECKS FOR DUPLICATE ITEM
IF ! RLOCK()
MSGBOX('Can not lock item')
SELECT PINV_IT
Form_Grid_IN2.Grid_2.ClearBuffer
VPROD2:= ''
RETURN
ENDIF
ENDIF
SELECT PINV_IT
ENDIF
SELECT PINV_IT
ENDIF
SELECT PINV_IT
OQ := PINV_IT->QTY
Form_Grid_IN2.Grid_2.Save
Form_Grid_IN2.Grid_2.VALUE := AVALCELL
IF PINV_IT->ITEM_NO = 'REC/ACC'
NQ := 1
ELSE
NQ := PINV_IT->QTY
ENDIF
IF NQ <> OQ
IF INV->DECIMAL <> 'Y' //INV->LOCATION <> 'DECIMAL'
NQ := INT(NQ)
IF RLOCK()
PINV_IT->QTY := NQ
UNLOCK
ENDIF
*** UPDATE INVENTORY
SELECT INV
IF INV->STOCKING = 'Y' //ALLTRIM(NUM2) <> '0'
IF RLOK()
IF OQ >NQ
REPLACE QTYONHAND WITH QTYONHAND + (OQ-NQ)
ELSE
REPLACE QTYONHAND WITH QTYONHAND - (NQ-OQ)
ENDIF
SELECT INV
UNLOCK
ENDIF
ENDIF
ENDIF
ENDIF
Form_Grid_IN2.Grid_2.Save

select pinv_it


IF AVALCELL[2] = 1 .OR. AVALCELL[2] = 2 .OR. AVALCELL[2] = 5 .OR. AVALCELL[2] = 5
SUM ROUND(PINV_IT->QTY*PINV_IT->UNIT_PRICE,2) TO MTOT
SUM (PINV_IT->QTY*PINV_IT->UNIT_PRICE)*CONTROLS->TAX1 TO MTAX1 FOR PINV_IT->TAX1 = 1
MTAX1 := ROUND(MTAX1,2)
SUM (PINV_IT->QTY*PINV_IT->UNIT_PRICE)*CONTROLS->TAX2 TO MTAX2 FOR PINV_IT->TAX2 = 1
MTAX2 := ROUND(MTAX2,2)
MTOTAL := MTOT+MTAX1+MTAX2
Form_Grid_IN2.TEXT_1.VALUE := MTOT
Form_Grid_IN2.TEXT_2.VALUE := MTAX1
Form_Grid_IN2.TEXT_3.VALUE := MTAX2
Form_Grid_IN2.TEXT_4.VALUE := MTOTAL
*UPINV()
ENDIF
SELECT PINV_IT
Form_Grid_IN2.Grid_2.VALUE := aValCell

return
****************************************************************************************

User avatar
serge_girard
Posts: 1838
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 279 times
Been thanked: 63 times
Contact:

Post by serge_girard » Sat Feb 04, 2017 12:53 pm

Franco, Without DBF (at least STRU) hard to simulate !

Serge

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Sat Feb 04, 2017 6:04 pm

I am using windows 8.1 64 bit for my HMG
Do you think I should use a newer HMG then 3.2.1 or use 32 bit for compiling.
Is it possible it`s the computer or the hmg. This is very random, I can not keep track of a sequence when it happens.
It happens on client 7 pro and client win 8 .
Can you think of a way to reset the grid as like I said,everything seems to be there but grid won`t come back. I could use f12 to do
something when it happens, until I can figure this out.
Also I use tables not a database. I open and close the tables as I use them. I open 5 tables for the invoicing we are looking at, then close them
when finished. Also I use memo...read edit write for my invoice information. It could be easier to use an editbox but I do not know where
the information is. I remove memofiles by date when wanted or every 3 years. Some memo files become 1 or 2 pages of infomation. Not every
invoice has a memo file. I know it is hard following someone elses code. I could put notes on the above code for each table.. could help.
Thanks Franco

User avatar
mol
Posts: 2842
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 119 times
Been thanked: 65 times
Contact:

Post by mol » Mon Feb 06, 2017 8:40 am

As my friend Edward Kościuk reported, this black rows are bounded with divide by 0 error and error handler.
The solution is to change DefError function

Code: Select all

STATIC FUNCTION DefError( oError )

   LOCAL cMessage

   LOCAL cDOSError

 

   LOCAL n

   Local Ai

 

   //Html Arch to ErrorLog

   LOCAL HtmArch, xText

 

//   _HMG_SYSDATA [ 347 ] := .F.      <- Here is the reason of missing lines refresh of Grid, this register is responsible for automatic grid refresh * _HMG_SYSDATA [ 347 ] -> Grid Automatic Update

 

   // By default, division by zero results in zero

   IF oError:genCode == EG_ZERODIV

      RETURN 0

   ENDIF

 

   // Set NetErr() of there was a database open error

   IF oError:genCode == EG_OPEN .AND. ;

      oError:osCode == 32 .AND. ;

      oError:canDefault

      NetErr( .T. )

      RETURN .F.

   ENDIF

 

   // Set NetErr() if there was a lock error on dbAppend()

   IF oError:genCode == EG_APPENDLOCK .AND. ;

      oError:canDefault

      NetErr( .T. )

      RETURN .F.

   ENDIF

 

 

   _HMG_SYSDATA [ 347 ] := .F.     <-  When you move problematic line here, everything works OK.

 

 

   HtmArch := Html_ErrorLog()

   cMessage := ErrorMessage( oError )

   IF ! Empty( oError:osCode )

      cDOSError := "(DOS Error " + LTRIM( STR( oError:osCode ) ) + ")"

   ENDIF

 

   // "Quit" selected

 

   IF ! Empty( oError:osCode )

      cMessage += " " + cDOSError

   ENDIF

   Html_LineText(HtmArch, '<p class="updated">Date:' + Dtoc(Date()) + "  " + "Time: " + Time() )

   Html_LineText(HtmArch, cMessage + "</p>" )

   n := 2

   ai = cmessage + CHR(13) + CHR (10) + CHR(13) + CHR (10)

   WHILE ! Empty( ProcName( n ) )

      xText := "Called from " + ProcName( n ) + "(" + ALLTRIM( STR( ProcLine( n++ ) ) ) + ")" +CHR(13) +CHR(10)

      ai = ai + xText

      Html_LineText(HtmArch,xText)

   ENDDO

   Html_Line(HtmArch)

 

   ShowError(ai)

 

   QUIT

 

   RETURN .F. 

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Tue Feb 07, 2017 12:21 am

Mol, Thank you for the response.
Is it only a divide by 0. I will check it out.
Can you tell me where to get to deferror() to change it.
Thanks Franco

User avatar
mol
Posts: 2842
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 119 times
Been thanked: 65 times
Contact:

Post by mol » Tue Feb 07, 2017 6:41 am

You need to modify hmg\Source\ErrorSys.prg file

Post Reply