Alpha Video Training
Results 1 to 20 of 20

Thread: Object name with onpush indicator

  1. #1
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Object name with onpush indicator

    I have a form with multiple fields (50) one for each year and corresponding buttons that are labeled with years. The fields will have 3 options: "S", "C", or blank. I would like to create a script that retrieves the object name of the button pushed. I should be able to write the xbasic that would determine which operation to complete.

    I would like to identify (Object Name) Btn_S2000 as triggered with onpush. Find the routine that matches Btn_S2000. Within that routine determine which specs are met and then put the data in Senate->2000.


    table name -- legis_senate
    alias -- Senate

    Button -- Btn_S2000
    Field -- Senate->S2000

  2. #2
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,628

    Default Re: Object name with onpush indicator

    Gary

    This looks like a question.

    This forum is for code contribution.

    Let me know what version you are using and I'll move this post.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  3. #3
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Sorry.

    I'm using Alpha Anywhere.

  4. #4
    "Certified" Alphaholic Ray in Capetown's Avatar
    Real Name
    Ray Hendler
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    2,036

    Default Re: Object name with onpush indicator

    put the code that determines the operation to complete into a udf

    Have each button call the same function with
    Code:
    yourudf(parentform.Active())
    The paramenter received by the function will be a string with the button name.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    You can get the button object name with

    this.name

    If the field corresponding to Btn_S2000 has the object name S2000 you know that the object name of the field is

    right(this.name(),5)

    and the value in the field is eval(right(this.name(),5)+".value")

    if the field contains text you would use

    eval(right(this.name(),5)+".text")
    There can be only one.

  6. #6
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Is there any Xbasic documentation that is helpful? I've searched Alpha 5 but it appears to be very minimal. It may be that I need to obtain Xbasic background from another source.

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    I don't think you're going to find a sample code snippet in any documentation that will do what you want. It's more a question of putting the pieces together.

    For any button the object name is this.name()

    Since you have fields named similarly to the buttons you have to parse the button name to get the associated field name.
    You use that field name and its properties to obtain the field value.
    You obtain "routine that matches" by combining the field name and the field value, I'm guessing.
    There can be only one.

  8. #8
    "Certified" Alphaholic Ronald Anusiewicz's Avatar
    Real Name
    Ronald Anusiewicz
    Join Date
    Oct 2000
    Location
    Southampton, MA
    Posts
    1,583

    Default Re: Object name with onpush indicator

    I'm not sure but maybe this could help you.
    Attached Files Attached Files

  9. #9
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Right now that won't help with determining the right routines to provide the right data. But part of it should help when I turn it into a function. The this.name() and parentform.Active() appear to prove useful. I am stuck with it not providing the right data each time.


    SenateTerms.PNG


    Buttons have a year for each election. Push to automatically put right status in box to right of year. Since this is for Senate elections they mostly run for election once every six years. The years they run it should have "S". The 2 election years after should have a "C". It should blank it out if there is a "S" or "C".

    If election year box is blank and previous election is blank -- put S in.
    If election year box is blank and previous election has "C" and election before that has "C" -- put S in.
    If election year box is blank and previous election has "C" and election before that has "S" -- put C in.
    If election year box has "C" or "S" -- blank it out.

    The following is where I am with this.

    Dim Senate_Status as C
    Dim Senate_E1 as C
    Dim Senate_E2 as C
    Dim Senate_E3 as C
    Dim Tbl_Senate as C

    Tbl_Senate ="Senate->S"

    select
    'Senate 1964
    case parentform.Active() ="Btn_S1964"
    Senate_Year = val(right(this.Name(),4))
    DELETE Senate_Status
    Senate_E1 =Tbl_Senate +str(Senate_Year,4)
    Senate_E2 =Tbl_Senate +str(Senate_Year-2,4)
    Senate_E3 =Tbl_Senate +str(Senate_Year-4,4)
    select
    case isblank(Senate_E1)
    select
    case isblank(Senate_E2)
    Senate_Status = "S"
    case isnotblank(Senate_E2)
    select
    case Senate_E2 + "='S'"
    Senate_Status = "C"
    case Senate_E2 + "='C' .and. " +Senate_E3 + "='C'"
    Senate_Status = "S"
    case else
    Senate_Status =""
    end select
    case else
    Senate_Status =""
    end select
    case isnotblank(Senate_E1)
    Senate_Status =""
    case else
    Senate_Status =""
    end select
    parentform:Senate_1964.value=Senate_Status

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    Is this

    Senate_E1 = Tbl_Senate +str(Senate_Year,4)

    supposed to be getting a field value into the Senate_E1 variable?
    There can be only one.

  11. #11
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,628

    Default Re: Object name with onpush indicator

    Quote Originally Posted by Stan Mathews View Post
    Is this

    Senate_E1 = Tbl_Senate +str(Senate_Year,4)

    supposed to be getting a field value into the Senate_E1 variable?
    Looks like Gary is building the fieldname.

    Time to use debug (1) and or the trace window.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  12. #12
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Yes, Senate_E1 is the field that corresponds to the button push that will hold either "S", "C", or will be blank.
    Senate_E2 will be the field to the last election and Senate_E3 is for 2 elections previous.

    I"m getting a snag with it reporting Variable "Senate_Status" not found when there is an "S" in the last election (Senate_E2).

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    This would all be easier to diagnose with a sample database. I've never used the construction you're using.

    I think your isnotblank() test needs modification

    Code:
    Dim Senate_Status as C
    Dim Senate_E1 as C
    Dim Senate_E2 as C
    Dim Senate_E3 as C
    Dim Tbl_Senate as C
    
    Tbl_Senate ="Senate->S"
    
    select
    	'Senate 1964
    	case parentform.Active() ="Btn_S1964"
    		Senate_Year = val(right(this.Name(),4))
    		DELETE Senate_Status
    		Senate_E1 =Tbl_Senate +str(Senate_Year,4)
    		Senate_E2 =Tbl_Senate +str(Senate_Year-2,4)
    		Senate_E3 =Tbl_Senate +str(Senate_Year-4,4)
    		select
    		case isblank(Senate_E1)
    			select
    			case isblank(Senate_E2)
    				Senate_Status = "S"
    			case isnotblank(Senate_E2)
    				select
    				case Senate_E2 = "S"
    					Senate_Status = "C"
    				case Senate_E2 ="C" .and. Senate_E3 ="C"
    					Senate_Status = "S"
    				case else
    					Senate_Status =""
    			end select
    			case else
    				Senate_Status =""
    		end select
    		case isnotblank(Senate_E1)
    			Senate_Status =""
    		case else
    			Senate_Status =""
    	end select
    	parentform:Senate_1964.value=Senate_Status
    or

    Code:
    case isnotblank(Senate_E2)
    				select
    				case eval(Senate_E2) = "S"
    					Senate_Status = "C"
    				case eval(Senate_E2) ="C" .and. eval(Senate_E3) ="C"
    					Senate_Status = "S"
    				case else
    					Senate_Status =""
    			end select
    Last edited by Stan Mathews; 12-22-2014 at 01:14 PM.
    There can be only one.

  14. #14
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Here is the file. I was still testing different options. Trying to figure out how to determine the name for the field name, etc.

    Congress.zip

    The form that is in need is Terms_Senate.
    Last edited by gschepp; 12-22-2014 at 08:26 PM.

  15. #15
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Here is the file. I was still testing different options. Trying to figure out how to determine the name for the field name, etc.

    Congress.zip

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    Seems to me to work for 1970. Not all of the years are handled in the script.

    What do you see not working?
    There can be only one.

  17. #17
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    I was focusing on trying to make it work with a range of elections before expanding the remaining years. The focus was on getting the conditional object labeled Senate Terms 1976 - 2026 work first. If you were checking the range from 1904 to 1974 then click on the button between the group of years and "Serve First". Right below the button with the down green arrow.

    U.S. Senators run for election once every 6 years unless there is a special election. If a Senator is elected in 1976 there won't be an election in 1978 or 1980. Next election would be 1982.

    I am trying to have "S" enter for years that a Senator is elected. For years that they are not elected but serving enter a "C".

    1976 -- S
    1978 -- C
    1980 -- C
    1982 -- S
    When the button is pushed for 1976 it should check to see if the Senator was elected in 1974 or serving. If elected a "C" would be enter. If serving in 1974 it would check to see if was serving in 1972 (Enter "S") if elected in 1972 (Enter "C"). Pattern is 2 election (even) years between years Senators are elected.

    The range you reviewed has a problem with this issue. It will not enter any data for the year after an election with "S" entered.

    1970 -- S
    1972 --
    1974 -- S
    1976 --
    1978 -- S
    It needs to be
    1970 -- S
    1972 -- C
    1974 -- C
    1976 -- S
    1978 -- C
    It does not seem to correctly interpret the expression after the variable Senate_E1. Or I have it written wrong.

    I also attempted writing it different starting with Senate 1978.

  18. #18
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    I think I see now.

    Define a global variable for the form pushed_btn. Set it to any year you want. I used
    pushed_btn = "1904"

    Add an inline xbasic element to each button as the first action,

    dim global pushed_btn as C
    pushed_btn = right(this.Name(),4)

    The elect_senate script is then

    Code:
    dim global pushed_btn as C
    Dim Senate_Status as C
    Dim Senate_E1 as C
    Dim Senate_E2 as C
    Dim Senate_E3 as C
    Dim Tbl_Senate as C
    Tbl_Senate ="Senate->S"
    Senate_Status =""
    Senate_Year = val(pushed_btn)
    		Senate_E1 =Tbl_Senate +str(Senate_Year,4)
    		Senate_E2 =Tbl_Senate +str(Senate_Year-2,4)
    		Senate_E3 =Tbl_Senate +str(Senate_Year-4,4)
    		select
    		case isblank(Senate_E1)
    			select
    			case isblank(Senate_E2)
    				Senate_Status = "S"
    			case isnotblank(Senate_E2)
    				select
    				case Senate_E3 ="S"
    					Senate_Status = "C"
    				case Senate_E3 ="C"
    					Senate_Status = "S"
    			end select
    			case else
    				Senate_Status =""
    		end select
    		case isnotblank(Senate_E1)
    			Senate_Status =""
    		case else
    			Senate_Status =""
    	end select
    	eval("parentform:Senate_"+pushed_btn+".value") = Senate_Status
    There can be only one.

  19. #19
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Object name with onpush indicator

    I probably don't have the logic right but there's a problem in your script with the isblank() and isnotblank() statements. You're inadvertently testing whether the variables Senate_E1, etc are blank, not the table fields you intend.

    I changed from the global variable scenario I suggested and created a udf. The udf is the onpush code for each button (I changed 1976 to present). The udf has one parameter, the year portion of the button name. I change the "blank" tests to alltrim(eval(variable_name)). Eval() returns the field value. Also changed the logic a bit as well.

    Give it a try.

    Congress.zip
    Last edited by Stan Mathews; 12-23-2014 at 12:57 PM.
    There can be only one.

  20. #20
    Member
    Real Name
    Gary Schepp
    Join Date
    May 2006
    Posts
    196

    Default Re: Object name with onpush indicator

    Thanks Stan, I tweaked the case part when Senate_E2 >"". It was nearly making it work except it would leave the election year blank after 2 non elected years showing with a "C". The result was S - C - C - Blank - S - C - C - Blank. After tweaking it is now S - C - C - S - C - C.

    Replaced that section with:

    Code:
    case alltrim(eval(Senate_E2))= "S"  (Section starting with -- case alltrim(eval(Senate_E2))> "")
    	Senate_Status = "C"	
    case alltrim(eval(Senate_E2))= "C"
    	select
    		case alltrim(eval(Senate_E3)) ="S"
    			Senate_Status = "C"
    		case alltrim(eval(Senate_E3)) ="C"
    			Senate_Status = "S"	
    	end select

Similar Threads

  1. Need an Indicator to Denote More Data Available if RowExpander + Sign is Clicked On
    By gsownsby in forum Application Server Version 11 - Web/Browser Applications
    Replies: 2
    Last Post: 11-16-2011, 07:29 AM
  2. Working Indicator
    By chadbrown in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 01-20-2010, 12:06 AM
  3. Button OnPush
    By Ed Barley in forum Alpha Five Version 5
    Replies: 13
    Last Post: 10-29-2004, 03:36 PM
  4. Force OnPush event
    By richarddsmith in forum Alpha Five Version 5
    Replies: 4
    Last Post: 06-14-2003, 07:01 AM
  5. invoice printed indicator
    By john carrio in forum Alpha Five Version 4
    Replies: 1
    Last Post: 04-06-2000, 06:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •