{"id":293,"date":"2004-08-15T14:34:40","date_gmt":"2004-08-15T06:34:40","guid":{"rendered":"http:\/\/foxpro.ntsl119.com\/scr\/?p=293"},"modified":"2007-11-02T13:36:26","modified_gmt":"2007-11-02T05:36:26","slug":"displaying-database-index-tag-names-in-combo-boxes","status":"publish","type":"post","link":"https:\/\/foxpro.ntsl119.com\/scr\/archives\/293","title":{"rendered":"Displaying database index tag names in combo boxes"},"content":{"rendered":"<p>Here&#8217;s a simple <font face=\"Tahoma, Verdana, sans-serif\">2:00<\/font>AM code I made. Its objective is to make a certain combo box automatically reflect the tag names for the databases you are currently using.<\/p>\n<pre><font color=\"#0000FF\" size=\"2\" face=\"Tahoma, Verdana, sans-serif\">with thisform<\/font><br \/>\r\n<font size=\"2\" face=\"Tahoma, Verdana, sans-serif\">     DatabaseInitialization()\t<br \/>\r\n     <\/font><font color=\"#0000FF\">select<\/font> FILEAREA<br \/>\r\n     nTagCount = <font color=\"#0000FF\">tagcount<\/font>()<br \/>\r\n     <font color=\"#0000FF\">dimension<\/font> aIndex(nTagCount)\t<br \/>\r\n     <font color=\"#0000FF\">for<\/font> nCount = 1 <font color=\"#0000FF\">to<\/font> tagcount()<br \/>\r\n          if !<font color=\"#0000FF\">empty<\/font>(<font color=\"#0000FF\">tag<\/font>(nCount))<br \/>\r\n               <font color=\"#0000FF\">store tag<\/font>(nCount) <font color=\"#0000FF\">to<\/font> aIndex(nCount)<br \/>\r\n          <font color=\"#0000FF\">else   \t\t<br \/>\r\n               exit      \t\t<br \/>\r\n          endif<\/font>   \t\t<br \/>\r\n     <font color=\"#0000FF\">endfor<\/font><br \/>\r\n     .cmbIndex.<font color=\"#0000FF\">rowsourcetype<\/font> = 5<br \/>\r\n     .cmbIndex.<font color=\"#0000FF\">rowsource<\/font> = 'aIndex'<br \/>\r\n     .cmbIndex.<font color=\"#0000FF\">value<\/font> = aIndex(1) <br \/>\r\n<font color=\"#0000FF\">endwith<\/font><\/pre>\n<p>\nIt&#8217;s too simple really but this was the first time I used this. I even had to refer to Foxpro&#8217;s help file in the formulation process.<\/p>\n<p>The main purpose is to create a template form for the &#8216;File Utility&#8217; type of modules. The term &#8216;File Utility&#8217; was something I have acquired from College MacPros (Machine Problems). This is a part of those old DOS based Programs we had back then (created in either Pascal, C\/C++, Clipper <font face=\"Tahoma, Verdana, sans-serif\">5.2<\/font>) which hold the records for your database-based values, or as one of my clients call it&#8230; directories.<\/p>\n<p>This has been a practice which I find useful especially when you&#8217;re already in the maintenance mode of your program. Directories like this, however, should be planned in advance. The &#8216;Design phase&#8217; of your project is a good place to start.<\/p>\n<p>These directories can also be used inside combo boxes, and if in the future you would like to add values that those combo boxes display, you don&#8217;t need to touch the hard code. You just either edit the database or use your File Utility module.<\/p>\n<p>Very handy too when your database application is being used by more than one client.<\/p>\n<p>Let&#8217;s give an example.<\/p>\n<p>Suppose you have a combo box for Profession. Of course you can choose the combo box builder wizard and enter the data by hand but that would be lame.<\/p>\n<p>Totally lame that only castrated over-boozed programmers of the <font face=\"Tahoma, Verdana, sans-serif\">60<\/font>s do that.<\/p>\n<p>You use a database approach and set the combo box to grab the values of that database.<\/p>\n<pre><font size=\"2\" face=\"Tahoma, Verdana, sans-serif\">     .cmbProf.<\/font><font color=\"#0000FF\">rowsource<\/font> = 'DATABASENAME.FIELDNAME'<br \/>\r\n     .cmbProf.<font color=\"#0000FF\">rowsourcetype<\/font> = 6<\/pre>\n<p>\n&#8230; where cmbProf is your Profession combo box and <font face=\"Tahoma, Verdana, sans-serif\">6<\/font> stands for (database) fields, the source of the values the combo box will display.<\/p>\n<p>You can also use the Property box to set things. Other sources include value, alias, sql statement, query (.qpr), array, files, structure, popup, DoomPortal, BermudaTriangle, RiverofLesRough and so on.<\/p>\n<p>Now back to the code above (Darn I&#8217;m wandering off once again), the algorithm gets the number of tags the compound index file has, gets the tag names and stores them in an array.<\/p>\n<p>Now using the values in that array, you can place the code below in an object (a &#8216;Browse&#8217; command button perhaps).<\/p>\n<pre><font size=\"2\" face=\"Tahoma, Verdana, sans-serif\">     <\/font><font color=\"#0000FF\">select<\/font> FILEAREA<br \/>\r\n     <font color=\"#0000FF\">set order to alltrim<\/font>(.cmbIndex.<font color=\"#0000FF\">value<\/font>)<br \/>\r\n     .GridProf.<font color=\"#0000FF\">refresh<\/font><\/pre>\n<p>\nThis will reflect the changes you want to view, which in my case is found in a grid that displays the sorted records.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/foxpro.ntsl119.com\/uploads\/20040815-GridArea.jpg\" width=\"400\" height=\"236\"\/><\/p>\n<p><font face=\"Tahoma, Verdana, sans-serif\">Figure 292.1 Image too shy to enlarge itself since its design and alignment was not optimized yet. Check back later when Image.nConfidenceLevel++.<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a simple 2:00AM code I made. Its objective is to make a certain combo box automatically reflect the tag names for the databases you are currently using. with thisform DatabaseInitialization() select FILEAREA nTagCount = tagcount() dimension aIndex(nTagCount) for nCount = 1 to tagcount() if !empty(tag(nCount)) store tag(nCount) to aIndex(nCount) else exit endif endfor .cmbIndex.rowsourcetype [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-visual-foxpro","category-workblog"],"_links":{"self":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":0,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"wp:attachment":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}