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!

Basic Illegal Statement Error

Status
Not open for further replies.

CGill

Programmer
Jan 2, 2003
51
GB
I have written a piece of code in Basic and I have come to the end of the code and closed it off with 'End Sub' the problem i get is when i compile it, i get an illegal statement error.

Anyone help Im new with basic.
 
some use "return".

Ed Fair
Give the wrong symptoms, get the wrong solutions.
 
1) is it work un-compiled?
2) consider posting your code (or piece that supposedly cause the error)
 
Option Explicit

Function DELAY%
If Hour(Now())<17 Then DELAY=500 Else DELAY=0
End Function

'---------------------------------------------------------------------------------------------------------

Sub Main

Dim System As Object, Session As Object, Screen As Object, OIA As Object
Dim IN%, OUT%, infile$, outfile$
Dim ref$, mpan$, acno$,tenant%
Dim ioption%, value$, temp%, success%, num_record&, num_success&, num_error%
Dim result$, detail$

'---------------------------------------------------------------------------------------------------------

'# Find an active extra! screen object

Set System=CreateObject("EXTRA.System")
If Not System Is Nothing Then Set Session=System.ActiveSession
If Not Session Is Nothing Then Set Screen=Session.Screen
If Screen Is Nothing Then
MsgBox "Please open Attachmate EXTRA! mainframe client first"
Goto Finish
End If
Set OIA=Screen.OIA

'---------------------------------------------------------------------------------------------------------

'# Prompt user for file name and check answer

infile=InputBox("Enter the name of a text file to use as input"+Chr(10)+Chr(13)+ _
"Please use the full path, i.e. C:\Data\inputfile.txt")
Do
If Len(infile)=0 Then
MsgBox "No path entered, Event cancelled!"
Goto Finish
End If
If Len(Dir(infile))>0 Then Exit Do
infile=InputBox("There was a problem with "+infile+Chr(10)+Chr(13)+ _
"Please try something different this time."+Chr(10)+Chr(13)+ _
Chr(10)+Chr(13)+ _
"Enter the name of a text fileto use as input"+Chr(10)+Chr(13)+ _
"Please use the full path, i.e. C:\Data\inputfile.txt")
Loop
outfile=infile+"_OUTPUT.log"

'---------------------------------------------------------------------------------------------------------
'# Open files for use

IN=FreeFile
Open infile For Input As #IN

Do Until EOF(IN)

'---------------------------------------------------------------------------------------------------------

'# clear reused variables

mpan=""
acno=""
tenant=0
result=""
detail=""
success=0

Input #IN, ref
num_record=num_record+1

'---------------------------------------------------------------------------------------------------------

'# Give up if dodgy data is encountered

If Not IsNumeric(ref) Then
result="bad ref"
detail="not numeric"
End If

'---------------------------------------------------------------------------------------------------------

'# Decide whether ref is account number or MPAN

If CInt(left(ref,2))<30 Then mpan=ref Else acno=ref

'---------------------------------------------------------------------------------------------------------

'# Enter account

Screen.SendKeys "<CLEAR>"
Do:Screen.WaitHostQuiet DELAY:DoEvents:Loop While OIA.XStatus=5
Screen.PutString acno,9,23
Screen.PutString "floh",7,23
Screen.SendKeys "<ENTER>"
Do:Screen.WaitHostQuiet DELAY:DoEvents:Loop While OIA.XStatus=5

If Screen.GetString(9,28,5) = "D0190" then screen.putstring "01",22,18 else
If Screen.GetString(9,27,5) = "D0190" then screen.putstring "02",22,18 else
If Screen.GetString(9,26,5) = "D0190" then screen.putstring "03",22,18 else
If Screen.GetString(9,25,5) = "D0190" then screen.putstring "04",22,18 else
If Screen.GetString(9,24,5) = "D0190" then screen.putstring "05",22,18 else
If Screen.GetString(9,23,5) = "D0190" then screen.putstring "06",22,18 else
If Screen.GetString(9,22,5) = "D0190" then screen.putstring "07",22,18 else
If Screen.GetString(9,21,5) = "D0190" then screen.putstring "08",22,18

Screen.sendkeys "<ENTER>"

'---------------------------------------------------------------------------------------------------------

End Sub
 
Which particular Basic are you using?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
I'm not familiar with E Basic but I'll give it a go...

I've looked at the code and came across this
Code:
    If Screen Is Nothing Then
        MsgBox "Please open Attachmate EXTRA! mainframe client first"
        [red]Goto Finish[/red]
    End If

where's the line labled "Finish"? Does the HELP files say anything about GOTOs within a Sub?

Let us know if this helps.
--MiggyD
 
You were correct in that the GOTO Finish should not have been there but it has made no difference to the intial problem.

Thanks for helping any other ideas
 
As was mentioned above, if you run the program (uncompiled) does it work?

Also, have you checked the syntax of the following:

Code:
    Set System=CreateObject("EXTRA.System")
    If [red][u]Not System[/u] Is Nothing[/red] Then Set Session=System.ActiveSession
    If Not Session Is Nothing Then Set Screen=Session.Screen
    If [b][red]Screen Is Nothing[/red][/b] Then

I don't understand how your EBasic is supposed to work with that.

Let us know if any of this helps.
--MiggyD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top