Alpha Video Training
Results 1 to 12 of 12

Thread: Text file display

  1. #1
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default Text file display

    I have a form which has a Text1 text object on it.
    There is a text file the name of which is contained in a global variable TextFileName.
    When the form is opened the OnInit event opens the text file and put its text contents in the Text1.

    This works fine except that the text file is bigger than the text object will allow and not all the text appears.

    Is there an easy way round this or a way to call up Windows Notepad to open with my text file contents in it?
    Mike Vance

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Text file display

    Assuming notepad is the registered editor for text files with the .txt extension and assuming the root C: directory

    sys_edit("C:"+chr(92)+TextFileName+".TXT")

  3. #3
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    Many thanks Stan. Will try that. Mike

  4. #4
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Text file display

    Mike:
    ""This works fine except that the text file is bigger than the text object will allow and not all the text appears. ""

    You could make the text object as big as you want.

    ""There is a text file the name of which is contained in a global variable TextFileName.
    When the form is opened the OnInit event opens the text file and put its text contents in the Text1. ""

    What you describe is exactly what a memo field does: have you considered using a memo field instead?
    Gabe

  5. #5
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    The memo field seems only for use in a table and I just want a simple text box field on the form which seems to have a maximum of 256 characters.

    Stan's sys_edit works very well except that one of the files I need to use must have an extension of .SIA not .TXT and I need to associate notepad with that file type in my xbasic code if it is not already an associated file type.

    I appreciate your and Stan's help. Mike

  6. #6
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Text file display

    Instead of a text object, how about an RTF?
    Gabe

  7. #7
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    Gabe - I tried RTF but could get it to work with plain text
    Here is the code I used:-
    Text1.text=""
    TextFilename="a:w275955.sia"
    file_pointer=file.open(TextFilename,FILE_RO_EXCLUSIVE)
    while .not. file_pointer.eof()
    TempString=file_pointer.read_line()
    Text1.text=Text1.text+TempString
    end while
    file_pointer.flush()
    file_pointer.close()
    'the next line was Stan's code - I changed this and it work very well except my clients may not have associated the .SIA file type
    'sys_edit("C:"+chr(92)+TextFileName+".TXT")
    sys_edit(TextFilename)

    Mike

  8. #8
    "Certified" Alphaholic Melvin Davidson's Avatar
    Real Name
    Melvin Davidson
    Join Date
    Apr 2000
    Location
    Parker, CO
    Posts
    1,197

    Default RE: Text file display

    Mike,

    Yes, there is a limitation of 255 for character type fields.
    (Text Box). However, depending on why you need this "text box", you could possibly break it up into several fields aligned next or under each other.

    ie:
    field1(length 100) field1(length 100) field1(length 100) field1(length 100)

    or

    field1(length 100)
    field1(length 100)
    field1(length 100)
    field1(length 100)

    Are you going to store that data anywhere? Perhaps if you clarify the usage we can better advise you.

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Text file display

    This should work with any file that notepad can open

    sys_shell("c:\windows\notepad.exe c:"+chr(92)+TextFileName,1)

  10. #10
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    The file is used to send quarterly payroll information to our island's Social Security Department and must be in a prescribed format. the number of text lines depends on how many employees are on the payroll. It could be two or 100 so the file size varies considerably and splitting it into blocks of 100 would not be easy to code/display. Mike

  11. #11
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    Great Stan. That looks like what I want. Will try again tomorrow. It's 17:00 in Guernsey and my wife has told me to take her shopping. Thanks for your help. Mike

  12. #12
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default RE: Text file display

    Thank you very much Stan. Your Sys_shell code did exactly what I was seeking to achieve. Much obliged. Mike

Similar Threads

  1. importing text file
    By Duane Pederson in forum Alpha Five Version 6
    Replies: 4
    Last Post: 09-18-2004, 11:57 AM
  2. Export to a text file
    By Garry Flanigan in forum Alpha Five Version 5
    Replies: 2
    Last Post: 07-13-2004, 04:19 AM
  3. Saving Report as text file or excel file
    By Michael Hadjimichael in forum Alpha Five Version 5
    Replies: 1
    Last Post: 06-02-2004, 05:46 AM
  4. Import Text file
    By Arthur Armour in forum Alpha Five Version 5
    Replies: 8
    Last Post: 03-28-2003, 07:28 AM
  5. File display data but access not available
    By Robert Adler in forum Alpha Five Version 4
    Replies: 1
    Last Post: 04-20-2000, 12:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •