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



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

allowing user to select file for import

  • Filter
  • Time
  • Show
Clear All
new posts

    allowing user to select file for import

    I have created an action to import a csv file into an existing table. Is there a way to allow the end user to select the file to import (without asking the user to create the import action from scratch)?

    Re: allowing user to select file for import

    Will the files selected all have the same structure, just different data? The easiest way I know is to convert the action to xbasic and edit that.
    There can be only one.


      Re: allowing user to select file for import

      Yes Stan all the same structure. Unfortunately not proficient in xbasic. This is the Alpha generated code.

      temporary_import_table = file.temp_path_get()+ "proselect_temp_table.dbf"
      import_destination_table = "proselect"
      import_filename = filename_decode("\23101\previews\2012-05-28_083008_23101.csv")
      if file.exists(import_filename) = .f. then
      	ui_msg_box("Error","File to import not found: '"+import_filename+"'.",ui_stop_symbol)
      end if
      ON ERROR GOTO ERROR28052012085957171
      import.type = 0
      import.names = "none"
      import.file = import_filename
      import.db = temporary_import_table
      import.skip_lines = 0
      import.skip_bytes = 0
      import.field_sep = ","
      import.record_sep = "<CR><LF>"
      import.text_qualifier = ""
      import.record_len = 0
      import.rem_blanks = .F.
      import.escape_newlines = .F.
      import.import_encoding = "default"
      import.fields = 13
      import.field1 = "session_id,n,0,7,0"
      import.field2 = "first,c,1,15,0"
      import.field3 = "last,c,2,6,0"
      import.field4 = "line,n,3,2,0"
      import.field5 = "desc1,c,4,15,0"
      import.field6 = "descr2,c,5,20,0"
      import.field7 = "image,c,6,15,0"
      import.field8 = "field_8,c,7,1,0"
      import.field9 = "qty,n,8,3,0"
      import.field10 = "unit,n,9,9,2"
      import.field11 = "extended,n,10,9,2"
      import.field12 = "tax,n,11,8,2"
      import.field13 = "total,n,12,9,2"
      'Prompt for confirmation before appending the records that were imported into the temporary table.......
      dim rec_count as n
      rec_count = a5_get_records_in_query(temporary_import_table, ".t.")
      message_text = "" + rec_count + " record(s) will be imported into '"+import_destination_table+"'."+crlf(2)+ "OK to proceed?"
      operation_result=ui_msg_box("Import Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
      If operation_result <> ui_ok_selected then
      end if 
      a_tbl =
      append.t_db = temporary_import_table
      append.m_key = ""
      append.t_key = ""
      append.m_filter = ""
      append.t_filter = ""
      append.type = "All"
      append.m_count = 13
      append.m_field1 = "SESSION_ID"
      append.m_exp1 = "@proselect_temp_table->SESSION_ID"
      append.m_field2 = "FIRST"
      append.m_exp2 = "@proselect_temp_table->FIRST"
      append.m_field3 = "LAST"
      append.m_exp3 = "@proselect_temp_table->LAST"
      append.m_field4 = "LINE"
      append.m_exp4 = "@proselect_temp_table->LINE"
      append.m_field5 = "DESC1"
      append.m_exp5 = "@proselect_temp_table->DESC1"
      append.m_field6 = "DESCR2"
      append.m_exp6 = "@proselect_temp_table->DESCR2"
      append.m_field7 = "IMAGE"
      append.m_exp7 = "@proselect_temp_table->IMAGE"
      append.m_field8 = "FIELD_8"
      append.m_exp8 = "@proselect_temp_table->FIELD_8"
      append.m_field9 = "QTY"
      append.m_exp9 = "@proselect_temp_table->QTY"
      append.m_field10 = "UNIT"
      append.m_exp10 = "@proselect_temp_table->UNIT"
      append.m_field11 = "EXTENDED"
      append.m_exp11 = "@proselect_temp_table->EXTENDED"
      append.m_field12 = "TAX"
      append.m_exp12 = "@proselect_temp_table->TAX"
      append.m_field13 = "TOTAL"
      append.m_exp13 = "@proselect_temp_table->TOTAL"
      append.t_count = 0
      GOTO CONTINUE28052012085957171
      ui_msg_box("Error","Error running Import Operation"+crlf()+error_text_get())
      'In case the destination table is not already in the Database, add it...
      'If the Operation is run from within a Form or Browse, then refresh the window
      if is_object(topparent.this) then
      	if topparent.Class() = "form" .or. topparent.class() = "browse" then
      	end if
      end if


        Re: allowing user to select file for import

        You need to get the desired filename from the user and substitute it into this line

        import_filename = filename_decode("\23101\previews\2012-05-28_083008_23101.csv")

        Start the script with

        dim defdir as C = "c:\documents"
        'change the "c:\documents" to the directory where the files will be located
        filename = ui_get_file("Select File", "", defdir +"\*.csv")

        Then change the line

        import_filename = filename_decode(filename)
        There can be only one.


          Re: allowing user to select file for import

          Hi Stan,
          Believe it or not, I actually got it to work in a somewhat more primitive way.
          I changed that line to:
          import_filename = ui_get_file("Select file to import", "", "","")

          I will substitute your code. There is one more thing I would like to add as a refinement. The file that is being imported is always in a directory that has the following parameters.
          The drive is w:
          The record that I will be executing the import from has a numeric ID field that contains the name of the parent folder that contains the csv file.
          For example If the record 's ID contains 23101, then the path to the csv file would be.


            Re: allowing user to select file for import

            import_filename = ui_get_file("Select File", "", "W:\\"+id +"\Previews\*.csv")

            taking advantage of Alpha's automatic type conversion or

            import_filename = ui_get_file("Select File", "", "W:\\"+alltrim(str(id)) +"\Previews\*.csv")

            explicitly converting the numeric field value.
            There can be only one.


              Re: allowing user to select file for import

              Thank you


                Re: allowing user to select file for import

                At the end of the import operation Alpha presents a Dialog box requesting an option to view the results. How can I prevent that window from showing?


                  Re: allowing user to select file for import

                  Remove this

                  There can be only one.