Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cut and paste entire page in txt file

Status
Not open for further replies.

2009luca

Programmer
Jul 27, 2013
222
IT
How to copy entire page from sess0 and paste directlly in c:\mytxt.txt?

note:
during the process a press PF8 to go to the next page and i need to append to just part of page alreday copied into to txt file.
 
something like this should get you started
Code:
Sub Main

        Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
	Set Sys = CreateObject("EXTRA.System")
        ' Assumes an open sessions
	Set Sess = Sys.ActiveSession
	Set MyScreen = Sess.Screen
 
        Set MyArea = MyScreen.Area(1,1,24,80)
        
        MyFile = "C:\mytxt.txt"

        Open MyFile for Append as #1

            Print #1, MyArea
 
        Close #1  
    
End Sub

look in the HELP files for "Open statement:description" for further information
 
tK!!!!!
But the code write into txt all in one line!!!!!!!!!!!!

I need to paste into the txt exactlly wath i see in session...similar:

AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC
AAAAAAA BBBBBBBB CCCCCCC


And not in one line, similar:
AAAAAAA BBBBBBBB CCCCCCC AAAAAAA BBBBBBBB CCCCCCC

tkx!

 
be careful of what you ask for :)
How to copy entire page from sess0 and paste directlly in c:\mytxt.txt?

something like this, maybe?
Code:
Sub Main
    Dim System As Object, Sess As Object, MyScreen As Object
    Set System = CreateObject("EXTRA.System")
    Set Sess = System.ActiveSession
    Set MyScreen = Sess.Screen
    
    MyFile = "C:\mytxt.txt"
      
    Open MyFile for Append as #1

        For i = 1 to 24
            
            MyArea = MyScreen.GetString (i,1,80)
            Print #1, MyArea
                
        Next i
        
    Close #1
    
End Sub
 
hi REMY988, tks!
The code now work great!

Sorry for my bad english (I'm Italian)
 
hi 2009luca,

no need to apologize. there are folks that would actually use the first code instead of the second. glad i was able to help you.

rem
 
But in case to use the first how to read line by line the txt?
 
it can get complicated, depending on how the screens are structured.

when you scrape one entire screen, in this case (1,1,24,80), that means there are 1920 characters in total (80 characters per row * 24 = 1920).

then you can loop through the 1920 characters using the MID function

either way is just as quick. it's a matter of preference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top