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

Updating AutoExec Variables

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

    Updating AutoExec Variables

    Using the attached "example" file, I would like to create a way of updating the variables found in the AutoExec script without having to open the script and making the changes inside the script. Example, when I want to change the "Expiration Date" information found in the variable "EXDate" I have to open the AutoExec script thru the control panel and change it. I would like to create a way from the main menu that by pushing a button (ie "update) a Xdialog is displayed and I'm able to do update variables inside Autoexec this way. I don't want to limit the updating to just the "Expiration Date" but any and all variables found in the autoexec script. I have created a Xdialog and have successfully updated variables, until program is closed and re-opened.

    Thank you... JON
    Attached Files

    #2
    Re: Updating AutoExec Variables

    There are a few ways to do that. How you do it depends on personal preference and how secure you want it.

    One way that can make it easy for the user to change the values is to create a table with three fields - one holds the variable name, one holds the type, and one holds the value. If you want the user to be able to change them, just provide a form with a browse for editing them. If you only want specific users to change them, add a password prompt to the button that activates it. Then loop through the table like this:
    Code:
    tp = table.open( "app_settings", file_ro_shared )
    tp.fetch_first()
    WHILE .not. tp.fetch_eof()
    	evaluate_template( "dim global " + trim( tp.variable ) + " as " + trim( tp.type ) )
    	IF tp.Type = "C"
    		IF right( trim( tp.Value ), 1 ) = "\\"
    			'If the value ends with a backslash, add another as the escape character.
    			var_value = chr(34) + trim( tp.value ) + "\\" + chr(34)
    		ELSE
    			var_value = chr(34) + trim( tp.value ) + chr(34)
    		END IF
    		evaluate_template( trim( tp.Variable ) + "=" + var_value )
    	ELSE
    		evaluate_template( trim( tp.Variable ) + "=" + trim( tp.value ) )
    	END IF
    	tp.fetch_next()
    END WHILE
    Another way is to put the values in a text file and import them from there. Other than retrieving the text, the rest of the loop follows the same concept as above. The security of putting them in a text file vs. a table is debatable. You could encrypt the vales in the text file to keep users from editing them but you could do the same to the values in the table.

    Of course, it easiest to update a single value if it's in a table. That way you can have an index on the variable name field and edit just that one record.

    Comment


      #3
      Re: Updating AutoExec Variables

      Thanks Cal for the response. I would be the one updating the values. As we hire new salesmen and our program is distributed to them, I have found it easiest to create variables for various scripts. This way I can open the Autoexec script and make necessary changes such as "Salesman's Name, Address, etc.... I have successfully created a form that when opened allows me to do such modifications. Just not a big fan of putting that info in a table (.dbf) file for security reasons. Was hoping I could use a Xdialog box that was password protected and would allow me to make "permanent" changes to the values of the variables found in the Autoexec script. In your reply, you stated that "you could encrypt values found in a table", HOW? Do you have an example you could share?

      Comment


        #4
        Re: Updating AutoExec Variables

        Put this script on a button on the form:
        Code:
        dim global EXDate as d=date()
        dim global SCLDate as d
        DIM Global SMData as C
        DIM Global SMName as C
        dim scrpt as c=""
        ui_modeless_dlg_box("Update AutoExec",<<%dlg%
        {xmargin=2}
        {ymargin=2}
        EXDate: | [%DATE;P=popup.calendar(dtoc(EXDate));I=popup.calendar%.20EXDate!d_*];
        SCLDate: | [%DATE;P=popup.calendar(dtoc(SCLDate));I=popup.calendar%.20SCLDate!d_*];
        SMName : | [.20SMName];
        
        <Update!Update><Cancel!cancel>
        %dlg%,<<%code%
        if a_dlg_button="cancel"
        ui_modeless_dlg_close("Update AutoExec")
        	end if
        if a_dlg_button="d_change"	
        x= regex_split(word(word(ui_dlg_ctl_current("Update AutoExec"),3,"%"),1,"!"),"[.0-9]")
        x=ctod(dtoc(eval(x)))
        end if	
        if a_dlg_button="Update"
        scrpt="Dim Global EXDate as D"+crlf()+"EXDate ="+EXDate+crlf()
        scrpt=scrpt+"DIM Global SCLDate as D"+crlf()+"SCLDate = tablemax(\"tbl_sales data\",\".t.\",\"date\")"+crlf()
        scrpt=scrpt+"DIM Global SMData as C"+crlf()+"SMData = \"C:\Users\Steve\Desktop\Steve Martin Sales Data thru \" +dtoc("+SCLDate+",\"6-\") +\".zip\""+crlf()
        scrpt=scrpt+"DIM Global SMName as C"+crlf()+"SMName ="+SMName
        script_save("AutoExec",scrpt)
        msgbox("Script updated successfully!")
        ui_modeless_dlg_close("Update AutoExec")
        end if
        %code%)
        Incidentally, not sure why you want to update SCLDate?

        Comment


          #5
          Re: Updating AutoExec Variables

          My salesperson/employee table is encrypted. So is my customer information table and a couple more.
          I have a scri[t set to do the encryption and the autoexec has the encryption key so alpha can read the tables.
          Look up encrypt in the help files and/or on this forum.
          Dave Mason
          [email protected]
          Skype is dave.mason46

          Comment


            #6
            Re: Updating AutoExec Variables

            Thanks G.Gabriel for the code. I have attached a new example file with your code inserted as a script (Update AutoExec). Unfortunately, I can't seem to get it to work. Hitting "Update" button on the main menu brings up the Xdialog box where I make changes to variables found in AutoExec and all seems well til you restart program and then the following error appears: "There was an error running the AutoExec script. Argument is incorrect data type. Also, when the Xdialog box is brought up, I would like it to show the "current values" of the variables and give me the option to change them.

            PS: I do NOT want to update the variable SCLDate. Sorry for the confusion, was just trying to but together an example....

            Thanks again... JON
            Attached Files

            Comment


              #7
              Re: Updating AutoExec Variables

              Thanks Dave for the info.

              Comment


                #8
                Re: Updating AutoExec Variables

                The error is not in my code but rather in your original code, specifically:
                dtoc(04/08/2012,"6-")
                It should be dtoc({04/08/2012},"6-")
                That's what is giving you the error message.
                It's a simple fix.
                There was actually couple other errors that I fixed.
                Code:
                dim global EXDate as d=date()
                dim global SCLDate as D
                DIM Global SMData as C
                DIM Global SMName as C
                dim scrpt as c=""
                ui_modeless_dlg_box("Update AutoExec",<<%dlg%
                {xmargin=2}
                {ymargin=2}
                EXDate: | [%DATE;P=popup.calendar(dtoc(EXDate));I=popup.calendar%.20EXDate!d_*];
                SCLDate: | [%DATE;P=popup.calendar(dtoc(SCLDate));I=popup.calendar%.20SCLDate!d_*];
                SMName : | [.20SMName];
                
                <Update!Update><Cancel!cancel>
                %dlg%,<<%code%
                if a_dlg_button="cancel"
                ui_modeless_dlg_close("Update AutoExec")
                	end if
                if a_dlg_button="d_change"	
                x= regex_split(word(word(ui_dlg_ctl_current("Update AutoExec"),3,"%"),1,"!"),"[.0-9]")
                x=ctod(dtoc(eval(x)))
                end if	
                if a_dlg_button="Update"
                scrpt="Dim Global EXDate as D"+crlf()+"EXDate ={"+EXDate+"}"+crlf()
                scrpt=scrpt+"DIM Global SCLDate as D"+crlf()+"SCLDate = tablemax(\"tbl_sales data\",\".t.\",\"date\")"+crlf()
                scrpt=scrpt+"DIM Global SMData as C"+crlf()+"SMData = \"C:\Users\Steve\Desktop\Steve Martin Sales Data thru \" +dtoc({"+SCLDate+"},\"6-\") +\".zip\""+crlf()
                scrpt=scrpt+"DIM Global SMName as C"+crlf()+"SMName ="+quote(SMName)
                script_save("AutoExec",scrpt)
                msgbox("Script updated successfully!")
                ui_modeless_dlg_close("Update AutoExec")
                end if
                %code%)
                Last edited by G Gabriel; 04-13-2012, 03:07 PM.

                Comment


                  #9
                  Re: Updating AutoExec Variables

                  Original code was SMData = "C:\Users\Steve\Desktop\Steve Martin Sales Data thru " +dtoc(SCLDate,"6-") +".zip" which the variable SCLDate was the "date" of "Steve's" last sales call so that when a zip file was created to the desktop the name of the file was "Steve Martin Sales Data thru 04-08-12". Change the first part of the code to reflect the location of your desktop and you'll see what of mean. To be honest, if the Xdialog updated just the EXDate, that would be okay with me. I was just hoping that If I ever needed to make changes to the variables in the autoexec, I could do all of them... thanks again

                  Comment


                    #10
                    Re: Updating AutoExec Variables

                    Check the above code.

                    Comment


                      #11
                      Re: Updating AutoExec Variables

                      I need to keep the part of the code for the variable "SMData" like it was originally was (+dtoc(SCLDate,"6-") +".zip" . The way you have modified it, doesn't reference the last sales call date from the table "Sales Data", it simply makes the date "04/08/12". I need the date in the zip file's name to contain the date of the last sales call. I do appreciate you trying to make this work for me. Sounds like I'm just going to have to make the modifications to the values of the variables the old fashion way (opening the control panel and then autoexec script and go from line to line and modify as needed. Bummer.... thank you sir

                      Comment


                        #12
                        Re: Updating AutoExec Variables

                        The error was not in your original code. Apologies. It was how it was translated when I "adopted" it. Should have seen it coming. It is working now.
                        Check the above code.

                        Comment


                          #13
                          Re: Updating AutoExec Variables

                          G.Gabriel, is there a way of having the "orginal values" of the variables be determined by what the user inputs in a Xdialog box? Would this make it any easier?

                          Comment


                            #14
                            Re: Updating AutoExec Variables

                            I tried your updated code you posted/modified in post #8 about 35 minutes ago. Have you posted code since then?
                            Last edited by jbk; 04-13-2012, 04:04 PM.

                            Comment


                              #15
                              Re: Updating AutoExec Variables

                              The code as it is produces this file path:
                              C:\Users\Steve\Desktop\Steve Martin Sales Data thru 04-08-12.zip
                              Isn't that what you want?
                              And yes, the code uses the values entered by the user in the xdlg.
                              I have to leave in 5 minutes!

                              Comment

                              Working...
                              X