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

A new variable scope

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

    #31
    Re: A new variable scope

    Originally posted by G Gabriel View Post
    Al:
    Just as you would put safeguards (by locking the table) I suppose I could lock the script. Again, I haven't investigated that yet, but that's not the only usage for this idea.
    But you suggested this as a "great alternative" for autoincrment and you seem to be suggesting it is more reliable with less work.

    If we ignore multi-user issues (which many of us can not), aren't you still flirting with disaster. What happens when in my single-user app the saved script sets the intial value of the global variable to say 10, I enter several records and then someone trips over the power cord of my PC?

    Next time I start entering records, I will start at 10 and duplicate IDs. Right?

    Yes, you can do more work by saving the script every time. But you've said we don't need to. And by the time you start doing all the required work to make this approach work properly, are you really gaining anything?

    It seems to me that I must be missing something about this new variable "scope", so I'd be grateful if you could fill in the blanks for me if you have the time.

    Comment


      #32
      Re: A new variable scope

      What happens when in my single-user app the saved script sets the intial value of the global variable to say 10, I enter several records and then someone trips over the power cord of my PC?
      That's a good point. You could also have a powe outage.
      No all is not lost and no, you don't have to save each time (although saving a script is not that big of a deal and it does not in any way compare to saving in a table).
      If that happens, and I hope people are not tripping over your cord every day else you really need a good lawyer, you query your table for the highest value and reset the variable.

      Comment


        #33
        Re: A new variable scope

        Using one script to modify another.

        I see script_load() to get the text of the script to be modified.

        But I don't see a function to save it after edits have been made programmatically.

        What am I missing?

        Comment


          #34
          Re: A new variable scope

          Tom:
          script_save()

          Comment


            #35
            Re: A new variable scope

            G, that's wierd.

            Script_Save() is not indexed in the HELP file, nor can I find documentation on it by searching through the HELP file. I know cause I looked before posting. Oh well, live and learn. If there's documentation for it "out there" would appreciate a tip on how to find it. Thanks.

            Comment


              #36
              Re: A new variable scope

              Tom you are right. See this post.
              Marcel

              I hear and I forget. I see and I remember. I do and I understand.
              ---- Confusius ----

              Comment


                #37
                Re: A new variable scope

                No Tom, I ran into the same dilemma and started a thread and Cal alerted me to that function. I was looking for it as I was thinking about this whole thing and couldn't find it anywhere in the help file.

                I don't think there is any documentation for it, but it's there and it works.

                To all:
                I have a meeting I gotta go. I used autoincrement as an example, but that's not the only usage for this. think about any time you post to or update a table, this could be your ticket where you don't have to open that table every time you want to post or update.

                Comment


                  #38
                  Re: A new variable scope

                  In general terms... i.e. not just thinking of the Alpha environment... no matter where the "vairable" is stored, accessed from, written to, etc... you will have the "concurrency issues" to deal with. So, the only real question is what "solution" provides the "best concurrency control available" in any particular computing environment.

                  My guess is that in the Alpha computing environment, using it's db-based "concurrency controls"... regardless of if the file being used is a dbf or where ever Alpha stores scripts.... is as good as it's going to get. That is, unless/until, there is an Xbasic function which allows multiple workstations to share a memory location on one workstation designated as a memory-server.

                  I have actually programmed in that sort of environment... but it was at NASA... the computing environment was a cluster of computers designed to create a file-safe environment... and it was likely more expensive than most Alpha clients would be willing to spend to ensure that their next invoice number is correct. :)
                  "all things should be as simple as possible... but no simpler"

                  Mike

                  Comment


                    #39
                    Re: A new variable scope

                    I think the idea of continually writing to the adb file of an application is not a good one.
                    If a hardware glitch occurs while writing, then it is your application itself that could become corrupted..
                    As far as your first example goes, If someone had the initial unused application,once they were locked out by too many uses, all they would have to do is take the adb file from the original and overwrite the adb file in the current application.It seems almost too easy to reset the counter.
                    As far as its usefulness in an auto incrementing solution, that would result in many more writes( corruption possibilities ) than merely doing so on exiting.There certainly is a lack of available information on the script _save that would need to be known prior to trusting it in a rapid fire multi-user situation. For instance is it writing to the adb file in the server location or is it writing to the optimized local adb. Also as Michael mentioned, does it provide concurrency controls at least equal to the normal reading and writing to a dbf
                    Reading and writing to a dbf for auto incrementing is a time tested solution in busy multi-user environments. ADB multiuser writing could only be proven out thru exhaustive use in a real life situation.

                    Comment


                      #40
                      Re: A new variable scope

                      Andrew:

                      Originally posted by aschone View Post
                      Ira-
                      Isn't modifying the script to store the new updated variable along the same lines as modifying the data dictionaries?
                      Yes, saving a script is stored in the ALB/ALX/ALM files. Data dictionaries are properly shared as they are just renamed DBF files. However, they are not tested for this kind of activity, so it is possible that some activities (e.g a pack, shadow, etc) could potentially not be handled properly. Scripts (and most things in there), are read, changed locally, and then written back overtop whatever is there. Other users are not locked out during that process (whereas in a normal table if you are in change mode, all users are locked out until you save), except during a very small time during the read or write, meaning who knows who will write the last value?

                      Pre-beta versions of the CSDA Code Utility's Desktop Restore actually wrote a special script, to facilitate a Desktop restore and to have less impact, but this was only one time startup, and ultimately these were eliminated.

                      Also, if a database is shadowed, then it is normally referencing a shadowed copy specific to the user, and is not the shared dictionary on the network.

                      This method of code modifying your code is also potentially dangerous to the point that you can hang your code (That's why we use C and not APL for most programs!). E.g. suppose you had a line that set in a script something like this
                      dim global datevar as d
                      datevar={13/14/2007}
                      You will potentially cause an execution error that could be difficult to recover from if in a critical place (e.g. your autoexec script)

                      A table can store the same information and be a whole lot more accessible and shared or not shared. A record in the table could hold a value, and potentially only specific users or user groups could have access to it (by another field holding "rights". So a record could hold user only or shared data. Anyone changing the value would normally be doing by code execution, so the data would not be locked for long.

                      The issue of autoincrement via program control using anything that does not utilize proper sharing techniques is flirting with danger. The technique of using the database locking/sharing mechanism has been in use in the Alpha environment since Alpha 4 DOS days. When done properly (and it is not easy to do properly) it provides the proper safety. It would be nice if Alpha had provided an "Atomic" locking mechanism for code, but it does not, and that is why it is so difficult. It requires using mechanisms within Alpha that implicitly have these.

                      It all comes down to essentially having a "test & set" in a single operation that can't be interrupted, but it can't be done at a high level like XBasic. It can also lead to a situation known as a "deadly embrace", something akin to traffic gridlock, even when done right.
                      Regards,

                      Ira J. Perlow
                      Computer Systems Design


                      CSDA A5 Products
                      New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                      CSDA Barcode Functions

                      CSDA Code Utility
                      CSDA Screen Capture


                      Comment


                        #41
                        Re: A new variable scope

                        John:
                        I know.. but that is the same argument some people used a 100 years ago or so that horse buggies and mules were much more reliable and time tested than automobiles.

                        I can't answer any of that. Perhaps alpha can. But one thing is quite clear to me: rewriting a one or two-line script cannot possibly be as onorous as locking/eding/updating tables & indixes. I can't imagine that, particularly if you have tables with hundreds of thousnads of records and several indices.

                        I did multiple runs of rewriting the script, it worked each and every time. I am not suggesting that people should just drop everythin and redesign their databses allover again. It's something to think about and consider, maybe one day it will become the norm and horse buggies become a museum item. Maybe alpha will take note of that and provide for more reliability in the adb if it is lacking and I don't know that it is.

                        Mike:
                        Shared memory sounds like panacea and it will take more than alpha to accomplish. Your OS must allow you access to the same memory slot and I don't see that happening anytime soon, that is unless Bill Gates is reading this! Even then, I don't see how a shared memory will resolve all concurrency issues. Perhaps a shared memory will make it possible for all machines to access the same variables, but it wont resolve the issue of triggering or saving the same script at the same nano-second. I believe you do have to lock the script and that shouldn't be very difficult with an on/off flag. The locking will only last for milliseonds, the time needed to save the rewritten script, unlike locking the table for minutes or perhaps hours while Suzie is editing a record, answering the phone, putting paper in the fax machine, sending email, eating lunch, filing her nails and adjusting her makup.

                        Ira:
                        I am not buying any of these hypothetical arguments, but assuming that all these disasters happen, who the heck cares?! It is not the end of the world, you could reset the variable by quering the table once for the highest value. Same scenario like that guy who tripped over the power cord.

                        When was the last time a table pack destoyed your dictionary? and if it did, don't blame it on my script.. next thing you are going to blame me for the Korean war!
                        Last edited by G Gabriel; 12-11-2007, 10:03 PM.

                        Comment


                          #42
                          Re: A new variable scope

                          This thread appears to me to go around in circles. First off, addressing the issue of creating your own auto incrementing routine, and querying a table to get a value to auto increment, Peter Wayne’s approach is the way to go, but there does not need to be “whole lot of overhead, trouble and vulnerability” in querying the table. Although there are issues, which IMHO would be much less than modifying the script with each use, one could do this to get the value to increment:

                          Code:
                          t = table.open("customer",FILE_RO_SHARED)
                          t.index_primary_put()
                          t.fetch_last()
                          vNewIncrementNumber = t.incrementNumber + 1
                          t.close()
                          One could argue about the overhead of opening and closing the table, but there are other options here as well but the real issue is timing and muti-users hitting the table, and IMHO the reason Peter Wayne’s approach is preferable is because it isolates the process of getting the incremented value from the repository of the data.

                          Beyond this, the whole discussion is about ‘which file format is best’ to store a value. After all, what is an Alpha Five script but a file, or more correctly a portion of a file, a given entry in a memo field. Alpha Five stores scripts predominately in the database library (can also be stored in a given table’s data dictionary, as an AEX file or if you want as a text file executed by an evaluate_template() function call), specifically the *.alb and it associated memo file *.alm. Remember that these file formats are really just plain old dbf file formats with different file extensions.

                          If I am understanding this whole thread, what it being proposed is to change the script ‘on the fly’. So in effect this means modifying the *.alb and *.alm files within a muti-user environment. If we are talking about a single user environment, the whole issue of overhead is insignificant. Do we really want to be modifying the data dictionary memo fields ‘on the fly’? My opinion is we really don’t want to do this, especially without any real gain in functionality.

                          So boiled down is it best to store values in:

                          The registry?
                          A text file of some type?
                          A table (dbf)?
                          A table & memo file (script file)?


                          Jim

                          Comment


                            #43
                            Re: A new variable scope

                            G,

                            I believe it can be done in shared memory. Ever hear of a ram drive? We used them big time when compiling clipper apps. Compile on an old hard drive = 2 hours, sam compile on a ram drive 10 minutes.

                            Share it over a lan( if possible?) and you have a speed demon?? Or maybe not.

                            I think I had a small alpha app in a ram drive once and it FLEW!

                            Dave
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                              #44
                              Re: A new variable scope

                              Man, what a thread. Much of what was said is over my head to one degree or another. Whew!!!

                              What I do understand and enjoy is listening to the interaction. I like the way Gabe is thinking "outside the box". He never said his idea is the way to go. Rather, he posed an idea in the form of a brain teaser to get others to think.

                              Gabe didn't expect everyone to agree nor do I think he wanted everyone to agree. I think it's a very clever way to provoke other's thoughts and ideas.

                              Venturing "outside the box" is a very valuable tool to exploring new ways of doing things.

                              kenn
                              TYVM :) kenn

                              Knowing what you can achieve will not become reality until you imagine and explore.

                              Comment


                                #45
                                Re: A new variable scope

                                Originally posted by Jim Chapman View Post
                                This thread appears to me to go around in circles. First off, addressing the issue of creating your own auto incrementing routine
                                How did this thread end up being about autoincrementing when I only used that as an example?! In fact the example I used prior to that was about keeping count! If autoincrementing is a bad example, well, can't you use your imagination as to what can you use such an idea for and offer better examples instead of trying to beat me and my ideas to a pulp? If people can't understand or don't want to understand what I was talking about all along, all I could say is:

                                Folks, please don't shoot me, I was only joking.. the earth is flat, just look at it, it's flat!

                                Comment

                                Working...
                                X