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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enter number and print to file? 1

Status
Not open for further replies.

planetech

Technical User
Dec 29, 2017
9
US
Hello all,

Can someone help with this I am trying to prompt user to enter to number example 901- 910 and then print screen area to file enter next number (2. 46) and print again.
Here is the code so far.
Thanks for any help.
-------------------------------------

'Declare our global variables for Aircraft

Global g_StartAC as String
Global g_StopAC as String
Global g_bSuccess as Integer

'Declare the Dialog Box function
Declare Function AircraftDialog()

' Define constants
Const TRUE = -1
Const FALSE = 0

Function findAC()
Dim StartAC As Double
Dim StopAC As Double

StartAC = InputBox("Enter Start A/C", "Enter a Number")
StopAC = InputBox("Enter Stop A/C", "Enter a Number")

End Function

Sub main

' Get the necessary Session Object

Dim System As Object, Sess As Object, MyScreen As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Set MyScreen = Sess.Screen

Do
Sess.Screen.MoveTo 2, 46
Sess.Screen.SendKeys g_StartAC + "<Enter>"

MyFile = "C:\print.txt"
Open MyFile For Append As #1
For i = 6 To 18
MyArea = MyScreen.GetString(i, 1, 80)
Print #1, MyArea

Close #1

Do: Loop Until StartAC = StopAC

MsgBox "Your done"

End sub
 
Hi,

Welcome to Tek-Tips

You never assign either input value to g_StartAC or g_StopAC, your global variables.

What are g_StartAC and g_StopAC used for?

StartAC and StopAC are not global and therefore will never be "seen" in Main.

You never increment so that StartAC = StopAC is ever true.

Now some questions regarding your process.

Why are you opening and closing the file multiple times in your Do...Loop?

Don't you want to:
1. Open the input file
2. start your Do loop at row = StartAC
3. write to the file
4. increment row
5. Loop until row = StopAC
6. Close the input file



Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thanks for looking at this
yes I want to open the file and write increment rows (6,80) then next ac is entered at (2.46)+enter then write to file and repeat til stopac
 
the startac and stopac are to entered inputebox by user
 
...and write increment rows (6,80) then next ac is entered at (2.46)+enter then write to file and repeat til stopac

???
(6,80) is row 6 column 80.

What does then next ac is entered at (2.46)+enter mean?

None of this makes sense.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
sorry for the confusion.
yes i= myarea which is row 6 to columon 80 most of the screen then I need to enter next number at postion row 2.46
the print to file portion works if i do it separate. but I believe it will be a loop inside a loop if that makes sense


 
yes i= myarea which is row 6 to columon 80

I don’t understand what this means? 6,80 is one point on your screen.

Please upload a screen shot of your terminal emulator.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
yes its row 6 columon 80 it moves the cursor to that location for number input
i will try to upload a pic
 
ok so this is working for me but I need to create one for an array of number like 5,7,8,10,15 etc


' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Global g_ac as String

dim ac

Sub Main()

' Set the default wait timeout value
g_HostSettleTime = 800 ' milliseconds

Dim System As Object, Sess As Object, MyScreen As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Set MyScreen = Sess.Screen

for ac = 901 To 913

Sess.Screen.Sendkeys("<Clear>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys("/for sciuvc <Enter>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys ac + "<Enter>"
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.WaitHostQuiet(g_HostSettleTime)

MyFile = "T:\Sceptre Session Files\IUVscrape.txt"

Open MyFile For Append As #1

For i = 6 To 18

MyArea = MyScreen.GetString(i, 1, 80)
Print #1, MyArea

Next i
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Close #1
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Next ac
End Sub
 
Do you mean, intead of...
Code:
For i = 6 To 18
...you want i = 5,7,8,10,15 etc

???

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Code:
Dim a(4)

a(0) = 5
a(1) = 7
a(2) = 8
a(3) = 10
a(4) = 15

For i = 0 to UBound(a)
   MyArea = MyScreen.GetString(a(i), 1, 80)
   Print #1, MyArea
Next i

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
sorry i messed that one up it is a loop inside a loop. I am trying to do like this.

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Global g_ac as string



Sub Main()

' Set the default wait timeout value
g_HostSettleTime = 900 ' milliseconds


dim ac As Variant
ac = Array(2018,2019,2021,2025)

Dim System As Object, Sess As Object, MyScreen As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Set MyScreen = Sess.Screen


For r = LBound(ac) To UBound(ac)

Sess.Screen.Sendkeys("<Clear>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys("/for sciuvc <Enter>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys r + "<Enter>"
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.WaitHostQuiet(g_HostSettleTime)

MyFile = "T:\Sceptre Session Files\IUVscrape.txt"

Open MyFile For Append As #1

For i = 6 To 18
MyArea = MyScreen.GetString(i, 1, 80)
Print #1, MyArea
Next i
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Close #1
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Next r

MsgBox "Your Done"
End Sub
 
This worked thank so much for your help..

Sub Main()

' Set the default wait timeout value
g_HostSettleTime = 900 ' milliseconds



Dim System As Object, Sess As Object, MyScreen As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Set MyScreen = Sess.Screen

Dim ac(2)

ac(0) = 2018
ac(1) = 2025
ac(2) = 2029


for a = 0 To UBound(ac)

Sess.Screen.Sendkeys("<Clear>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys("/for sciuvc <Enter>")
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.Sendkeys ac(a) + "<Enter>"
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Sess.Screen.WaitHostQuiet(g_HostSettleTime)

MyFile = "T:\Sceptre Session Files\IUVscrape.txt"

Open MyFile For Append As #1

For i = 6 To 18
MyArea = MyScreen.GetString(i, 1, 80)
Print #1, MyArea
Next i
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Close #1
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
Next a

MsgBox "Your Done"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top