Should i use a GRID or something else.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
metron9
Posts: 45
Joined: Sat Sep 08, 2012 7:18 am
Location: Minnesota U.S.A.

Should i use a GRID or something else.

Post by metron9 »

The first program I am converting is our Work In Process program.
The layout so far is below.

I would like the UPDATE function to work similar to the screen attached below that shows my EMAIL.
That screen allows a check box to be checked for each line. It then has a DELETE button,
I would add a "PERFORM UPDATE" button as well to update all checked items.

I have not found a sample grid project that has a check box option.

I would also like to use the center grid to hold the work in process so that when the radio box options
are checked it changes the data in the box to reflect the filter chosen, i.e. "In Process" or "Shipped"

I also am wondering, Is the graphical FORM layout typically used to build a window and then you copy the code
and paste it into your main.PRG file so that you can edit the code?
Can I just create a new .PRG file and add a define window and paste the MAIN.FRM code into that file
and then call that .prg file to open the main window?
or
Should I just put all of that code in the MAIN.PRG file.


EDIT...(no need to answer this one (in red) I figured out how to use the #INCLUDE and store the form code in a .PRG file)



Just to clarify, the UPDATE button in the form would pull up a second data table that was created by the Job Ticket program,
Typically the list is 10 to 20 jobs, those files checked could be merged with the main work in process table,
some could be deleted if necessary if jobs were cancelled between the time the update to WIP was done.
Typically jobs are input during the day and the next morning the WIP is updated so most of the data is merged.
i would also have a "SELECT ALL" button to make it faster.

EDIT... I found the "DATA.BOUND" sample program. It seems i want a mixture of this and a grid.
Perhaps setting up screens of a maximum number of lines and then scroll bUTTON "NEXT PAGE" showing the next page of data
is what I need to do. Since there is usually just one page of data to update, this would work.
Attachments
Work In Process screen
Work In Process screen
sofar.png (40.4 KiB) Viewed 2895 times
My Email display shows check boxes
My Email display shows check boxes
grid.png (9.81 KiB) Viewed 2895 times
User avatar
metron9
Posts: 45
Joined: Sat Sep 08, 2012 7:18 am
Location: Minnesota U.S.A.

Re: Should i use a GRID or something else.

Post by metron9 »

I have continued working on the above question.
I did try this code algorithm loop below using the Macro & to build a screen.
However the macro does not work in the definition ONCHANGE
I tried using

ONCHANGE &chkboxsave

This seems like this is not the way to go but perhaps if it works do it?
I tried calling a function ONCHANGE chkboxchange(nxrow)
Again the macro & does not work for that command.

Code: Select all

 function chkboxchange(nxrow)
   chkboxfield='MAIN.Check_field'+alltrim(str(nxrow))+'.FIELD'
   replace atyes with &chkboxfield
  return nil

Code: Select all

nxrow=30
    do while .not. eof()
     jobfield="Label_job"+alltrim(str(nxrow))
     chkboxfield='Check_field'+alltrim(str(nxrow))
     chkboxsave='MAIN.'+chkboxfield+'.Save'
     
     DEFINE LABEL &jobfield
        ROW    nxrow
        COL    160
        WIDTH  50
        HEIGHT 30
        VALUE str(addwip->job)
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
     END LABEL
     
     DEFINE CHECKBOX &chkboxfield
        ROW    nxrow-6
        COL    140
        WIDTH  20
        HEIGHT 30
        CAPTION ''
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        FIELD addwip->atyes
        BACKCOLOR NIL
        FONTCOLOR NIL
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
    END CHECKBOX
     
      nxrow=nxrow+25
     skip
    enddo
Attachments
Building the screen works but not sure if i can commit the checkbox input to the data table.
Building the screen works but not sure if i can commit the checkbox input to the data table.
attempt.png (24.97 KiB) Viewed 2886 times
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Should i use a GRID or something else.

Post by esgici »

Hi Mark

You are going very speedy, I'm afraid I can't follow you ;)

For example dealing e-mails is a advanced subject for me :(
I would also like to use the center grid to hold the work in process so that when the radio box options
are checked it changes the data in the box to reflect the filter chosen, i.e. "In Process" or "Shipped"
Does PROGRESSBAR or WAIT WINDOW control will be usable for this purpose ?
I have not found a sample grid project that has a check box option.
GRID support check box; though absence of sample, surely you can achieve this.
I figured out how to use the #INCLUDE and store the form code in a .PRG file.
Yes, you can add screen definition code your project via #include directive. For adding code file to project other ways may be :

- SET PROCEDURE statement
- "Import file" in project menu,
- .hbp file manually ( and restart IDE ;) )

IMHO best way is LOAD WINDOW command; please look at herefor details.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
metron9
Posts: 45
Joined: Sat Sep 08, 2012 7:18 am
Location: Minnesota U.S.A.

Re: Should i use a GRID or something else.

Post by metron9 »

I do see now there are samples grid.01 and others.
I did not see them when I ran the program because you have to double click the column
to see the check box. I see the code and how it works now.

I have to go to work now but tonight I will try using a grid to display a set number of records
and use a list of DEFINE CHECKBOX next to the grid and use an array to hold the actual record numbers that correspond
to the checkboxes displayed.

I really want to have the box clicked and that initiates the transfer (merge with main table) of each record, updating the screen to show
only records that have not been merged.

The email screen I showed above is just the screen layout and how it functions for a table of data, not working with email data here.

i will read the link you posted when I get back home.

Thank you.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Should i use a GRID or something else.

Post by esgici »

Hi Mark
I have not found a sample grid project that has a check box option.
In ...\SAMPLES\GRID.25 trough 38 includes CHECKBOX defined in GRID row.

Probably you are searched DEFINE CHECKBOX statement; defining controls as a GRID row is a little different ;)

Regards
Viva INTERNATIONAL HMG :D
User avatar
metron9
Posts: 45
Joined: Sat Sep 08, 2012 7:18 am
Location: Minnesota U.S.A.

Re: Should i use a GRID or something else.

Post by metron9 »

Here is what I ended up doing.
I only have two lines of data so far but I will add code to do a screen of 20 items.

Point and click, i like it.

here is a video (Camtasia studio, I just upgraded to version 8, Very smooth and easy to use)
http://www.screencast.com/t/iyDQygRs920k

Firefox is not working on the screencast site, but Chrome works.

Here is the code so far for the update screen.

Code: Select all


#include "hmg.ch"

Function wiptran()

public rec [10]
public RecOnscreen :=0

	DEFINE WINDOW Win_1 ;
		ROW 0 ;
		COL 0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'Update Work In Process' ;
		WINDOWTYPE STANDARD; 
      ON INIT OPENFILES() ;
      ON RELEASE CLOSEFILES()
      
 DEFINE BUTTON Button_1
        ROW    300
        COL    10
        WIDTH  100
        HEIGHT 28
        ACTION selectall()
        CAPTION "Select All"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS NIL
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON     
      
DEFINE BUTTON Button_2
        ROW    300
        COL    110
        WIDTH  120
        HEIGHT 28
        ACTION donext()
        CAPTION "Next"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
    
     DEFINE BUTTON Button_3
        ROW    300
        COL    230
        WIDTH  100
        HEIGHT 28
        ACTION mergefiles()
        CAPTION "Merge"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
     
   
    DEFINE CHECKBOX Check_1
        ROW    20
        COL    10
        WIDTH  300
        HEIGHT 20
        CAPTION "Check_1"
        VALUE NIL
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE chg1()
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR {250,250,250}
        FONTCOLOR NIL
        HELPID Nil
        TABSTOP .T.
        VISIBLE .F.
        TRANSPARENT .F.
    END CHECKBOX
    
    DEFINE CHECKBOX Check_2
        ROW    40
        COL    10
        WIDTH  300
        HEIGHT 20
        CAPTION "Check_2"
        VALUE NIL
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE chg2()
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
        HELPID Nil
        TABSTOP .T.
        VISIBLE .F.
        TRANSPARENT .F.
    END CHECKBOX
	END WINDOW

	Win_1.Center

	Win_1.Activate
Return

function chg1()
 if Win_1.Check_1.Value = .t.
  goto rec[1]
  replace atyes with .t.
 else
  goto rec[1]
  replace atyes with .f.
 endif
return nil

function chg2()
 if Win_1.Check_2.Value = .t.
  goto rec[2]
  replace atyes with .t.
 else
  goto rec[2]
  replace atyes with .f.
 endif
return nil
 
FUNCTION OPENFILES()
SELECT 0
 NETOPEN('HELLO')
 donext()
RETURN NIL

FUNCTION CLOSEFILES()
 CLOSE HELLO
RETURN NIL

function mergefiles()
 * merge file code here
return nil

function donext()
go top
if .not. eof()
 RecOnscreen++
 rec[1]=recno()
 Win_1.Check_1.Caption := str(job)+' '+Company
 Win_1.Check_1.Visible := .t.
 Win_1.Check_1.Value := atyes
endif
 skip
 if .not. eof()
  reconscreen++
  rec[2]=recno()
  Win_1.Check_2.Caption := str(job)+' '+Company
  Win_1.Check_2.Visible := .t.
  Win_1.Check_2.Value := atyes
 endif
return nil

 function selectall()
 if RecOnscreen>0
  Win_1.Check_1.Value := .t.
  chg1()
  endif
  if RecOnscreen>1
  Win_1.Check_2.Value := .t.
   chg2()
  endif
  return nil
 
 
Post Reply