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

Escaping the plus (+) sign in an XBasic function

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

    Escaping the plus (+) sign in an XBasic function

    I feel that I am missing something obvious. I have a small IIS server app whose only job is to convert signatures saved in the ink format to png. I have a javascript function that loops through a list to get all the signatures in the ink format. It then passes the info to an XBasic function, which calls the a5_ink_to_png function to save the ink as a png on our server. The problem is that whenever I pass the ink to the XBasic function, the plus (+) signs are missing from the data. There must be some obvious way to escape the + signs that I am missing. My XBasic function looks at follows

    Code:
    function convertInk as c (e as p)
    	on error goto error_handler
    
    	dim flagUseViewBox as L
    	flagUseViewBox = .f.
    	dim ink as C = e.ApprovedBySignature
    	dim placepk as C = e.PlacePK
    	dim salescallid as C = e.SalesCallID
    
    	a5_ink_to_png(ink,300,750,"C:\inetpub\wwwroot\appPhotos\ink_"+placepk+"_"+salescallid+".png",flagUseViewBox)
    
    	save_to_file("convertInk success:ink_"+placepk+"_"+salescallid+".png" + crlf() + "ink:" + ink + crlf() + "c.ApprovedBySignature:"+e.ApprovedBySignature + crlf(), "C:\Users\Public\Documents\ServerTasks.txt", .T.)
    	convertInk = "console.log('covertInk XBasic funtion - success');"
    	end
    	error_handler:
    	    err = error_code_get()
    	    msg = error_text_get(err)
    	    msg = STRTRAN(msg, crlf(), "")
    	    save_to_file("Error in convertInk: " + msg+ crlf(), "C:\Users\Public\Documents\ServerTasks.txt", .T.)
    	    convertInk = "console.log('covertInk XBasic funtion - error');"
    	end
    end function
    My Alpha build is 6402. Using the XBasic debugger, I am able to do something like this

    Code:
    dim str as C
    str = "hello+hello"
    The variable str prints out with the + sign in it, so I am not sure why the + sign is missing when passed in to the XBasic function. Thanks in advance for any help.

    #2
    Re: Escaping the plus (+) sign in an XBasic function

    Originally posted by RustyB View Post
    I feel that I am missing something obvious. I have a small IIS server app whose only job is to convert signatures saved in the ink format to png. I have a javascript function that loops through a list to get all the signatures in the ink format. It then passes the info to an XBasic function, which calls the a5_ink_to_png function to save the ink as a png on our server. The problem is that whenever I pass the ink to the XBasic function, the plus (+) signs are missing from the data. There must be some obvious way to escape the + signs that I am missing. My XBasic function looks at follows

    Code:
    function convertInk as c (e as p)
    	on error goto error_handler
    
    	dim flagUseViewBox as L
    	flagUseViewBox = .f.
    	dim ink as C = e.ApprovedBySignature
    	dim placepk as C = e.PlacePK
    	dim salescallid as C = e.SalesCallID
    
    	a5_ink_to_png(ink,300,750,"C:\inetpub\wwwroot\appPhotos\ink_"+placepk+"_"+salescallid+".png",flagUseViewBox)
    
    	save_to_file("convertInk success:ink_"+placepk+"_"+salescallid+".png" + crlf() + "ink:" + ink + crlf() + "c.ApprovedBySignature:"+e.ApprovedBySignature + crlf(), "C:\Users\Public\Documents\ServerTasks.txt", .T.)
    	convertInk = "console.log('covertInk XBasic funtion - success');"
    	end
    	error_handler:
    	    err = error_code_get()
    	    msg = error_text_get(err)
    	    msg = STRTRAN(msg, crlf(), "")
    	    save_to_file("Error in convertInk: " + msg+ crlf(), "C:\Users\Public\Documents\ServerTasks.txt", .T.)
    	    convertInk = "console.log('covertInk XBasic funtion - error');"
    	end
    end function
    My Alpha build is 6402. Using the XBasic debugger, I am able to do something like this

    Code:
    dim str as C
    str = "hello+hello"
    The variable str prints out with the + sign in it, so I am not sure why the + sign is missing when passed in to the XBasic function. Thanks in advance for any help.
    What is your JavaScript for passing the data to the Ajax callback?
    Sarah Mitchell
    Director of Customer Success | [URL="https://www.alphasoftware.com"]Alpha Software Corporation[/URL]
    [B]Get in the know! [/B] Join us for our Weekly Webinars: [URL="https://www.alphasoftware.com/weekly-transform-tuesday-webinar"]TransForm Tuesday[/URL] and [URL="https://www.alphasoftware.com/weekly-alpha-anywhere-overview-webinar"]Wednesday's Alpha Anywhere Demo and Q&A[/URL]
    Connect with us: [URL="https://www.instagram.com/alpha_software_corp/"]Instagram[/URL] | [URL="https://twitter.com/AlphaSoftware"]Twitter[/URL] | [URL="https://www.facebook.com/AlphaSoftware/"]Facebook[/URL] | [URL="https://www.linkedin.com/company/alpha-software"]LinkedIn[/URL] | [URL="https://www.youtube.com/user/AlphaSoftwareInc"]YouTube[/URL]

    Comment


      #3
      Re: Escaping the plus (+) sign in an XBasic function

      Rusty, you may just need to encode the ink string before passing it to XBasic.

      Code:
      var encSigInk = encodeURI(sigInk);
      I've tested this and the a5_ink_to_png works fine on an encoded string.

      Are you getting an error with your code?

      Comment


        #4
        Re: Escaping the plus (+) sign in an XBasic function

        Originally posted by Beta Spark View Post
        What is your JavaScript for passing the data to the Ajax callback?
        Hi Sarah. This is my Javascript.

        Code:
        console.log('BTN_CONVERTALL - start'); 
        var obj_list_LISTSALESCALLLIST = {dialog.object}.getControl("LISTSALESCALLLIST");
        var SalesCallListObj = obj_list_LISTSALESCALLLIST._data.filter(index => (index.ApprovedBySignature != "" && index.ApprovedBySignature != null) && (index.ApprovedBySignatureFilename == "" || index.ApprovedBySignatureFilename == null));
        if(typeof SalesCallListObj != "undefined"){
        	console.log('BTN_CONVERTALL - length:'+SalesCallListObj.length);
        	for (var i = 0; i < SalesCallListObj.length; i++) {
        		var PlacePK = SalesCallListObj[i].PlacePK;
        		var SalesCallID = SalesCallListObj[i].SalesCallID;
        		var ApprovedBySignature = SalesCallListObj[i].ApprovedBySignature;
        		//var ApprovedBySignature = ApprovedBySignature.replace(/+/g, "\+");
        		var reportParameters = 'PlacePK=' + PlacePK + '&SalesCallID=' + SalesCallID + '&ApprovedBySignature=' + ApprovedBySignature;
        		console.log('BTN_CONVERTALL - About to call convertInk XBasic funtion - reportParameters:'+reportParameters); 
        		{dialog.object}.ajaxCallback('', '', 'convertInk', '', reportParameters, {
        			errorFunction: function() {
        										console.log('Ajax Callback Action - convertInk - errorFunction');  
        									  },
        			onComplete: function() { 
        									    console.log('Ajax Callback Action - convertInk - onComplete');
        									    var jsonData = {};
        									    jsonData.ApprovedBySignatureFilename = "ink_"+PlacePK+"_"+SalesCallID+".png";
        									    obj_list_LISTSALESCALLLIST.updateTableRow(SalesCallID,jsonData);
        								   },
        			deviceOfflineFunction: function() {
        												console.log('Ajax Callback Action - convertInk - deviceOfflineFunction');
        								   			  }
        		});
        		console.log('CovertAll:');
        	}
        }else{
        	console.log('CovertAll: No records found in SalesCallList');
        }
        
        console.log('BTN_CONVERTALL - end');
        Thanks Penge. I'll give that a try in the morning.

        Comment


          #5
          Re: Escaping the plus (+) sign in an XBasic function

          I don't know how many List rows you're working on, but I wouldn't make 1 Ajax Callback for each row. I would collect all information in a json object array, convert it to a string, and pass that data back to XBasic. Convert that json to a pointer variable and loop through processing the ink data. 1 callback for all the data.

          Comment


            #6
            Re: Escaping the plus (+) sign in an XBasic function

            Originally posted by pngbungalow View Post
            Rusty, you may just need to encode the ink string before passing it to XBasic.

            Are you getting an error with your code?
            Unfortunately the encodeURI function did not work. No, I am not getting any errors in my code. It is the weiredest thing. I can console log the ink field in Javascript and the + signs are there, but when I pass them to XBasic the + signs are gone.

            I don't know how many List rows you're working on, but I wouldn't make 1 Ajax Callback for each row. I would collect all information in a json object array, convert it to a string, and pass that data back to XBasic. Convert that json to a pointer variable and loop through processing the ink data. 1 callback for all the data.
            I'm not dealing with much data. As a matter of fact, the next step after I get this working is to try to make this a little more automatic and have the process trigger as soon as a signature is synced from someones tablet. But what you are saying sounds like a pretty good practice. I will try that out.

            Comment


              #7
              Re: Escaping the plus (+) sign in an XBasic function

              Using your code, without the encodeURI, a5_ink_to_png() gives me an XBasic error "Unexpected token xx in JSON at position 0" . With the encodeURI in place in the Javascript code, there are no errors and the conversion is successful.

              Are you sure your target folders have all the proper permission for writing a file?

              Regarding the missing "+" signs from the signature, I see the same here, there are no "+" signs. I don't think this is the issue as they are probably just non-displayable characters.

              How do all the variables look under Javascript and XBasic debugging?
              Last edited by Davidk; 01-30-2020, 01:45 PM.

              Comment


                #8
                Re: Escaping the plus (+) sign in an XBasic function

                Another Javascript function to try is encodeURIComponent() as this encodes more characters including +. At least this will give you back your + signs. I get the same successful results using either function but you may have better luck using this.

                I may have misunderstood your original post. Are your + signs simply missing from your txt file? Is that the only problem?

                Is your png file being correctly created?

                Comment


                  #9
                  Re: Escaping the plus (+) sign in an XBasic function

                  Originally posted by pngbungalow View Post
                  Regarding the missing "+" signs from the signature, I see the same here, there are no "+" signs. I don't think this is the issue as they are probably just non-displayable characters.
                  The png file does not look right at all and does not match the signature. That is why I though the + signs missing were causing problems. It does create the png, so I don't think it is a permission issue.

                  Originally posted by pngbungalow View Post
                  Using your code, without the encodeURI, a5_ink_to_png() gives me an XBasic error "Unexpected token xx in JSON at position 0"
                  I was getting that error in Live Preview, but not when I published to the server. So I thought it was just a Live Preview problem.

                  Comment


                    #10
                    Re: Escaping the plus (+) sign in an XBasic function

                    Originally posted by pngbungalow View Post
                    Another Javascript function to try is encodeURIComponent() as this encodes more characters including +. At least this will give you back your + signs. I get the same successful results using either function but you may have better luck using this.
                    encodeURIComponent() did the trick. Thank you so much for your help!!!

                    Comment

                    Working...
                    X