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

Programming Puzzle 9 - Dump ta dump

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

    Programming Puzzle 9 - Dump ta dump

    Beginning Xbasic Programming

    Puzzle 9 - Dump ta dump

    You solved Puzzle 6, 7, & 8 but NOW your sales manager tells you
    that the list of product sales doesn't do anyone any good displayed on
    screen. She needs the list of sales in a text file she can print or
    send to others. After noting that it took you longer to do the
    descending sort that she had expected, she says dumping the
    list to a disk file should be trivial. After all, you're dumping it
    to the trace window already, right?

    After contemplating what you might want to "dump" on your manager,
    you realize that your job now is to write an xbasic script that will list
    each product in the Inivoice_items table and for each product show the
    total dollars generated by that item across all the invoices. Your list
    should be sorted in descending order based on total dollars generated
    by each item. And, finally, the list must be written to disk in a simple
    text file.

    Instructions:

    a) you may not use any of the built in summary functions, methods,
    or operations in Alpha Five. We're totaling sales without using
    any of the built-in summarization tools Alpha provides.

    b) you may open the table only once

    c) your output should be written to a disk file named "Puzzle_9_Sorted_List.txt"
    in a folder called "Temp" on your "C" drive.

    d) export your solution script and attach it to your reply, here

    e) attach a copy of the text file your script creates when you submit your
    solution here

    #2
    Re: Programming Puzzle 9 - Dump ta dump

    Comments simply regurgitate what the code already tells you. Hence why I hate comments. For Mr. PickyPicky's sake I have added some comments.
    Attached Files
    Andrew

    Comment


      #3
      Re: Programming Puzzle 9 - Dump ta dump

      All I needed to do was use

      file.from_string() with the appropriate parameters instead of the loop I had writing to the trace window.

      Puzzle_9 - 06-12-2011 -1.txt
      Puzzle_9_Sorted_List.txt
      There can be only one.

      Comment


        #4
        Re: Programming Puzzle 9 - Dump ta dump

        Very nice work, guys. You both built a long string containing the complete output text. Then you used a higher level function to write the string to your disk file.

        Here's my more primitive approach. Key differences are few: (a) script verifies target directory exists or creates it; (b) script gives user the optioin to end early without overwriting an exisitng file; and (c) the file is created one line at a time.

        -- tom

        Comment


          #5
          Re: Programming Puzzle 9 - Dump ta dump

          To Mr. Prof. PickyPicky, towards the end of my script there are comment out lines. These lines are alternative ways I discovered to write my array into a txt format document. If the time is available check out the alternatives and see what you think. (The alternatives were introduced to me by Stan.)

          Puzzle_9.txt
          Puzzle_9_Sorted_List.txt



          -Jeb

          Comment


            #6
            Re: Programming Puzzle 9 - Dump ta dump

            Jeb -

            Code looks and even better it works.

            I didn't validate that your results where correct so cannot attest to the calculations.

            I would suggest that you always dimension your variables prior to using them. Alpha 5 does allow you use a non dimensioned variable, but I find this to be bad habit forming. When you are editing your code you can click the "Code" menu option then choose "Find Un-DIMed Variables" This genie will even help you create the code needed to dimension the variables. I prefer to start all my code with the "OPTION EXPLICIT" command, this will cause alpha5 to stop execution if it finds an un-dimmed variable.

            On line 27 you create the output file and open it using the file.create() function. However you still have a bit of processing to do before you utilize the opened file. I personally prefer to open files right before i need to read or write data and then close them immediately.

            In this case I would move line 27 down to where you are gonna start writing to the file.
            Code:
            creation = file.create(path,FILE_RW_SHARED)
            creation.write_line("Product ID"+space(20)+"Totals")
            Same with line 62
            Code:
            item.close()
            . Since you were done using the table at line 49, I would place my <tbl>.close() call there. No sense leaving a table pointer open if you are not using it.

            None of this is ground breaking or show stopping. In the end sometimes if the code works just go with :)
            Andrew

            Comment


              #7
              Re: Programming Puzzle 9 - Dump ta dump

              Jeb, I think Andy means

              OPTION STRICT

              not OPTION EXPLICIT

              Comment


                #8
                Re: Programming Puzzle 9 - Dump ta dump

                You are correct.
                Andrew

                Comment


                  #9
                  Re: Programming Puzzle 9 - Dump ta dump

                  Awesome. Thanks guys!

                  -Jeb

                  Comment

                  Working...
                  X