
-----------------------------------
haayyeess
Thu Dec 24, 2015 9:52 am

Column Display w/ Multiple Fields, only three on at once
-----------------------------------
What is it you are trying to achieve?

Hi guys,

I am creating a display routine for a record database.  I desire to create a columned display allowing up to three of about 12 fields to be displayed.  I want the user to be able to press singular keys in order to add or remove a field from the display.  For example, if they press 'a', then I want the first names to be displayed in a column, and if they press 'a' again, I want it to be removed.  If 'a' has been pressed and set true, or on, and the user presses 'b' to display last names, I want it to appear in the second column.  In the event the user removes the first name selection, i would like to have last names shift into the first column.  If the user has three selections, they will be forced to remove one prior to adding a new one. I further desire the user to be able to select a record using a number to pull up a full form view of that record (another display i already have).  Also, there will be more records than can show on screen.  Can I have the user be able to page up and down through the records on the lower half of the screen?


What is the problem you are having?
I want to be able to handle a large amount of records (greater than what will fit on screen when displayed) without forcing the user to page through all of them.

Describe what you have tried to solve this problem
This is best seen in the code I have attached.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




/*

 %%%%%%%%%%%%%%%%%%%%%%%%%%%% DISPLAY TEXT COLUMNS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 NOTE:  Please see the 'Main Menu' for a detailed menu including build info.
 Please be advised that this subprogram uses global consts n vars ..
 ..  which have been declared in 'Main Menu.t'

 "Display Text Columns" is a subprogram which will display the users data in
 a columned fashion.  In the future, this subprogram will have advanced features.
 These advanced features will include the ability for a user to choose the fields
 that will be displayed in a columned fashion up to a max when no more will fit
 on the screen.

 %*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*
 %*%                              VARIABLE LIST                             %*%
 %*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*
 Font1, Font2: Custom fonts, menus/titles, to stand out and improv. user exper.
 Person: array containing good record data entered into PERSON_RECORD_DATA
 RecordCount: Count watching the amt of data entered (amt of records), nums
 Columns: Tracks the # of columns, and prevents exceeding a val to keep nice
 Count: Counter to watch the amount of records on screen so it doesnt run off
 %NEEEDS TO BE UPDATED
 */


procedure Display_Text_Columns (Person : PERSON_ARRAY, RecordCount : nat1)

    %LOCAL VARIABLES
    var FirstOn : boolean
    var LastOn : boolean
    var MidOn : boolean
    var TownOn : boolean
    var HouseNumOn : boolean
    var PostalOn : boolean
    var ProvOn : boolean
    var CountryOn : boolean
    var PhoneNumOn : boolean
    var FirstChildOn : boolean
    var SecondChildOn : boolean
    var HowManyOn : nat1 %Counter to track amount of displays on
    var Columns : nat1     % Numeric counter, currently wont exceed 2
    var Count : nat1    % Numeric Counter, won't exceed 20 (on screen limit)
    var RecordIndex : nat1
    var LoopCount : nat1

    %LOCAL VARIABLE ASSIGNMENTS
    FirstOn := false
    LastOn := false
    MidOn := false
    TownOn := false
    HouseNumOn := false
    PostalOn := false
    ProvOn := false
    CountryOn := false
    PhoneNumOn := false
    FirstChildOn := false
    SecondChildOn := false
    HowManyOn := 0
    Columns := 1

    %Count := 1 %moved inside of loop

    cls %clear menu

    if RecordCount > 0 then
        loop
            Count := 1
            colour (brightpurple)
            drawfillbox (5, 365, 635, 270, purple)
            drawfillbox (15, 355, 625, 280, black)
            %Draw Choices on screen top
            Font.Draw ("Please select up to three fields to display",
                70, 375, Font1, brightpurple)
            Font.Draw ("Please select up to three fields to display",
                68, 377, Font1, black)
            Font.Draw ("a. First Name", 20, 335, Font2, white)
            Font.Draw ("b. Last Name", 20, 320, Font2, white)
            Font.Draw ("c. Middle Name", 20, 305, Font2, white)
            Font.Draw ("d. Town", 20, 290, Font2, white)
            Font.Draw ("e. House Number", 220, 335, Font2, white)
            Font.Draw ("f. Postal Code", 220, 320, Font2, white)
            Font.Draw ("g. Province", 220, 305, Font2, white)
            Font.Draw ("h. Country", 220, 290, Font2, white)
            Font.Draw ("i. Phone Number", 420, 335, Font2, white)
            Font.Draw ("j. First Child Name", 420, 320, Font2, white)
            Font.Draw ("k. Second Child Name", 420, 305, Font2, white)
            Font.Draw ("*Press X to exit*", 420, 290, Font2, brightred)

            %Get Input
            getch (Choice)

            %Check for letter vs number, ignore rest
            %Letter Check
            if Choice > "@" and Choice < "


Please specify what version of Turing you are using


-----------------------------------
Insectoid
Thu Dec 24, 2015 10:30 pm

RE:Column Display w/ Multiple Fields, only three on at once
-----------------------------------
To add/remove/shift fields in the display, you could use 3 variables (or an array of size 3) to store what field goes into what column. Give every field a unique identifier and store that identifier in the variable that represents the column it is to be drawn to. Say you're using integers. first name = 1, last name = 2, etc. and nothing (empty column) = 0. Our three variables are column(1), column(2), and column(3). To add first names to the view, change one of the columns to 1. To add last names, change one to 2. To delete one, shift everything to the right of that field one space to the left, and change column(3) to 0 (aka empty). 

Now, when you draw your table, look at those three column variables. If column(1) = 1, then draw first names in column 1, etc. If it's 0, then don't draw that column. 

The important thing is properly updating those three variables when you add or remove fields or you'll end up with a blank column in the middle or a field overwriting another instead of appending to the end of the list.

Making this work might require restructuring your entire draw routing and even how you store your data. I dunno, I haven't seen your code. 

As for scrolling, well, implementing a scroll wheel is a pain in the ass, but doing simple page ups/downs isn't too hard. Keep a page counter variable. When the page down button is pressed, increment the page counter. When you draw your records, instead of starting from the first, start from (page counter * max records per page). So if you draw 10 per page, then page 2 starts at 2*10=record #20.

-----------------------------------
haayyeess
Fri Dec 25, 2015 10:55 pm

Re: Column Display w/ Multiple Fields, only three on at once
-----------------------------------
Thanks for the reply Insectoid!  I solved both issues.  Thank you for the support.
