Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Progressive Lookup Function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Progressive Lookup Function

    It appears that some of the code in my previous message was cut off?

    The full code is now in the attached text file.

    Alan

    Comment


    • #17
      Re: Progressive Lookup Function

      Jim

      I have studied your progressive lookup threads, and feel your approach could give me some answers in a very tricky problem i posted yesterday.

      Basically I have to search for the occurrence of hundreds of key words, within a memo field.

      I documented my approach and problem here, and would be in great debt to you for any suggestions and or ideas that could help.

      cheers
      keven

      http://msgboard.alphasoftware.com/al...ad.php?t=69365
      Logical Design
      Keven Thibeault
      Boston, Massachusetts
      Dwell in possibility

      Comment


      • #18
        Re: Progressive Lookup Function

        Originally posted by Alan Lucas View Post

        The full code is now in the attached text file.

        Alan
        Here is a correction to the correction to keep this function as fast as possible...

        Since the variable i wasn't being changed with by the increment_value() function, the entire table was being scanned. Not a problem with a small number of records, but on larger numbers of records it's crippling.

        Code:
             i = 1
            while i <= vCount .and. .not. vTable.fetch_eof()
                vKey = vIndex.key_get()
                BuildList = BuildList + "{data="+padl(alltrim(str(vKey.record)),10,"0")+"}"+ vKey.key + crlf() 
                vTable.fetch_next()       
        '        increment_value(i)  ' old code   
                [B][COLOR=Red]i=increment_value(i) ' change of old code[/COLOR][/B]
            end while
        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.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


        • #19
          Re: Progressive Lookup Function

          Has anyone noticed that the latest mods to the Prog Lkup now give a display box with two (2) vertical scroll bars and when scrolling with the most right hand one, you can freeze up the display box????

          I have no idea how to fix it or I would and then post it...

          D

          Comment


          • #20
            Re: Progressive Lookup Function

            D

            I see that but haven't had the freeze.

            Do you have the mod that I added?

            Also, what I see in those 2 scroll bars is an interesting situation. Given the way this function works, the inside scroll bar scrolls through records already retrieved and the outer scroll bar scrolls through the entire table.

            I can see where not having the mod that I added might cause a 'freeze' - or slow response in a larger table.

            With what mod did you see this double scroll bar appear?

            Thanks for sharing...
            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.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


            • #21
              Re: Progressive Lookup Function

              Al,
              I am using the latest revision of the prog lkup, with your last mod.
              I cannot duplicate the problem. It appeared ONLY in 4 very small lookup tables containing numeric data only. The problem occurred whenever I would hold the down arrow (for the table, not the visible data in the box) and go past EOF on these small tables. Also, the last record lookup data would sometimes repeat if the table data did not completely fill the dialog box.
              Using larger tables seems to 'overcome' the problem. The dialog box will still go 'blank' when passing EOF using the outside down arrow; but pressing the outside up arrow will bring back correct 'active' data.
              Not sure there is a problem, and not sure I like the second scroll bar (YET).

              thanx for your response and hope to see you again at the next conference.

              D

              Comment


              • #22
                Re: Progressive Lookup Function

                Originally posted by dik_coleman View Post
                The problem occurred whenever I would hold the down arrow (for the table, not the visible data in the box) and go past EOF on these small tables.
                Like my doctor told me - don't do that... :p

                Originally posted by dik_coleman View Post
                Also, the last record lookup data would sometimes repeat if the table data did not completely fill the dialog box.
                Can you send me your tables and code so I can look at it?
                I can send you a link to upload or you can email it directly.

                Originally posted by dik_coleman View Post
                thanx for your response and hope to see you again at the next conference.

                D
                God willing and a fair wind, we'll be at the conference again.
                It was good to see you at this year's conference and hopefully I'll see you and many others at the next one...
                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.
                "Make it as simple as possible, but not simpler."
                Albert Einstein

                http://www.iadn.com/images/media/iadn_member.png

                Comment


                • #23
                  Re: Progressive Lookup Function

                  ooops here I go again ---

                  It may only be me, but would someone look at the latest 'hot' version of this lookup and tell me where <Cancel> is handled on the initial lookup screen.
                  Not the form that may be used to display the data, the actual dialog box that contains the names, etc.....

                  I can't find it anywhere...... I would like to be able to completely cancel the entire operation from that <Cancel> button, close the display form and go back to the 'whatever' that called the lookup.

                  Any help is appreciated.
                  D

                  Comment


                  • #24
                    Re: Progressive Lookup Function

                    D,

                    The cancel button is not handled explicitly. The default behavior of the xdialog stores "Cancel" in a_dlg_button and closes the xdialog. The following section of code assigns the character string "-1" to the return value from the function (not the dialog) since vDlgReturn will not equal "OK".

                    Code:
                    select
                       case vDlgReturn <> "OK"
                       	  ProgressiveLkUp = -1
                       case vRecNumber > 0
                       	  ProgressiveLkUp = vRecNumber
                       case else
                       	  ProgressiveLkUp = -1
                    end select
                    If you get a "-1" character string return from the function it means that either the user pressed Cancel button or (having first selected a row) the user has pressed the Esc key.

                    Read the help file discussion of Xdialog events for details on the default behavior. You will find that pushing any button will assign the name of that button to a_dlg_button. Since a_dlg_button is not empty the dialog will close unless you trap the event in code and assign null to a_dlg_button to keep the xdialog open.

                    Comment


                    • #25
                      Re: Progressive Lookup Function

                      Thanx Tom...
                      That is exactly what I found out over the past hour.
                      by creating a variable to carry out a value after getting the minus one, I was able to stop all further action and return to the form that started the script...

                      Sorry to be so dense sometimes..... Me like turtle -- I get there eventually

                      Thanx again
                      D

                      Comment


                      • #26
                        Re: Progressive Lookup Function

                        Recommended changes (for Alpha Five vers 8) to Jim's script are discussed in the following thread:

                        http://msgboard.alphasoftware.com/al...ad.php?t=71983

                        Comment


                        • #27
                          Re: Progressive Lookup Function

                          I'm a little lost here... with all the mods, or not, mods, or not... that have gone on with this function. Anyone have any idea where the "latest/greatest" code for this can be found... if anywhere... out here :-)

                          Thanks,
                          "all things should be as simple as possible... but no simpler"

                          Mike

                          Comment


                          • #28
                            Re: Progressive Lookup Function

                            This is my 'latest' version. It works!

                            these are the variables passed along to the function.

                            the index 'lkup4' is an index on the table that organizes last and first names of husband and wife into the following: Coleman, Richard or Ann.
                            It also allows for only one spouse and formats the index accordingly.
                            The record chosen is displayed on a form. Data is transferred from the lookup
                            to shared and global variables that facilitate data input to a form.


                            Code:
                            vtblname="c_custbl"
                            vindxname="lkup4"
                            vnumlines=25
                            vWidth=45
                            
                            vrecnum=PrgLkup(vtblname, vindxname, vnumlines, vWidth)
                            
                            if vRecNum > 0 then
                            	:fc_cusok.Recno_goto(vRecNum)
                            	 ' original line in script
                            end if
                            this is the function PrgLkup:

                            Code:
                            'Date Created: 22-Sep-2005 08:51:46 PM
                            'Last Updated: 14-Dec-2008 08:43:13 AM
                            'Created By  : Jim Chapman
                            'Updated By  : Dick Coleman
                            
                            FUNCTION PrgLkup AS N (vtblname AS C, vindxname AS C, vnumlines AS N, vWidth AS N )
                            
                            dim shared pos as N  'The position of the scroll bar
                            dim shared vList as C 'The list variable that is displayed in the control
                            dim shared vSelect as C 'The 'record' selected by the user
                            dim shared vTypeIn as C  'The variable that contains the 'search for' string the user types in
                            dim shared vfstrecnum as N 'The variable that contains the first record number
                            dim shared getoutnow as L = .F.
                            
                            pos = 0
                            vSelect = ""
                            vTypeIn = ""
                            t = table.open(vtblname,FILE_RO_SHARED)
                            vIndex = t.index_primary_put(vindxname)
                            t.fetch_first()
                            vfstrecnum = t.recno()
                            
                            vList = ""
                            vList = BuildList(t,vIndex,vnumlines)
                            dim shared vpgdn as n
                            
                            vDlg =<<%dlg%
                            {position=remember=cuslkup1}
                            {on_key=PGUP!pgup}
                            {on_key=PGDN!pgdn}
                            {on_key=Down!Down}
                            {on_key=Up!Up}
                            {on_key=ENTER!EnterKey}
                            Type in Query Description:;
                            [.[varN->vWidth]vTypeIn!changed];;
                            [%O={@@}%.[varN->vWidth],[varN->vnumlines]vSelect^#vList!vList_*]{vscroll=%0,[varN->vnumlines+1]%3,[varN->vnumlines]pos!pos_Changed};
                            <10OK> <10Cancel>
                            %dlg%
                            
                            vDlg = replace_parameters(vDlg,local_variables())
                            
                            vDlgReturn = ui_dlg_box("Input Search String",vDlg,<<%code%
                            
                            if a_dlg_button = "Cancel"
                            	getoutnow=.T.
                            	goto inside_end
                            end if
                            
                            if a_dlg_button = "vList_dblclick"
                            	a_dlg_button = "OK"
                            end if 
                            if a_dlg_button = "EnterKey" .or. a_dlg_button = "OK"
                            	select
                            	   case vSelect = ""
                            	   	a_dlg_button = ""
                            	   	ui_msg_box("Oops","A lookup selection must be made or the Cancel button pushed!",UI_STOP_SYMBOL)
                            	   case vSelect <> ""
                            	   	a_dlg_button = "OK"
                            	end select
                            end if 
                            if a_dlg_button = "changed"
                            	a_dlg_button = ""
                            	t.fetch_find(vTypeIn)
                            	vList = BuildList(t,vIndex,vnumlines)
                            	GetCurrentValues("TypeInChanged",1)
                            end if 
                            if a_dlg_button ="pos_changed" .or. a_dlg_button = "Up" .or. a_dlg_button = "Down"
                            	select
                            	   case a_dlg_button = "Down"
                            	   pos = pos + 1
                            	   case a_dlg_button = "Up"
                            	   pos = pos - 1
                            	end select
                            	a_dlg_button = ""
                            	select
                            	   case pos > vnumlines
                            	   	vList = BuildList(t,vIndex,vnumlines)
                            	   	GetCurrentValues("Scroll_EOL",1)
                            	   case pos = 0 .and. vfstrecnum = val(vSelect)
                            	   	GetCurrentValues("At First Record",0)
                            	   case pos = 0
                            	   for i = 1 to vnumlines * 2
                            	   		if t.bof(vindxname)
                            				exit for
                            			end if 
                            	   	t.fetch_prev()
                            	   	next 
                            	   	vList = BuildList(t,vIndex,vnumlines)
                            	   	GetCurrentValues("Scroll_BOL",vnumlines)
                            	end select
                            	vCurrentString = word(vList,pos,crlf())
                            	vReturnString = GetCurrentValues("POS_Changed",pos)
                            end if 
                            if a_dlg_button = "pgdn"
                            	a_dlg_button = ""
                            	select
                            	   case pos < vnumlines 
                            	   if vnumlines > line_count(vList)
                            	   	GetCurrentValues("PageDown",line_count(vList))
                            	   	else
                            	   	GetCurrentValues("PageDown",vnumlines)
                            	   end if 
                            	   case else
                            	   	vList = BuildList(t,vIndex,vnumlines)
                            	   	GetCurrentValues("PageDown",1)
                            	end select
                            end if 
                            
                            if a_dlg_button = "pgup"
                            	a_dlg_button = ""
                            	select
                            	   case pos > 1
                            	   	GetCurrentValues("PageUp",1)
                            	   case else
                            	   	for i = 1 to (vnumlines + line_count(vList))
                            	   		if t.bof(vindxname)
                            				exit for
                            			end if 
                            	   	t.fetch_prev()
                            	   	next 
                            	   	vList = BuildList(t,vIndex,vnumlines)
                            	   	GetCurrentValues("PageUp",1)
                            	end select
                            end if 
                            
                            '_____________________________________________________________________
                            'Code created by Selwyn Rabins due to bug report submitted.
                            'this has fixed the loss of clicking on a name to pick it and have it displayed in pick box.
                            	if atc("vlist_",a_dlg_button) = 1 then
                            	
                            	if a_dlg_button = "vList_Change"
                            	dim pos as n
                            	pos = atc("{data=" + alltrim(vselect),vlist)
                            	vCurrentLine = word_from_pos(vlist,pos,crlf())
                            	
                            	vReturnString = GetCurrentValues("vList_Changed",vCurrentLine)
                            	a_dlg_button = ""
                            	else
                            	a_dlg_button = ""
                            	end if
                            	end if 
                            '_____________________________________________________________________
                            'Original code below and commented out
                            
                            'if a_dlg_button = "vList_Change"
                            '	a_dlg_button = ""
                            '	vCurrentLine = word_number_get(vList,vSelect,crlf())
                            '	vReturnString = GetCurrentValues("vList_Changed",vCurrentLine)
                            'end if 
                            'if left(a_dlg_button,6) = "vList_"
                            '	a_dlg_button = ""
                            'end if 
                            '______________________________________________________________________
                            
                            inside_end:
                            
                            %code%)
                            t.close()
                            vrecnum = val(vSelect)
                            select
                               case vDlgReturn <> "OK"
                               	PrgLkup = -1
                               case vrecnum > 0
                               	PrgLkup = vrecnum
                               case else
                               	PrgLkup = -1
                            end select
                            
                            END FUNCTION
                            
                            
                            function GetCurrentValues as C (vWhatFired as c,vPositionNum as n)
                            	   	vCurrentString = word(vList,vPositionNum,crlf())
                            	   	'*****************************************************************************
                            	   	'*** Uncommenting the following lines will cause the type in control to reflect
                            	   	'*** highlighted selection when using page and arrow keys, mouse and scroll bar
                            	   	'*****************************************************************************
                            	   	if vWhatFired <> "TypeInChanged"
                            	   		vTypeIn = alltrim(substr(vCurrentString,at("}",vCurrentString)+1))
                            	   	end if 
                            	   	vTempLen = at("}",vCurrentString) - 7
                            	   	vSelect = substr(vCurrentString,7,vTempLen)
                            	   	pos = vPositionNum
                            	GetCurrentValues = "T"
                            end function 
                            
                            function BuildList as c (vTable as p,vIndex as p,vCount as n)
                            	BuildList = ""
                            	for i = 1 to vCount
                            		vKey = vIndex.key_get()
                            		BuildList = BuildList + "{data="+padl(alltrim(str(vKey.record)),10,"0")+"}"+ vKey.key + crlf() 		
                            		if vTable.eof(vIndex.name_get())
                            			exit for
                            		end if
                            		vTable.fetch_next() 
                            	next
                            end function
                            I don't know if there are any 'other' versions.
                            Hope it helps.
                            D

                            Comment


                            • #29
                              Re: Progressive Lookup Function

                              Hi All,

                              Thought I would post this here in case it might help someone else. I made a quick and dirty little function that calls Jim's Progressive Lookup function. But, this function will use the recno() returned by Jim's function and return whatever field you want for that record number. I wanted an easy way to have a one line function call to give me the data from the field I wanted. Instead of modifying Jim's function I decided to use it as is and just call it with this little function.

                              You pass the source table, source index, return field, rows and columns.

                              Code:
                              'Date Created: 12-Mar-2009 05:00:37 PM
                              'Last Updated: 12-Mar-2009 08:03:23 PM
                              'Created By  : Jeff
                              'Updated By  : Jeff
                              FUNCTION PrgLkupRetVal AS C (srctable AS C, srcindex AS C, srcretfield AS C,lkuprows as N, lkupcolumns as N)
                              'Call Jim's function
                              	vrecnum=prglkup(srctable,srcindex,lkuprows,lkupcolumns)
                              	
                              	if vrecnum>0 ' a valid record was returned
                              		dim tblsrc as p
                              		tblsrc=table.open(srctable,FILE_RO_SHARED)
                              		tblsrc.fetch_goto(vrecnum)
                              		PrgLkupRetVal=alltrim(eval("tblsrc."+srcretfield))
                              	             tblsrc.close()
                              	else
                              	PrgLkupRetVal=""
                              	ui_msg_box("No Record Chosen","No Record was chosen - Process Terminating!")
                              	end
                              	end if
                              END FUNCTION
                              BTW, Thanks to Jim and all that have contributed to this thread. This is a great function to have.

                              I have used a fixed width font (QuickType Mono) that I did put into Jim's dialog code to make columns line up perfectly when I use more than one field in my index for the lookup (actually they all have more than one field in them) - makes for a nice looking presentation to the user.

                              Regards,

                              Jeff

                              Comment


                              • #30
                                Re: Progressive Lookup Function

                                Would someone be so kind as to post a small database with this function working within it, thank you.

                                Comment

                                Working...
                                X