Trouble with IBM 5250 VB macro



Discuss about all tools related to Mainframes but usable in a PC/Computer like Mainframe Simulators, Emulators, Abend Assist etc...

Trouble with IBM 5250 VB macro

Postby JoseDIA » Wed Oct 09, 2013 4:24 pm

Hello, I'm facing a problem with Dim statement into a macro for IBM 5250 (Client Access). Here is my simple code:

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_

sub subSub1_()
   Dim value As String

   autECLSession.autECLOIA.WaitForAppAvailable
   autECLSession.autECLOIA.WaitForInputReady
   value = autECLSession.autECLPS.GetText(1, 5, 60)
   MsgBox(value)     
end sub


When I run this macro on emulator I always get an error at line "Dim value as String": End of statement expected. If I define value variable as "Dim value" without "As String" script runs fine, but I need to define the type of each variable. Any ideas? Thanks.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

 

Re: Trouble with IBM 5250 VB macro

Postby NicC » Wed Oct 09, 2013 6:11 pm

Are you sure 'value' is an allowed variable name - I would have thought that it was a reserved word. certainly it is not a good name for a variable.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Trouble with IBM 5250 VB macro

Postby JoseDIA » Wed Oct 09, 2013 7:31 pm

Thanks for your quick response. Well, you are right but I have translated this word to english because this is an english forum. The original script is like below, and "valor" is not a reserved word:

Dim valor As String

I tried to convert "As" to LowerCase and get the same error:
Dim valor as String


I think this is a weird error because refering to the API document http://publib.boulder.ibm.com/infocente ... cess08.htm there are many variables declared like mine.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

Postby NicC » Wed Oct 09, 2013 8:49 pm

Val however is a VB function (or, at least, a VBA function which is the only reference I have to hand) so I wonder if VB is getting confused?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Trouble with IBM 5250 VB macro

Postby JoseDIA » Wed Oct 09, 2013 9:06 pm

Val is a function but Valor isn't. I wonder too coz I copied and pasted -Dim x As Number- line from http://publib.boulder.ibm.com/infocente ... ingdim.htm to my .mac file and I run it on Client Access emulator and it gives me the same error :lol: Perhaps I'm declaring variables in a wrong section. I dont know.

Well in order to avoid creating variables I have removed OPTION EXPLICIT line, but now I have not accuracy of the type of variable.
Thank you for your time.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

Postby cobolcmd » Fri Oct 18, 2013 8:43 am

hi, I think you can define the variable as below:
dim valor
no need to indicate the type, just use it.
if you give a string value to it, then it would be a String type; if you give a integer value to it, it would be a integer type. you can have a try.
cobolcmd
 
Posts: 1
Joined: Fri Oct 18, 2013 8:36 am
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

Postby JoseDIA » Fri Oct 18, 2013 12:17 pm

Hello. Yes, it works like you say, but it's the same as no declaring variables.

Thanks for your response.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

Postby NicC » Fri Oct 18, 2013 1:49 pm

Is it a Visual Basic macro? The page you linked to was for Basic, not Visual Basic. I could not see OPTION EXPLICIT in those pages so I cannot say if it is a part of Basic or not. Also, not specifying a type in Basic is not the same as with Visual Basic. In Basic it assumes the type of the first data assigned to it and it keeps that type from that point onwards. But, in Visual Basic you do not need to declare the type when using OPTION EXPLICIT - just the name.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Trouble with IBM 5250 VB macro

Postby JoseDIA » Fri Oct 18, 2013 2:13 pm

The first page I linked is for VB, not Basic: http://publib.boulder.ibm.com/infocente ... cess08.htm and I can see there thousands of examples of variable declarations where type is defined. If I copy & paste kinda of that code to my .mac file and I run it into Client Access Emulator it crashes always at Dim statement. At first post of this thread there is a code example that everybody can try it for yourself.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trouble with IBM 5250 VB macro

Postby JoseDIA » Fri Oct 18, 2013 4:42 pm

I have found this VB code for Client Access (AS400) that export any AS400 screen to an Excel sheet: http://forums.iprodeveloper.com/forums/aft/148659
XavierM declares variables without specifying its type. Well, I am very confused with this, but I think NicC is right.
From now I'll try to declare variables with no type.

Thank you all.
JoseDIA
 
Posts: 6
Joined: Wed Oct 09, 2013 4:06 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Simulators & Emulators

 


  • Related topics
    Replies
    Views
    Last post