PDA

View Full Version : Xbasic Loop Processing Examples


ABC123

Tom Cone Jr
02-23-2006, 03:55 PM
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

brett s
02-24-2006, 07:46 PM
Hi Tom. Nice examples. Any chance of posting them as a plain text file too? I just love looking at well written Xbasic code. :)

kthibeault1965
09-26-2007, 12:09 PM
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)

kthibeault1965
09-26-2007, 12:12 PM
Tom

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

http://msgboard.alphasoftware.com/alphaforum/showthread.php?t=69365

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

richard2007
03-29-2008, 11:11 AM
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

MikeC
03-29-2008, 11:51 AM
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().

richard2007
03-29-2008, 01:13 PM
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

Rudy16
04-24-2008, 09:19 PM
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

Tom Cone Jr
04-24-2008, 10:08 PM
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

Rudy16
04-25-2008, 05:07 AM
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

Tom Cone Jr
04-25-2008, 05:26 AM
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.

Doug Page
04-25-2008, 06:41 PM
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?

Tom Cone Jr
04-25-2008, 06:51 PM
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

Doug Page
04-25-2008, 06:53 PM
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.

Tom Cone Jr
04-25-2008, 06:57 PM
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?

Rudy16
05-01-2008, 11:21 AM
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.

Doug Page
05-01-2008, 11:33 AM
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!

Tim Kiebert
05-01-2008, 11:42 AM
Rudy,
And once you have that second copy you may want to follow the instructions on this page (http://support.alphasoftware.com/alphafivehelpv8/User_Manual/Renaming_and_Deleting_Databases.htm) to rename the database.

Rudy16
05-07-2008, 06:43 AM
Thanks Doug and Tim. There are other .* extions associated with the database such as .MUF, .Recent_Files, .RMUF, etc. What about these??

Tom Cone Jr
05-07-2008, 06:54 AM
Rudy, check the help file. It has a topic on Alpha's "File Types".

MoGrace
05-07-2008, 10:58 AM
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???

NoeticCC
05-12-2008, 04:45 AM
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.

MoGrace
05-12-2008, 03:40 PM
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?

NoeticCC
05-12-2008, 04:06 PM
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/AlphaFive/help_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...