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

Debugging an xbasic function when running live

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

    Debugging an xbasic function when running live

    I'm working with DBF tables.

    I have an xbasic function that fails when running live but works right when running under localhost. The function is suppose to edit a field and save the edit. I can debug the function running in live preview and I do not see anything wrong. Running live does not generate any errors. Running live fails to either edit the field or save the changes, don't know which.

    I've looked at the code for hours trying different things with no success. I have other code that writes to the same field which works correctly. The code is almost identical. I'm baffled.

    Is there some way possible to debug the xbasic function when running live?
    Alpha 5 Version 11
    AA Build 2999, Build 4269, Current Build
    DBF's and MySql
    Desktop, Web on the Desktop and WEB

    Ron Anusiewicz

    #2
    Re: Debugging an xbasic function when running live

    Can you post the code? ...and the error?

    Short of that try placing this in your xbasic: file.append("c:\debug.txt","Line 10")

    That will generate a txt file with what ever is in the second parameter. In this case a line #. You can put this as many times as you want in the xbasic function. Maybe one at the beginning and end. Then a few in between. It'll help you narrow down the problem.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant​​

    Comment


      #3
      Re: Debugging an xbasic function when running live

      Mike, Thank you for your reply.

      I tried your suggestion using file.append("c:\debug.txt","Line 10") and no matter how I coded it, it would not work live.
      Worked just fine using localhost. I even set up a test environment to emulate the live running WEB app and file.append("c:\debug.txt","Line 10")
      just would not work. Maybe a security issue. I thought I had that covered.

      Anyways, here's the entire function. Works fine running under localhost. Debug doesn't generate any errors. Running live, at almost the end of the code, the
      line "td.ml = newText" does not appear to work.

      I have very similar code running throughout the app all running with no issues except for this one function. No errors, just does not write to the field.

      Thanks

      Code:
      function deleteMechEntry as v (e as p)
      	dim t as p
      	t = table.open("[PathAlias.ADB_Path]\wodesclabor_m_entry1")
      	t.fetch_goto(val(e.datasubmitted.fixentries))
      	t.change_begin(.t.)
      	t.delete()
      	t.change_end(.t.)
      	t.close()
      
      	filter = "Site="+s_quote(e.datasubmitted.site)+ ".AND. POSTED = .F. .AND. LOCKED <> .T. .AND. MECHANIC = "+s_quote(e.datasubmitted.mech)
      	
      	dim nrecs as N
      	nrecs = a5_get_records_in_query("[PathAlias.ADB_Path]\wodesclabor_m_entry1",filter)
      	if nrecs < 1 then
      		e.javascript = "{dialog.object}.setValue('FIXENTRIESVALUE',0);"
      	end if
      	
      debug(1)	
      		
      	''get variables for deleting corrective action entry
      	dim vcCASwkNo as C = e.datasubmitted.swkno
      	dim vcCATransno as C = e.datasubmitted.transnolbr
      	dim vEntryDate as C = alltrim(e.datasubmitted.Lbrdate)
      	dim vcML as C = alltrim(e.olddatasubmitted.workdone)
      	dim Search_Text as C = vcML + " - " + alltrim(e.datasubmitted.mech_name) + ", " + vEntryDate
      	dim td as p
      	td = table.open("[PathAlias.ADB_Path]\wodesclabor_m_ca")
      	td.order("transno+swkno","site="+s_quote(e.datasubmitted.site))
      	f = td.fetch_find(vcCATransno+vcCASwkNo)
      	if f > 0 then
      		ml = td.ml
      		'stritran options to delete only the first instance found
      		removeText = stritran(ml,Search_Text,"",1,1,1)
      		newText = remove_blank_lines(removeText)
      		td.change_begin()
      		td.ml = newText
      		td.change_end(.t.)
      	end if
      	td.close()
      end function
      Alpha 5 Version 11
      AA Build 2999, Build 4269, Current Build
      DBF's and MySql
      Desktop, Web on the Desktop and WEB

      Ron Anusiewicz

      Comment


        #4
        Re: Debugging an xbasic function when running live

        Could be the error is generated before the logging call
        Try adding the logging to start and end of the section of code you suspect is generating the error
        You can also use Save_To_File which has an append option.

        https://documentation.alphasoftware....20Function.xml
        https://appsbydesign.co.uk/

        Comment


          #5
          Re: Debugging an xbasic function when running live

          .
          Last edited by mumfie; 09-23-2019, 10:42 AM. Reason: db error
          https://appsbydesign.co.uk/

          Comment


            #6
            Re: Debugging an xbasic function when running live

            You can also set session variables throughout the procedure, then test the values of the session variables after the procedure runs.

            Comment


              #7
              Re: Debugging an xbasic function when running live

              Using session variables is the way to go.
              it looks like this line:

              Code:
              nrecs = a5_get_records_in_query("[PathAlias.ADB_Path]\wodesclabor_m_entry1",filter)
              is the source of my trouble. Not sure why at this time.

              The filter is valid. Not sure if the function itself is the problem.
              Alpha 5 Version 11
              AA Build 2999, Build 4269, Current Build
              DBF's and MySql
              Desktop, Web on the Desktop and WEB

              Ron Anusiewicz

              Comment


                #8
                Re: Debugging an xbasic function when running live

                If the file.append was on the very first line of your function, and still did not run, that means the problem is with how the function is being called. Is your developer AND app server on the same version of Alpha? There is something right under our (your) nose that is causing this.
                Mike Brown - Contact Me
                Programmatic Technologies, LLC
                Programmatic-Technologies.com
                Independent Developer & Consultant​​

                Comment


                  #9
                  Re: Debugging an xbasic function when running live

                  You should also check that PathAlias.ADB_Path is what you think it is on the live server.

                  Comment


                    #10
                    Re: Debugging an xbasic function when running live

                    Larry,

                    Thank you thank you thank you thank you thank you

                    Using session variables is a great way to debug. As it turns out, the issue was the function a5_get_records_in_query()
                    does not work in the live environment while it does work using localhost. I had to replace it with:

                    Code:
                    	dim nrecs as N
                    	query.filter = "Site="+s_quote(e.datasubmitted.site)+ ".AND. POSTED = .F. .AND. LOCKED <> .T. .AND. MECHANIC = "+s_quote(e.datasubmitted.mech)
                    	query.order = "Site+Mechanic"
                    
                    	session.vfilter = query.filter	'*****************
                    
                    	dim t as P
                    	t = table.open("[PathAlias.ADB_Path]\wodesclabor_m_entry1",FILE_RW_SHARED)
                    	qry = t.query_create()
                    	nrecs = qry.records_get()
                    	qry.drop()
                    	t.close()
                    
                    	session.nrecs = nrecs	'******************
                    Now the entire function works as designed.
                    Thank you all for your help.
                    Alpha 5 Version 11
                    AA Build 2999, Build 4269, Current Build
                    DBF's and MySql
                    Desktop, Web on the Desktop and WEB

                    Ron Anusiewicz

                    Comment


                      #11
                      Re: Debugging an xbasic function when running live

                      I often have the script send me an email with the values when it gets to be this troublesome.
                      PathAlias.adb_path and filter look like the items I'd include in the email.
                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                        #12
                        Re: Debugging an xbasic function when running live

                        If under "Live" (the real server) you did not see "c:\debug.txt" get created then that would be normal because writing outside the webroot folder is typically prohibited.
                        I'd recommend setting up an xbasic function in your Control Panel (Not Web Panel) that you call when you want to write debugging messages. Setup the type of parameters (information) you want to pass to this procedure. I keep it simple and just pass two parameters: 1) the message to put into the text file, 2) a flag to indicate Append or Overwrite existing debug file. Something like this:

                        FUNCTION WriteDbg AS V (msg as C, AppendFlag as L = .T. )
                        dim pref as C
                        pref = NOW()
                        '-- add some session vars, if you want.
                        if variable_exists(session.XXXX)
                        pref = pref + " XXXX=" + session.XXXX
                        end if
                        ... add more session vars
                        dim OutputFileNm as C
                        dim stat as L
                        OutputFileNm = "C:\A5Webroot\Debug\cptload.txt" ' A5Webroot is my server's web root, change it to yours. "Debug" is a folder I created in it.
                        stat = SAVE_TO_FILE( pref + "|| " + msg + crlf(), OutputFileNm , AppendFlag )

                        END FUNCTION

                        Comment


                          #13
                          Re: Debugging an xbasic function when running live

                          Originally posted by RichCPT View Post
                          If under "Live" (the real server) you did not see "c:\debug.txt" get created then that would be normal because writing outside the webroot folder is typically prohibited.
                          I'm surprised to hear this. I use the method in all of my apps to write debug or error related date to. Usually c:\debugData\errors.txt. Never had a permissions issue.
                          Mike Brown - Contact Me
                          Programmatic Technologies, LLC
                          Programmatic-Technologies.com
                          Independent Developer & Consultant​​

                          Comment


                            #14
                            Re: Debugging an xbasic function when running live

                            Mike,

                            It depends on how you setup the user that Alpha is logging in as.

                            Anyways, I have found that the issue is more with writing directly to the C: root than writing to another directory.

                            Going to c:\myfile.txt is different from going to c:\mydirectory\myfile.txt

                            But it's always easiest (permissionswise) to go to

                            c:\alphadirectory\whatever

                            Comment


                              #15
                              Re: Debugging an xbasic function when running live

                              Thanks to all who responded.

                              I did think it was a permission issue and set up a live test environment and that didn't work either.
                              The reason I had trouble, the script terminated before getting to my write to file code.

                              Using session variables was very easy for me to work with and made it much easier for me to troubleshoot.
                              In my apps, I include an admin only web page with the function: a5w_info().

                              So after each attempt, I would open the page and view all the session variables.

                              Thanks again.
                              Alpha 5 Version 11
                              AA Build 2999, Build 4269, Current Build
                              DBF's and MySql
                              Desktop, Web on the Desktop and WEB

                              Ron Anusiewicz

                              Comment

                              Working...
                              X