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

Viewing Text Files

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

  • Viewing Text Files

    I am relatively new to Alpha5. I am looking for a simple way to view a text file within my application. There must be a simple answer, but I've looked through the help file and through the forums and cannot find a simple way to do so. Currently I open the text file by having Alpha5 hand the chore off to the OS's text editor, but I would prefer a simple way to have Alpha5 display it directly on a form. Any suggestions? Thanks in advance for any help.

  • #2
    Re: Viewing Text Files

    I can think of a few ways.

    How big are the text files (word count might be a useful measure here, approx)? Big difference between something with, say, 50 words, and one that might have 50,000 words.

    Do you want the text embedded in a form, or maybe viewed in an XDialog (and, XDialogs can be embedded in a form as well)?

    Need just a little more info /explanation to decide what to suggest as a solution.
    -Steve
    sigpic

    Comment


    • #3
      Re: Viewing Text Files

      Thanks for your reply. They will greatly vary in size, some being rather large - probably average around 250kb. For the project at hand it would be used for viewing invoices which have been spooled to text files and can contain hundreds of pages of invoices. Other languages I've used usually have a simple text editor and I thought I must have missed the one in Alpha5. I don't really care if it is embedded w/in a form - what I should have said is that I would just like something within Alpha5 instead of invoking an outside program to view it.

      Comment


      • #4
        Re: Viewing Text Files

        Well, here's one way to do it. See attached picture as a guide.

        The form has two variables:

        Code:
        txt
        file
        There are two controls here. The largest one is a SuperControl for HTML Content. When you draw the Supercontrol, it asks what you want to display. I chose variable->txt. I also gave the Supercontrol object a name of txtDisplay; I'll be referencing it in the Xbasic below.

        The smaller control on the left is a file select field. You can just drag the variable->file onto the form, then adjust the control's properties to be a File Select type of control.

        I have this code on the OnChange event:

        Code:
        dim shared txt as c
        ' Open the file that's just been selected
        f = file.open(this.text, file_rw_shared)
        
        ' Get the length of the text in the file
        l = f.chars_get()
        
        ' Read all text into the "txt" variable:
        txt = f.read(l)
        
        ' Convert carriage returns to HTML breaks for proper display
        txt = stritran(txt,crlf(), "<br>")
        
        ' Close the file
        f.close()
        
        ' Refresh the HTML object to display the variable's contents
        txtDisplay.refresh()
        I don't think I missed anything, but ask away if you have questions.
        -Steve
        sigpic

        Comment


        • #5
          Re: Viewing Text Files

          Steve,

          Thanks so much for your help and clearly detailed explanation. I created the form as you said, and it does work - but unfortunately not quite as required for this project's purpose. Mind you, I do not really have knowledge of HTML, but did as you said with the modification below:

          ' Convert carriage returns to HTML breaks for proper display
          v_txt = "<HTML><BODY><FONT FACE='Courier New' SIZE=1><P>"+stritran(v_txt,crlf(), "<br>")+"</P></FONT></BODY></HTML>"

          This assigns a uniformly spaced font (necessary for proper rendering), but the text still doesn't display properly. This specific form is intended to display a text-based invoice and as such it requires that all characters (including spaces - even leading spaces) all have the same horizontal spacing so that columns will line up properly.

          I really like what I've seen of Alpha5 - it has many powerful functions not found in other languages I've used - and I find it hard to believe that it does not have a built-in text editor function. It clearly has a text editor used for coding and such and most other languages I've encountered seem to make a form of that code editor available as a function for simple editing/viewing of text files. I just figured that I somehow missed it in my search. Such a function is not available in Alpha5, correct?

          Another way I could do it is to import the text file into a table - where each line would be stored to a single field with one record per line and then create a browse form for that table. I might just do it that way unless you would recommend otherwise.

          Thanks again for all your help.

          Comment


          • #6
            Re: Viewing Text Files

            Originally posted by Smokey_ View Post
            Another way I could do it is to import the text file into a table - where each line would be stored to a single field with one record per line and then create a browse form for that table.
            Personally, rather than do it that way, I would probably have a memo field in my table and import the text directly into the memo field. Not sure it would retain the formatting exactly, but you could try it out. It should retain leading spaces, at least.

            Something like:
            Code:
            tbl = table.current()
            tbl.enter_begin()
            tbl.YourMemoField = GET_FROM_FILE("your file name.txt")
            tbl.enter_end(.T.)
            Peter
            AlphaBase Solutions, LLC

            [email protected]
            https://www.alphabasesolutions.com


            Comment


            • #7
              Re: Viewing Text Files

              You could try importing it into a table with a memo field, and see how that looks.

              Try this first though: You don't need to specify the html and body tags. This might be throwing things off. Should be:

              Code:
              v_txt = "<FONT FACE='Courier New' SIZE=1><P>"+stritran(v_txt,crlf(), "<br>")+"</P></FONT>"
              You might have better luck putting the text into an XDialog. That way you're outta the HTML pool. Attached is a picture of XDialog displaying columns of text in one of my apps.

              Busy today, maybe some other ideas tonight including an XDialog example if you want.
              Last edited by Steve Workings; 09-16-2009, 01:01 PM.
              -Steve
              sigpic

              Comment


              • #8
                Re: Viewing Text Files

                I just tried Peter's method. I like the results a lot. It's probably simplest if it meets your needs.

                Minor suggestions for the script, just to give you ideas:

                Code:
                filename = ui_get_file("Get File", "*.txt")
                tbl = table.open("table_to_display_text")
                tbl.enter_begin()
                tbl.text = GET_FROM_FILE(filename)
                tbl.enter_end(.T.)
                tbl.close()
                -Steve
                sigpic

                Comment


                • #9
                  Re: Viewing Text Files

                  I tried both approaches (above) on one form. For whatever reason the HTML will still not line up properly. The memo field approach did work very well and is an even simpler approach than the one I was considering with multiple records. The attached jpg shows both approaches as rendered on the same form for the same file. I will use the memo field approach.

                  Many thanks to both of you for all your help with this.

                  Comment

                  Working...
                  X