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

Folder creation in xbasic script not working

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

    Folder creation in xbasic script not working

    This works in the interactive window on my development machine but it doesn't work in production. I want to control where documents I am generating are stored. Any help is appreciated!

    Code:
    dim MarketingName as C = "Test"
    dim folderpath as C="c:\Sales Files\Generated Documents\Sales Contract"
    file.dir_create_recurse(folderpath + chr(92) + MarketingName)

    #2
    Re: Folder creation in xbasic script not working

    I wonder if you are encountering an NTFS permissions issue. On the production machine manually create the folder structure to verify that the user has the necessary permissions.
    Andrew

    Comment


      #3
      Re: Folder creation in xbasic script not working

      Be advised that if you should migrate to IIS this is not supposed to work by default as IIS default security settings will not allow it. Alternative would be to use A5storage (see release notes)
      Frank

      Tell me and I'll forget; show me and I may remember; involve me and I'll understand

      Comment


        #4
        Re: Folder creation in xbasic script not working

        Originally posted by Clipper87 View Post
        Be advised that if you should migrate to IIS this is not supposed to work by default as IIS default security settings will not allow it. Alternative would be to use A5storage (see release notes)
        I didn't notice that this was posted in the Mobile & Browser application forum. Can the application server access and manipulate folders outside of the webroot folder?
        Andrew

        Comment


          #5
          Re: Folder creation in xbasic script not working

          Originally posted by aschone View Post
          I didn't notice that this was posted in the Mobile & Browser application forum. Can the application server access and manipulate folders outside of the webroot folder?
          You would certainly hope not.

          I'd go with that....
          Al Buchholz
          Bookwood Systems, LTD
          Weekly QReportBuilder Webinars Thursday 1 pm CST

          Occam's Razor - KISS
          Normalize till it hurts - De-normalize till it works.
          Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
          When we triage a problem it is much easier to read sample systems than to read a mind.
          "Make it as simple as possible, but not simpler."
          Albert Einstein

          http://www.iadn.com/images/media/iadn_member.png

          Comment


            #6
            Re: Folder creation in xbasic script not working

            Well I was able to create an a5w page with the code above and run it in the browser and it did create the folder

            Comment


              #7
              Re: Folder creation in xbasic script not working

              Do you guys generate any documents from within your app that you need to store? How do you handle this?

              Comment


                #8
                Re: Folder creation in xbasic script not working

                Josh,

                I think your problem is the space in folderpath. Replace it with an underline and it will probably work.

                You asked what others do, so here's what I do.

                In one place, I use code similar to yours just to make sure the directories exists. Each project (Session.JOBNAME) has it's own directories.

                '*********** make sure the target directories exists
                vWipDir=dir_create_recurse("c:\enefen\000_NFN_Projects"+chr(92)+Session.JOBNAME+"\NFNWIP")
                vFinDir=dir_create_recurse("c:\enefen\000_NFN_Projects"+chr(92)+Session.JOBNAME+"\NFNFinished")
                sleep(0)

                Then when I'm setting up to print reports
                vSpath = "c:\a5v12\a5reports"
                vRpath = "c:\enefen\000_NFN_Projects"
                Session.SOURCE = vSpath+chr(92)+"NFN"+Session.JOBNO+"_"+vDatetime+"_"
                Session.DESTINATION = vRpath+chr(92)+Session.JOBNAME+"\NFNWIP" + chr(92)+ "NFN"+Session.JOBNO+"_"+vDateTime+"_"

                I use the session variables because I create between 4 and 20 reports, then append them together in a separate print routine and a separate append routine.

                Then in the print routine
                vSource = Session.SOURCE + RptArray[vIndx].Code+".pdf"
                vDestination = Session.DESTINATION + RptArray[vIndx].Code+".pdf"
                vRprtSaved = a5w_report_saveAs(RptArray[vIndx].Code+"@c:\nfn_v12\nfn.alb","pdf","","",vSource,global_variables(),pdfopts,args,opts)
                sleep(0)
                file.copy(vSource,vDestination)

                Where RptArray[vIndx].code contains the name of the individual report. Reports are all printed into c:\a5v12\a5reports and then copied into the project directories. The sleep(0) gives them time to get printed before I try to copy them..

                Pat
                Last edited by Pat Bremkamp; 06-09-2015, 09:21 PM.
                Pat Bremkamp
                MindKicks Consulting

                Comment


                  #9
                  Re: Folder creation in xbasic script not working

                  Pat,

                  It works when I run the script from an a5w page. It just doesn't seem to work within my script. I'll have to install a copy of the developer on the server so that I can debug

                  Thank you for the helpful information!

                  Comment


                    #10
                    Re: Folder creation in xbasic script not working

                    It works when I run the script from an a5w page. It just doesn't seem to work within my script
                    I think that is because a5w page runs in the server and so it has access to the server computer areas, but not the script which runs in the browser - for safety reasons. I remember reading similar to this in one of the documents. if I see that, I will post a link. it has to do with accessing other areas of the server computer or files in the server computer other than the webroot.

                    edit:
                    here is that link:
                    http://wiki.alphasoftware.com/Access...de+the+Webroot
                    2.Create an A5W page that opens the file and sends it to the browser. Because the A5W page runs locally on the server, it has access to the whole file system. If you use this technique, make sure you provide some type of protection so that the user cannot specify any arbitrary file on your server.
                    Last edited by GGandhi; 06-10-2015, 09:53 AM.
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                      #11
                      Re: Folder creation in xbasic script not working

                      Pat,

                      How do the folders get created? Is everyone correct in that you can not do this with a callback? I understand the security concerns but am just curious how you handle it. Does the function above create the project folder?

                      Comment


                        #12
                        Re: Folder creation in xbasic script not working

                        Same way, except initially, I create the directories with a User Defined Function

                        In the AfterInsertRecord event
                        vMade=Make_Local_Dirs(vPNC,vOW,vCL)

                        calls this function
                        FUNCTION Make_Local_Dirs AS C (p_Projectid AS C, p_OwnerName AS C, p_ClientName AS C )
                        vProjectid = "NFN"+right("0"+alltrim(p_Projectid),7)
                        vOwner = alltrim(word(alltrim(p_OwnerName),1))
                        vClient = alltrim(word(alltrim(p_ClientName),1))
                        dim vPath as c
                        dim vProjectname as c
                        dim vResult as l
                        dim vDircount as n
                        vDircount = 0
                        vPath = "c:\enefen\000_NFN_Projects"
                        vProjectname = vProjectid+"_"+vOwner+"_"+vClient
                        vResult=dir_create_recurse(vPath+chr(92)+vProjectname+chr(92)+"ClientDocs")
                        sleep(.1)
                        if vResult = .t.
                        vDircount=vDircount+1
                        end if
                        .
                        Same for the other 4 directories
                        .
                        Make_Local_Dirs = str(vDircount,1,0)+" of 5 directories were created"
                        END FUNCTION

                        So far, this has worked over 4000 times

                        Pat
                        Pat Bremkamp
                        MindKicks Consulting

                        Comment


                          #13
                          Re: Folder creation in xbasic script not working

                          I create folders on my servers root drive by using the dir_create function. I am able to save images, pdfs etc in those folders and save and retrieve them from a browser on the client machine. I don't recall giving any special permissions to allow this. I guess when I convert to iis i will have some headaches.
                          Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                          Comment


                            #14
                            Re: Folder creation in xbasic script not working

                            Fyi for All,

                            function saveFiles as v (e as p)
                            'This function is called after the file(s) selected in the Upload Files dialog have been uploaded to the server.
                            'The function is responsible for processing each uploaded file.

                            dim count as n
                            count = e.filecount
                            dim i as n
                            dim arr as p
                            arr = e.filearray
                            dim cn as sql::connection
                            dim cs as c
                            cs = e.tmpl.cs.connectionstring
                            cn.open(cs)
                            dim sql as c
                            sql = "INSERT INTO CLAIM_FILE_UPLOAD (CLIENT, CLAIM_NO, REOPEN_NO, CODE, LINKEDFILE) Values (:CLIENT, :CLAIM_NO, :REOPEN_NO, :CODE, :Filename)"

                            dim args as sql::arguments
                            args.add("CLAIM_NO",convert_type(e.primaryKeyArray[1],"N"))
                            args.add("CLIENT",convert_type(e.primaryKeyArray[2],"C"))
                            args.add("CODE",convert_type(e.primaryKeyArray[3],"C"))
                            args.add("REOPEN_NO",convert_type(e.primaryKeyArray[4],"N"))

                            genedate = cdate(now())
                            genemonth = month(now())
                            geneyear = year(now())
                            user = session.g_userid
                            claimno = convert_type(e.primaryKeyArray[1],"N")

                            for i = 1 to count
                            dim fn as c
                            dim fn1 as c
                            dim data as c
                            data = e.fileArray[i].tempFileUploadedData
                            fn = "C:\FileUpload_Doc"
                            fn1 = "C:\FileUpload_Doc" + chr(92) + user + chr(92) + claimno + chr(92) + e.fileArray[i].fileName
                            dim file as l
                            dim vDircount as n
                            vDircount = 0
                            file = dir_create_recurse(fn + chr(92) + user + chr(92) + claimno)
                            sleep(.1)
                            if file = .t.
                            vDircount=vDircount+1
                            end if
                            file.copy(data,fn1)
                            'file.From_blob(fn,data)

                            dim fntoStore as c
                            fntoStore = e.fileArray[i].fileName

                            args.Add("Filename",fntoStore)
                            flag = cn.Execute(sql,args)
                            next i
                            cn.Close()

                            Comment

                            Working...
                            X