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

REXX LOOP Slowness

Status
Not open for further replies.

hardybacon

Technical User
Nov 21, 2013
79
0
0
US

I'm sure I have something wrong. It works but it is really slow. I could key it in faster.

I would guess that the way the loop is setup is wrong. Any thoughts? - Thank you, Bryan


REXX SCRIPT:
CALL ZocSend "****^M"
CALL ZocDelay .5
CALL ZocSend "LD 49^M"

CALL ZocWait "REQ "
CALL ZocDelay .5
CALL ZocSend "chg^M"
CALL ZocWait "TYPE"
CALL ZocDelay .5
CALL ZocSend "idc^M"
CALL ZocWait "CUST"
CALL ZocDelay .5
CALL ZocSend "0^M"
CALL ZocWait "DCNO"
CALL ZocDelay .5
CALL ZocSend "1^M"

file = "C:\IDC\ld49.txt"
LOOP:
data=LINEIN(file)
Parse Var data v1 v2
IF v1 = "" THEN CALL finish

CALL ZocWait "IDGT"
CALL ZocDelay .5
CALL ZocSend v1
CALL ZocSend "^M"
CALL ZocDelay .5
CALL ZocSend v2
CALL ZocSend "^M"
CALL ZocDelay .5
Call LOOP

finish:
Call ZocSend "^M"
CALL ZocSend "****^M"
Exit


OUTPUT Of REXX SCRIPT:

>LD 49
DGT000
MEM AVAIL: (U/P): 44807023 USED U P: 5663954 1159100 TOT: 51630077
DISK SPACE NEEDED: 1665 KBYTES
REQ chg
TYPE idc
CUST 0
DCNO 1
IDGT 1234567

1234567 12345
IDGT 8912345

8912345 89123
IDGT 6789123

6789123 67891
IDGT 4567891

4567891 45678
IDGT 2345678

2345678 23456
IDGT 9123456

9123456 91234
IDGT
****

ld49.txt file:
1234567 12345
8912345 89123
6789123 67891
4567891 45678
2345678 23456
9123456 91234
 

Okay, I removed the CALL ZocDelay .5 from almost all of it and now it is supper fast. I'll just have to figure out how to slow it down a little. - Thx.


CALL ZocSend "****^M"
CALL ZocDelay .5
CALL ZocSend "LD 49^M"

CALL ZocWait "REQ "
CALL ZocSend "chg^M"
CALL ZocWait "TYPE"
CALL ZocSend "idc^M"
CALL ZocWait "CUST"
CALL ZocSend "0^M"
CALL ZocWait "DCNO"
CALL ZocSend "1^M"

file = "C:\IDC\ld49.txt"
LOOP:
data=LINEIN(file)
Parse Var data v1 v2
IF v1 = "" THEN CALL finish

CALL ZocWait "IDGT"
CALL ZocSend v1
CALL ZocSend "^M"
CALL ZocDelay .5
CALL ZocSend v2
CALL ZocSend "^M"
Call LOOP

finish:
Call ZocSend "^M"
CALL ZocSend "****^M"
Exit
 
Hi hardybacon,
CALL is for calling routines. If you want jump to label use SIGNAL.

But IMHO, how you try to read a file with jumping to the labels is ugly or gently said very obsolete.

Look at this example. It demonstrates how to read a text file line-by-line at 2 ways:
[ol 1]
[li]using jumping to the labels as you do[/li]
[li]using only one while loop[/li]
[/ol]
IMHO, the second way is more better.

hardybacon.rexx
Code:
file [COLOR=#a52a2a][b]=[/b][/color] [COLOR=#ff00ff]"ld49.txt"[/color]

[COLOR=#0000ff]-- Reading file: Example 1  [/color]
[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Reading file: Example 1'[/color] 
[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Begin'[/color]
[COLOR=#008b8b]LOOP[/color][COLOR=#a52a2a][b]:[/b][/color]
  data[COLOR=#a52a2a][b]=[/b][/color][COLOR=#008b8b]LINEIN([/color]file[COLOR=#008b8b])[/color]
  [COLOR=#a52a2a][b]Parse Var[/b][/color] data v1 v2
  [COLOR=#0000ff]-- if empty line jump to label FINISH[/color]
  [COLOR=#a52a2a][b]if[/b][/color] v1 [COLOR=#a52a2a][b]=[/b][/color] [COLOR=#ff00ff]""[/color] [COLOR=#a52a2a][b]then[/b][/color] [COLOR=#a52a2a][b]signal [/b][/color][COLOR=#008b8b]FINISH[/color]
  [COLOR=#a52a2a][b]say[/b][/color] data
  [COLOR=#a52a2a][b]say[/b][/color] v1 [COLOR=#ff00ff]', '[/color] v2
  [COLOR=#0000ff]-- jump to label LOOP[/color]
  [COLOR=#a52a2a][b]signal [/b][/color][COLOR=#008b8b]LOOP[/color]
[COLOR=#008b8b]FINISH[/color][COLOR=#a52a2a][b]:[/b][/color] 
  [COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Done.'[/color]

[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'-----------------------'[/color]
[COLOR=#a52a2a][b]say[/b][/color]
[COLOR=#0000ff]-- close file[/color]
[COLOR=#a52a2a][b]call [/b][/color][COLOR=#008b8b]lineout[/color] file

[COLOR=#0000ff]-- Reading file: Example 2[/color]
[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Reading file: Example 2'[/color]
[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Begin'[/color]
[COLOR=#a52a2a][b]do [/b][/color][COLOR=#a52a2a][b]while[/b][/color][COLOR=#a52a2a][b] [/b][/color][COLOR=#008b8b]lines([/color]file[COLOR=#008b8b])[/color] [COLOR=#a52a2a][b]\=[/b][/color] 0
  data[COLOR=#a52a2a][b]=[/b][/color][COLOR=#008b8b]LINEIN([/color]file[COLOR=#008b8b])[/color]
  [COLOR=#a52a2a][b]Parse Var[/b][/color] data v1 v2
  [COLOR=#a52a2a][b]say[/b][/color] data
  [COLOR=#a52a2a][b]say[/b][/color] v1 [COLOR=#ff00ff]', '[/color] v2
[COLOR=#a52a2a][b]end[/b][/color]
[COLOR=#a52a2a][b]say[/b][/color] [COLOR=#ff00ff]'Done.'[/color]

[COLOR=#a52a2a][b]exit[/b][/color]

Output:
Code:
$ rexx hardybacon.rexx
Reading file: Example 1
Begin
1234567 12345
1234567 ,  12345
8912345 89123
8912345 ,  89123
6789123 67891
6789123 ,  67891
4567891 45678
4567891 ,  45678
2345678 23456
2345678 ,  23456
9123456 91234 
9123456 ,  91234 
Done.
-----------------------

Reading file: Example 2
Begin
1234567 12345
1234567 ,  12345
8912345 89123
8912345 ,  89123
6789123 67891
6789123 ,  67891
4567891 45678
4567891 ,  45678
2345678 23456
2345678 ,  23456
9123456 91234 
9123456 ,  91234 
Done.

 
OK, CALL works too, but for me it's irritating, because I'm using it only to routines.
On the other way SIGNAL was thought for using to signalling when error occurs.
I don't know why they didn't include normal GOTO statement too - maybe because REXX should look as modern language without GOTO.

 
I'll just have to figure out how to slow it down a little.

I have here ooRexx installed and it has the SYSSLEEP() function.
You can call it as a procedure, e.g.
[pre] call syssleep 10[/pre]
or as a function
[pre] syssleep(10)[/pre]
Regina REXX should have [pre] SLEEP()[/pre] function, which is similar to use.

I don't know which REXX is embedded with your application - try and you will see.

 
Thank you mikrom. I will try to make some changes to it. The file is used to load Direct Dial numbers to extension conversions in a Legacy Nortel PBX.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top