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

Saving Variables

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

    Saving Variables

    In Alpha Four I could easily save all my Variables to a text text file by using {VSAVE}. How can I do this in A5?

    Thanks

    #2
    RE: Saving Variables

    Not so easily but you can write them, via xbasic, to a .dbf created for the purpose, and read them back by the same method attached to the onnit event for your startup form.
    There can be only one.

    Comment


      #3
      RE: Saving Variables

      Dan,

      As you know, vsave writes the values of variables to a text file. You get them back by using vrestore which reads the values in the text file back into variables. That way the values persist from one session to the next.

      When I first made the transition to A5 I wrote my own versions of vsave and vrestore. This was not so difficult and it had the benefit of familiarity.

      After that first application I went to the method Stan describes which I found to be somewhat more convenient. After all, if you have tables available why would you want to store data in a text file?

      I just thought you might like to know that you can do it Alpha4 way if you want. Further details upon request.

      Bill
      Bill Hanigsberg

      Comment


        #4
        RE: Saving Variables

        Thanks for your reply. We've got 36 users on a Novell network and it's been very useful to be able to save an individuals variables when they exit the program. I read them back in when the program is started, just as you described Bill and the user can pick up where they left off. There is always a tendency to want to fall back on familiar methods and I would like to know how I can continue to use a text file but I need to learn the Table method also. If you can provide a couple of samples of code I sure would appreciate it. I shouldn't need much, just something to get me started.

        Thanks

        Comment


          #5
          RE: Saving Variables

          Nice article at learn alpha.com, click here
          There can be only one.

          Comment


            #6
            RE: Saving Variables

            Dan,

            Here is a fragment of a script which initializes variables from a defaults table. The table contains a record for each user so the defaults are user-specific even though they are stored centrally.

            I can add that I do store a single value in a local text file. The file contains a single line with the name of the department logged on to the last time that particular machine ran the application. It saves the user the trouble of scrolling down a list to find it and is almost always correct as the machine is on a user's desk. The reason it must be in a local text file is that is is used *prior* to logon so I don't yet know the user name to do the lookup.

            I'd be happy to send you more if you want but this shows the technique and the article Stan flagged does the same.

            Bill


            ''XBasic
            'CPL_Ini_9
            'This script is called by Autoexec (Logon) script
            'It has other aspects which I have removed for simplicity
            '
            'Explicitly Declare Variables

            dim tbl as p 'defaults table
            dim ndx as p
            dim global user_key as c 'initialized in logon
            'this means that I can identify the user's defaults record
            dim global term_S as c 'Start term
            dim global term_E as c 'End term
            dim global term_D as c 'Default term
            '---------------------------------------------------------
            'Initialize global variables from saved defaults to use in filtering data forms
            'Defaults are user specific
            tbl=table.open("defaults.dbf")
            ndx=tbl.index_primary_put("User")
            tbl.fetch_find(user_key) 'fetch record holding current user's defaults
            term_S=tbl.Term_start
            term_E=tbl.Term_end
            term_D=tbl.Term_default
            tbl.close() 'close defaults table
            '-----------------------------------------------------------
            Bill Hanigsberg

            Comment


              #7
              RE: Saving Variables

              Bill,

              Thank you very much. I got a little sidetracked this week and I'm just now getting back to this. Your snippet of code is very helpful. That looks like the way to go. I would like to see how you did the text file thing though.

              Thanks again,

              Dan

              Comment


                #8
                RE: Saving Variables

                Dan:

                Here is a pair of scripts that do it the A4 way. Guess what they are called (vsave, vrestore). There is a lot of specific junk in these scripts which you can ignore but they show the way it works.

                The application is meant to work with a large or small monitor. There are two application main forms. By default it loads the small forms. The idea is to remember the forms which were active when the application closed so it restores the same the next time it is opened.

                The annotations also call attention to getting form names into pointers which is worth knowing.

                Feel free to query me on the many obscurities which must be there to confuse you (and me as I no longer remember the code very well).

                Bill

                ''XBasic VSAVE (from CPLFile_Exists3)
                'Thread and Topic forms must both be loaded for this to work
                '===============================================================
                'Test threads and topics are loaded
                'Get the names of the current forms
                'Test for existence of a text file.
                'If it does not exist prompt user to decide whether to create it.
                'If the file exists or is created, write variables to it.

                On Error goto ERROR_HANDLER
                Option Strict


                dim threadform as c
                dim topicform as c
                dim global thr as p
                dim global top as p
                dim message as c
                dim file_pointer as p
                dim filename as c
                dim result as L
                dim err as c
                dim msg as c

                dim crlf as constant
                crlf=chr(13)+chr(10)

                'Test forms are loaded. If not don't try to save.
                If .not. is_object(thr) THEN
                message="One or more application forms is not currently loaded"+crlf+
                "Not worth saving current forms."
                ui_msg_box("Missing information",message,UI_INFORMATION_SYMBOL)
                END
                End If

                If .not. is_object(top) THEN
                message="One or more application forms is not currently loaded"+crlf+
                "Not worth saving current forms."
                ui_msg_box("Missing information",message,UI_INFORMATION_SYMBOL)
                END
                End If

                'Forms are loaded so get their names from pointers

                'here's how
                'thr=form.view("thread new3")
                'threadform=thr.name()
                '?threadform
                '= "thread_new3"

                threadform=thr.name()
                topicform=top.name()



                dim path as c
                path=:A5.Get_Private_Path()
                filename=path+"TECHBOARD.txt"
                result = File.Exists(filename)

                IF result = .F. THEN
                message="Creating text file to remember current forms for next time."
                ui_msg_box(filename+" not found",message,UI_INFORMATION_SYMBOL)
                file_pointer=File.create(filename,file_rw_exclusive)
                goto WRITE

                ELSE
                'since file already exists there is no need to create it
                file_pointer=File.open(filename,file_rw_exclusive)
                END IF

                WRITE:
                '1;File_pointer.Write_line(threadform)
                '2;File_pointer.Write_line(topicform)


                file_pointer.flush()
                file_pointer.close()
                END

                ERROR_HANDLER:
                On Error goto 0
                err=error_code_get()
                msg=error_text_get(err)
                ui_msg_box("Error",msg)
                END


                ''XBasic VRESTORE
                'This is the only script which stores literal names of all forms
                'Test for existence of a text file containing names of last-used forms
                'If file does not exist inform the user and initialize small forms
                'If the file exists read the names last-used forms from it and open them
                '=======================================================================
                On Error goto ERROR_HANDLER

                dim global vThreadform_s as c 'these variables hold literal form names
                dim global vThreadform_l as c 'to use in setup_large.scp
                dim global vTopicform_s as c 'and setup_small.scp
                dim global vTopicform_l as c

                dim path as c
                dim global threads as c 'global for switch_forms.scp
                dim global topics as c
                dim global thr as p
                dim global top as p
                dim message as c
                dim file_pointer as p
                dim filename as c
                dim result as L
                dim err as n
                dim msg as c

                dim crlf as constant
                crlf=chr(13)+chr(10)

                vThreadform_s = "thread_s" 'Literal names of forms into variables
                vThreadform_l = "thread_l"
                vTopicform_s = "topic_s"
                vTopicform_l = "topic_l"

                'DEBUG(1)

                'Look for text file holding saved setup

                path=:A5.Get_Private_Path() 'private path is available during an autoexec script
                filename=path+"TECHBOARD.txt" 'whereas a_db_current_path is not
                result = File.Exists(filename)

                IF Result = .T. THEN 'Application saved last-used forms retrieve their names
                'nb these are literal names and not pointers

                file_pointer=File.open(filename,file_ro_exclusive)
                threads=File_pointer.Read_line()
                topics=File_pointer.Read_line()
                file_pointer.close()

                ELSE 'Inform the user and use small forms as a default
                message="TECHBOARD.txt doesn't exist. When you close the application"+crlf+
                "the forms you use will be remembered for next time."+crlf+crlf+
                "Using small forms as a default."+crlf+crlf+
                "Choose 'Switch_Forms' on the menu to change to large forms."
                ui_msg_box("No saved forms found",message,UI_INFORMATION_SYMBOL)

                threads = vThreadform_s
                topics = vTopicform_s

                END IF

                'Now load the actual forms
                :Statusbar.Set_Text("Loading application forms")
                :Statusbar.Disable()
                thr=form.load(threads)'Get the character variables into pointer variables
                thr.Index_Set("Headline")
                thr.show()
                thr.activate()

                top=form.load(topics)
                top.Index_Set("Title")
                :Statusbar.Enable()
                :Statusbar.Clear()

                END

                ERROR_HANDLER:
                On Error goto 0
                err=error_code_get()
                msg=error_text_get(err)
                ui_msg_box("Error",msg)
                :Statusbar.Enable()
                :Statusbar.Clear()
                END



                Bill Hanigsberg

                Comment


                  #9
                  RE: Saving Variables

                  Holy Smokes! Thank you Bill!

                  Comment

                  Working...
                  X