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

Keeping numeric field numeric upon importing

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

    Keeping numeric field numeric upon importing

    Hello all. The basis behind the application I am designing is that a file is imported into my database every morning and a series of steps are performed, generating reports and letters that print automatically. Everything is automated so that the user hits "Start" and knows nothing about how or why it happens, it just does....

    The major hurdle has been the attempt to seamlessly import the file from the user's database. After many hours playing with different ways of importing, I thought that the following code was getting the job done: (I will not pretend to know what type of import this is, I just know that it basically worked....)

    dim inputs as p
    inputs=table.open("user inputs")

    import_destination_table = filename_decode("import.dbf")


    'this line reads where the user saved the file that is to 'be imported
    import_filename = filename_decode(inputs.filename)
    if file.exists(import_filename) = .f. then
    ui_msg_box("Error","File to import not found: '"+import_filename+"'.",ui_stop_symbol)
    end
    end if

    import.type = 0
    import.names = "use"
    import.file = import_filename
    import.db = import_destination_table
    import.skip_lines = 0
    import.skip_bytes = 0
    import.field_sep = " "
    import.record_sep = ""
    import.text_qualifier = ""
    import.record_len = 294
    import.rem_blanks = .F.
    import.escape_newlines = .F.
    import.fields = 25
    import.field1 = "account_number,n,0,19,0"
    import.field2 = "name,c,1,50,0"
    import.field3 = "name_2,c,2,50,0"
    import.field4 = "address1,c,3,50,0"
    import.field5 = "address2,c,4,50,0"
    import.field6 = "address3,c,5,50,0"
    import.field7 = "city,c,6,50,0"
    import.field8 = "state,c,7,50,0"
    import.field9 = "zip,c,8,16,0"
    import.field10 = "zip2,c,9,16,0"
    import.field11 = "home_phone,c,10,20,0"
    import.field12 = "branch,n,11,19,0"
    import.field13 = "acct_type,n,12,19,0"
    import.field14 = "officer,c,13,20,0"
    import.field15 = "dda_balance,n,14,19,2"
    import.field16 = "ytd_average,n,15,19,2"
    import.field17 = "days_od,n,16,19,0"
    import.field18 = "of_deposits,n,17,19,0"
    import.field19 = "o_d_limit,n,18,19,0"
    import.field20 = "ytd_nsfs,n,19,19,0"
    import.field21 = "times_o_d_ytd,n,20,19,0"
    import.field22 = "date_last_deposit,d,21,8,0"
    import.field23 = "date_opened,d,22,8,0"
    import.field24 = "date_entered_od,d,23,8,0"
    import.field25 = "holds,n,24,19,2"
    import()


    'Add the import destination table to the database....
    file_add_to_db(table.filename_get(import_destination_table))

    '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
    topparent.Refresh_layout()
    end if
    end if

    '*******************************************************

    The problem is that for fields with dollar amounts and/or negative numbers (dda_balance, ytd_average, od_limit), the file to be imported contains parentheses "()" for negative amounts and dollar signs "$" for everything in these three fields, oh yeah, and commas too. Therefore, these characters cause the values to become zero, as my table has these fields designated as numeric. I do many calculations with these numbers and really need them to remain numeric.

    So, I noticed that importing the data from Excel using the ODBC Import Genie allows the data to remain numeric, i.e. the genie recognizes that the data is numeric, and negative. This is great, but my users will use Runtime, which will not support the ODBC Import Genie.

    So, I am back to where I was.

    Here are my options as I see them, this is where I would really appreciate some ideas and experience!

    1) Redefine my table's fields as character and import the data as such. Then somehow find a way to strip the dollar signs, commas, and replace the parentheses with a minus sign "-". Then dump the data into a new field that is numeric. (I have no idea if this can be done and how difficult it will be...)

    2) See if my users can save the import data as a different type of file that will enable Alpha to recognize these problem fields as numeric.

    3) See if my users can save the import data without the characters (dollar signs and parentheses).

    Well, if you've read this far I truely appreciate it! I am stupped and am greatful for any suggestions.

    Dave

    #2
    RE: Keeping numeric field numeric upon importing

    1. add the function shown below to your database
    2. import the money values as character value.
    3. add fields to your table to hold the numeric values of the money fields.
    4. run an Update operation to update the numeric fields.

    say that the char money field is called "money_c" and the numeric money field is "money_n", the update expression for money_n is: money_to_number(money_c)







    function money_to_number as n (string as c)

    dim decimal_sep as c
    dim thousand_sep as c
    dim currency_prefix as c
    decimal_sep = a5.System_Mode_Get("number.decimal")
    thousand_sep = a5.System_Mode_Get("number.thousand")
    currency_prefix = a5.System_Mode_Get("currency.prefix")

    dim multiplier as n
    multiplier = 1

    string = stritran(string,thousand_sep,"")
    string = stritran(string,currency_prefix,"")
    if atc("(",string) > 0 then
    multiplier = -1
    string = stritran(string,"(","")
    string = stritran(string,")","")
    end if

    money_to_number = multiplier * val(string)

    end function

    Comment


      #3
      RE: Keeping numeric field numeric upon importing

      Perfect! Thank you Mr. Rabins for the function and for the instructions on how to use it. It works great!

      Dave

      Comment

      Working...
      X