I'm a beginner, go easy. simple sign-in script



IBM's Command List programming language & Restructured Extended Executor

I'm a beginner, go easy. simple sign-in script

Postby Kirk Varra » Mon Mar 21, 2011 8:41 am

I am trying to write a simple sign-in script but cant seem to figure out why it wont go to the next command sequence. Here is my script:

-----------------------------------------------------------------------------------
Enter = '@E'
Tab = '@T'
On = 1
Off = 0
GetScrn = 'Copy_PS_to_Str'
PutScrn = 'Copy_Str_to_PS'
TRACE E
'@cls'
/*************************************************************/
/** Load the hllapi program **/
/*************************************************************/
if Rxfuncquery('hllapi') Then
call Rxfuncadd 'HLLAPI','SAAHLAPI','HLLAPISRV'

/*************************************************************/
/** connect to retain.ws to sign in **/
/*************************************************************/
RC=HLLAPI( 'Connect', A )

/*************************************************************/
/** confirm screen and get to signin screen **/
/*************************************************************/
IF 'IBM' = HLLAPI(GetScrn,107,3) THEN
DO
RC=HLLAPI('SENDKEY','Rta')
RC=HLLAPI('wait')
RC=HLLAPI('SENDKEY',ENTER)
RC=HLLAPI('wait')
END
ELSE
NOP
/*************************************************************/
/** Verify signon screen and signin **/
/*************************************************************/
ExitOK = Off <----- It stops at this point. at this screen it just doesnt continue.
DO L = 1 TO 5 UNTIL ExitOK = On
IF 'USER' = HLLAPI(GetScrn,731,3) THEN
ExitOK = On
ELSE
NOP
END
IF ExitOK = On THEN
DO
RC=HLLAPI('SENDKEY','userID/Pswd')
RC=HLLAPI('wait')
RC=HLLAPI('SENDKEY',ENTER)
RC=HLLAPI('wait')
END
ELSE
NOP
-------------------------------------------------------------------------------------------------------
If I string all the command together in one long DO command it works. But i dont want that. I want to verify each screen. Any advice would be much appreciated.
Kirk Varra
 
Posts: 5
Joined: Mon Mar 21, 2011 7:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: I'm a beginner, go easy. simple sign-in script

Postby NicC » Mon Mar 21, 2011 10:28 am

Possbly it is awaiting a response from you? Have you tried running with Trace? If not then insert one just before you set exitok to 0 - I use the trace option '?i' but others use '?r' - up to you.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: I'm a beginner, go easy. simple sign-in script

Postby Kirk Varra » Tue Mar 22, 2011 4:28 am

nope. I tried the trace but i get that ?i is not recognized as in internal or external command. The script should not be waiting for me to do anything. i am wondering if i nest the operations if it would run a little better. while i tried it before i suppose i could try a different way to nest them. anyone else have any ideas? i noticed there was 20+ views but only one response. thank you nic.

Kirk
Kirk Varra
 
Posts: 5
Joined: Mon Mar 21, 2011 7:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: I'm a beginner, go easy. simple sign-in script

Postby BillyBoyo » Tue Mar 22, 2011 5:45 am

Kirk Varra wrote:IF 'USER' = HLLAPI(GetScrn,731,3) THEN


If "3" is the length of what is extracted by GetScrn, then it is not going to be able to be equal to "USER". 731 looks big for a screen, but what do I know.

I don't know if your code is "indented" in your program, but if not I'd suggest you do it to improve readability if it is not, and use the Code button when posting so that your code is easier for us to read.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: I'm a beginner, go easy. simple sign-in script

Postby Kirk Varra » Tue Mar 22, 2011 6:14 am

no, 3 is the HLLAPI command to 'send key'. let me clarify what i am using. i am using HLLAPI rexx. so the command "IF 'USER' = HLLAPI(GetScrn,731,3) THEN" is reading to get the screen and copy it to the presentation space. 731 is the space on the screen to read. 3 is the command to do. so if the word user is the 731st spot on the screen then to send the following commands. but it doesnt. the screen itself is 24x80. so it has 1920 places on it. I am adding my code but with the code button:
Enter = '@E'
Tab = '@T'
On = 1
Off = 0
GetScrn = 'Copy_PS_to_Str'
PutScrn = 'Copy_Str_to_PS'
TRACE E
'@cls'
/*************************************************************/
/** Load the hllapi program                                   **/
/*************************************************************/
if Rxfuncquery('hllapi') Then
   call Rxfuncadd 'HLLAPI','SAAHLAPI','HLLAPISRV'

/*************************************************************/
/** connect to retain.ws to sign in                         **/
/*************************************************************/
 RC=HLLAPI( 'Connect', A )

/*************************************************************/
/** confirm screen and get to signin screen            **/
/*************************************************************/
IF 'IBM' = HLLAPI(GetScrn,107,3) THEN
    DO
      RC=HLLAPI('SENDKEY','Rta')
      RC=HLLAPI('wait')
      RC=HLLAPI('SENDKEY',ENTER)
      RC=HLLAPI('wait')
   END
ELSE
   NOP
/*************************************************************/
/** Verify signon screen and signin                         **/
/*************************************************************/
IF 'USER' = HLLAPI(GetScrn,731,3) THEN
   DO
      RC=HLLAPI('SENDKEY','userID/Pswd')
      RC=HLLAPI('wait')
      RC=HLLAPI('SENDKEY',ENTER)
      RC=HLLAPI('wait')
   END
       ELSE
         NOP


If i string them all together then it works fine; like this:
RC=HLLAPI('SENDKEY','userID/Pswd')
        RC=HLLAPI('wait')
        RC=HLLAPI('SENDKEY',ENTER)
        RC=HLLAPI('wait')
        RC=HLLAPI('SENDKEY','n;1')
        RC=HLLAPI('wait')
        RC=HLLAPI('SENDKEY',Enter)
        RC=HLLAPI('wait')
        RC=HLLAPI('SENDKEY','cs retop')
        RC=HLLAPI('wait')
        RC=HLLAPI('SENDKEY',Enter)


but i want to verify each screen and eventually return errors and do other things if on different screens. I just cant figure out why i cant run more than one IF-THEN-ELSE statement in a row.
Kirk Varra
 
Posts: 5
Joined: Mon Mar 21, 2011 7:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: I'm a beginner, go easy. simple sign-in script

Postby BillyBoyo » Tue Mar 22, 2011 6:50 am

Sorry about the screen. Too late to multiply correctly. Brain stopped working.

You make your code unconditional, it works. You make it conditional, it doesnt' work. Implies to me that your condition is not being met. So, for some reason, not "USER". Trace ?i, as suggested by NicC, should show whether USER appears or not, and what does if it doesn't. Why can't you get trace ?i to work? You have a trace already, change that one to ?i.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: I'm a beginner, go easy. simple sign-in script

Postby Kirk Varra » Tue Mar 22, 2011 7:00 am

you were correct in an earlier post billy:
If "3" is the length of what is extracted by GetScrn, then it is not going to be able to be equal to "USER".

when i ran the trace it only came up with 'use' instead of 'user'. I change the 3 to a 4 and... almost like i knew what i was doing. I understand how that string works now.
thats the last time i wont listen to you.
thank you.

Kirk
Kirk Varra
 
Posts: 5
Joined: Mon Mar 21, 2011 7:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: I'm a beginner, go easy. simple sign-in script

Postby BillyBoyo » Tue Mar 22, 2011 5:23 pm

I'm glad it's OK now.

Something to remember for next time, if a function/macro/whatever is named "Get..." then you shouldn't have to pass it a code to indicate "get". Even if someone tells you it is, or you think it is, have a little step back and check on something like that.

I assume your problem with trace was something like a typo?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post