Alpha Video Training
Results 1 to 24 of 24

Thread: Xbasic Loop Processing Examples

  1. #1
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Xbasic Loop Processing Examples

    Three examples illustrating ways to loop through a group of related records using Xbasic.

    Example 1 - using a set based form, loop through the child table records linked to the current parent table record.

    Example 2 - Without using a set based form, run a query against a table and then loop through the records in the query list.

    Example 3 - Without using a set based form, and without running a query, set the records in a specific sort order, find the first record that matches a specific search key, and then continue fetching through the table until the search key no longer matches.

    -- tom cone jr

  2. #2
    Member
    Real Name
    brett sinclair
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    858

    Default

    Hi Tom. Nice examples. Any chance of posting them as a plain text file too? I just love looking at well written Xbasic code. :)

  3. #3
    Member kthibeault1965's Avatar
    Real Name
    Keven Thibeault
    Join Date
    Sep 2007
    Location
    Boston Mass USA
    Posts
    108

    Default Re: Xbasic Loop Processing Examples

    Tom

    I am just now seeing your code on looping xbasic. I will see if this applies to my need (very tricky query involving a separate table)

  4. #4
    Member kthibeault1965's Avatar
    Real Name
    Keven Thibeault
    Join Date
    Sep 2007
    Location
    Boston Mass USA
    Posts
    108

    Default Re: Xbasic Loop Processing Examples

    Tom

    I was not able to get the result I was after I tried your code

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

    is the link to my bigger problem, if you have any ideas that would be fab!

  5. #5
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: Xbasic Loop Processing Examples

    I can think of a number of ways in which this would benefit my application but have a question,

    currently i have in amy application a form with an embedded browse and a filter to list all records which meet a certain criteria.

    so the user must open a form to obtain the data. from what i understand this function does the same as it will inform the user of the number of records which meet a set criteria.

    so... am i best using my current way or would it make for better programming and better database design to use such a function which loops through the records.

    once the records have been written to the trace window, how would i then use this data if i wanted to perform another action?

    thanks

    richard

  6. #6
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: Xbasic Loop Processing Examples

    Richard,
    A new thread may be better but I guess explaining the use of Tom's code is good too....I just don't want to muddy the thread is all.

    Regarding the Trace write-in data. You don't use that data persay (although I guess you could)....it just illustrates that the data can be extracted from the child table.

    Instead of writing to the Trace window you would say after finding a record in the loop, either process it (change values), mark them with either the Alpha "Mark" method or changing the value of a checkbox field, delete them, or any number of things. I use a very similar method to find records that have a checkbox True value, copy the values of each record into another table with the Parent link field that is to be used for a another process later on in my application...all done with a child loop such as this.

    Hope this helps in understanding a bit.


    LATER: I also wanted to add that to see the results in the trace window for the 2 scripts in the example you have to comment out the last trace.clear().
    Last edited by MikeC; 03-29-2008 at 01:03 PM.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  7. #7
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: Xbasic Loop Processing Examples

    Cheers Mike,

    thanks, that does help. i suppose this wouldnt be used for the purpose of my current filterd form, but will definitly come in handy for some other ideas i have, in particular one was to mark several records which have a certain field which is blank and then update that field with the same data.

    currently we have select a record in a browse, open a companion form, enter the data then close the form then do the same for the next record. very time consuming...

    thanks

    richard

  8. #8
    Member
    Real Name
    Rudy Pataky
    Join Date
    Apr 2008
    Location
    Toms River, NJ
    Posts
    171

    Default Re: Xbasic Loop Processing Examples

    Tom,

    Can you help me with some code?

    I have a password table named "pwtbl" which consists of
    EmpNum Char 2, (Index)
    Emp_name Char 25 and
    Admin_Status Logical 1.

    I would like to bring up a Login dialog box that runs in Autoexec which asks for a user Employee Number. I'd like to use Employee Number as a Lookup to the password database (pwtbl) to obtain the Admin_Status and hold it in a Global Variable.

    On my Main Menu, when an Administration Button is pushed, I'd like to check the status and if it's 't', I'd like tyo open the admininstartion form else I'd like to display a message of "Un-authorized User and have him exit the script when pressing "OK". If the Employee Nymber is not in the password table (pwtbl), I'd like to display the same message as my previous one and also exit the script when pressing "OK". Can you send me the code to accomplish this?? I'm new to this and very confused as the what to code.

    Thanks, Rudy

  9. #9
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Xbasic Loop Processing Examples

    I suppose so, but I'm curious if you've investigated the built in security functions. You can assign users to groups and then have your button script check to see if the user is a member of a group that is permitted to push the button. What version of Alpha Five are you using, and is it desktop or web app? -- tom

  10. #10
    Member
    Real Name
    Rudy Pataky
    Join Date
    Apr 2008
    Location
    Toms River, NJ
    Posts
    171

    Default Re: Xbasic Loop Processing Examples

    Thanks Tom.

    I'm using v9 Platium Desktop.

    If using groups is cleaner and easier then the routine that I outlined then maybe that's the way I should go.

    If we use the group routine, can it be changed by a client in a run-time mode? I thought the routine that I outlined could be. Whatever you think is easier, cleaner, flexible, and can be used by the client once once a run-time version is installed.

    Sincerely,
    Rudy

  11. #11
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Xbasic Loop Processing Examples

    Rudy, if all you need is to know if the user has Admin_Status then the built in security system may be overkill. On the other hand if this is the first step in implementing a system which controls access to various forms and functions depending on what privileges a user has been given, then you would be well advised to spend some time with the built in security sequences before doing all the additional work to roll your own from scratch.

    Yes, the Administrator can reassign groups and passwords in the runtime environment.

    By the way, your question should have been posted to the A5v9 Desktop forum. We're in a forum reserved for discussion of the code samples that have been posted here. Your question has nothing to do with the example code posted at the top of this thread.

  12. #12
    Member
    Real Name
    Doug Page
    Join Date
    Jan 2002
    Location
    Vancouver, BC Canada
    Posts
    963

    Default Re: Xbasic Loop Processing Examples

    Tom,

    I'm not sure as I have never used A5 Desktop, but since it is only for 1-up programming with no ability to be used in a multi-user environment or web environment, are the security methods included?

  13. #13
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Xbasic Loop Processing Examples

    Doug, I have the full version but only one license. The security system seems to be working fine. If I had different staff members who needed to run an application they could each log on separately, one at a time of course. I think the security model for the web app server is a completely different animal. -- tom

  14. #14
    Member
    Real Name
    Doug Page
    Join Date
    Jan 2002
    Location
    Vancouver, BC Canada
    Posts
    963

    Default Re: Xbasic Loop Processing Examples

    I was meaning that Rudy mentioned he had the DESKTOP version not the Full version as you (and I) both have. The Desktop version is much more limited. I just didn't know if he would be able to use the Security methods or not.

  15. #15
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Xbasic Loop Processing Examples

    Doug, I missed that. I don't know what features the DESKTOP version has. Had even forgotten that there was a DESKTOP version.

    Can't find any information on a so called Desktop version in the Alpha Five store or product listing. Might it be known by a different name? Is there a limited version of Alpha Five vers 9 Platinum Edition?

  16. #16
    Member
    Real Name
    Rudy Pataky
    Join Date
    Apr 2008
    Location
    Toms River, NJ
    Posts
    171

    Default Re: Xbasic Loop Processing Examples

    Your recommended technique works great. I was wondering if we have the ability to "clone" and application?

    I'm developing an app for a specific Clubhouse to control all residents, handle many types of monthly association fees as well as produce reports, labels, letters, etc.

    If I could clone an app for another clubhouse that may have slightly different data rules, it would save lots of development time. All I would have to do is add/update current tables, forms, etc.. All startup's menus. etc. would be in place.

    Can this be done in Alpha. In Access all files can be contained in 1 *.MDB file and a simple "save as" does the trick.

  17. #17
    Member
    Real Name
    Doug Page
    Join Date
    Jan 2002
    Location
    Vancouver, BC Canada
    Posts
    963

    Default Re: Xbasic Loop Processing Examples

    Rudy,

    Create a new directory for the 2nd clubhouse and copy all the files from the first to this one. Now you have a complete 2nd copy!

  18. #18
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: Xbasic Loop Processing Examples

    Rudy,
    And once you have that second copy you may want to follow the instructions on this page to rename the database.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  19. #19
    Member
    Real Name
    Rudy Pataky
    Join Date
    Apr 2008
    Location
    Toms River, NJ
    Posts
    171

    Default Re: Xbasic Loop Processing Examples

    Thanks Doug and Tim. There are other .* extions associated with the database such as .MUF, .Recent_Files, .RMUF, etc. What about these??

  20. #20
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Xbasic Loop Processing Examples

    Rudy, check the help file. It has a topic on Alpha's "File Types".

  21. #21
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,699

    Default Re: Xbasic Loop Processing Examples

    Quote Originally Posted by Doug Page View Post
    Tom,

    I'm not sure as I have never used A5 Desktop, but since it is only for 1-up programming with no ability to be used in a multi-user environment or web environment, are the security methods included?
    If that is true then why did they sell me 4 licenses???
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  22. #22
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: Xbasic Loop Processing Examples

    Quote Originally Posted by MoGrace View Post
    If that is true then why did they sell me 4 licenses???
    Because you can have as many licenses of any version - that includes the "Desktop" Edition of V8 - of Alpha 5 as you like - there is no reason why a standalone piece of software can't be needed on several different PCs, after all!

    But I suspect there is some confusion between the use of the term Desktop as used to describe the type of apps you want to develop (web vs. desktop), and the use of the same term in previous versions of Alpha 5 to denote what functionality a copy of Alpha 5 has.

    There is no standalone/desktop edition of A5V9, for example... Just Standard vs. Platinum, but with V8 you could get Desktop (single user but of course several users can have a copy of A5 and use that copy for their own, standalone purposes), Professional (multi-user, you can create executable applications from your code, but no SQL connectivity/reporting) and Enterprise (multi-user, you can create executable applications from your code, SQL enabled) versions of the developer copy of Alpha 5.

    Alpha Five Version 8 Desktop Edition

    Ideal for home and standalone users, build non-networked desktop applications.

    You would require this edition, if you are a single user, and are only interested in building desktop applications.
    You do not have the ability to build web applications.
    You do not have the ability to build applications that will run using the runtime modules.

    Alpha Five Version 8 Professional Edition

    includes everything in the Desktop Edition,
    advanced new browse features,
    the ability to create web applications,
    the ability to create applications that can be deployed or distributed with the Alpha Five Runtime
    Quickly and inexpensively build fully functional desktop and web database applications. Also included are flexible report writing, intelligent email, data browsers and a full security framework. A rich programming language and tools like Action Scripting combine ease of use and complete extensibility.

    You will require this version if you are interested in building both desktop and web applications.
    You will require this version if you are interested in developing desktop applications that will run using our runtime modules, either for distributing applications or for having multiple users on a network.

    Alpha Five Version 8 Enterprise Edition

    includes everything in the Professional Edition,

    offers the ability to work with SQL databases through ADO or the new Alpha DAO,
    the Alpha Five Enterprise Report Builder - previously this was separately priced at $199,
    the Alpha Five Database Explorer
    Build enterprise applications against Alpha’s built in dbf engine or any back-end data source using all of Alpha Five's proven web and desktop development tools.

    You would want this version if you intend working with any kind of SQL data either on desktop applications or web applications.
    Take advantage of the advanced browse options.
    Last edited by NoeticCC; 05-12-2008 at 06:18 AM.

  23. #23
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,699

    Default Re: Xbasic Loop Processing Examples

    I expect v8 to work as v7 does now, where I put my data files on the server and a shadow on each desktop (each with its own license), to access those files. Is this not what a multiuser aka "networked" environment is?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  24. #24
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: Xbasic Loop Processing Examples

    Quote Originally Posted by MoGrace View Post
    I expect v8 to work as v7 does now, where I put my data files on the server and a shadow on each desktop (each with its own license), to access those files. Is this not what a multiuser aka "networked" environment is?
    Yes basically it is, but it depends on what you mean by "each desktop". If you read through the explanations on the versions of V8 you can get, there is a DESKTOP edition of Alpha 5, which is a STANDALONE copy, e.g. you use it not to design apps, not to access remote apps, but just to edit databases locally. https://www.alphasoftware.com/shop/A...elp_choose.asp

    Are you referring to the $199 DESKTOP EDITION or are you just talking about writing desktop apps with Alpha 5?!

    If you want multiple users to acces the same app, the way to go is usually ONE professional or enterprise copy per developer, and a RT license/engine for however many consecutive users you need. (This is generally cheaper than getting a "Desktop Edition" license for each user anyway, especially if you get a bundle!)

    The "Desktop Edition" for $199 is referred to explicitly as

    "Alpha Five Version 8 Desktop Edition

    Ideal for home and standalone users, build non-networked desktop applications.

    You would require this edition, if you are a single user, and are only interested in building desktop applications.
    You do not have the ability to build web applications.
    You do not have the ability to build applications that will run using the runtime modules."

    Naturally you can still have situations where a company has several copies of the Desktop Edition, so there is no reason why Alpha Software should refuse to sell you however many copies of the Desktop Edition as you want to order...

Similar Threads

  1. Continue in For loop
    By elidaho in forum Alpha Five Version 6
    Replies: 5
    Last Post: 06-30-2005, 02:03 PM
  2. examples don't seem to work for me
    By dik_coleman in forum Alpha Five Version 5
    Replies: 6
    Last Post: 06-04-2004, 05:39 AM
  3. Looking for Good Xdialog examples
    By Edward Larrabee in forum Alpha Five Version 5
    Replies: 0
    Last Post: 02-18-2004, 05:54 AM
  4. Expressions examples
    By Larry Eaton in forum Alpha Five Version 5
    Replies: 1
    Last Post: 01-20-2004, 11:42 AM
  5. Infinite Loop
    By Melvin Davidson in forum Alpha Five Version 5
    Replies: 9
    Last Post: 04-03-2003, 07:28 AM

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
  •