INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

enter number and print to file?

enter number and print to file?

(OP)
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

RE: enter number and print to file?

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: enter number and print to file?

(OP)
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

RE: enter number and print to file?

(OP)
the startac and stopac are to entered inputebox by user

RE: enter number and print to file?

Quote:

...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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: enter number and print to file?

(OP)
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


RE: enter number and print to file?

Quote:

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: enter number and print to file?

(OP)
yes its row 6 columon 80 it moves the cursor to that location for number input
i will try to upload a pic

RE: enter number and print to file?

(OP)
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

RE: enter number and print to file?

Do you mean, intead of...

CODE

For i = 6 To 18 
...you want i = 5,7,8,10,15 etc

???

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: enter number and print to file?

(OP)
yes that would be great.

RE: enter number and print to file?

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: enter number and print to file?

(OP)
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

RE: enter number and print to file?

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close