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.


Returning Queue values from function

Returning Queue values from function

Hello everybody
I have this function/procedure which saves results in a Queue.
What I want is to return these values normally to be used in the calling routine.

Now I am defining the Queue in the function as Global, so I can read it and copy its contents to a queue in the calling procedure.

But I am looking for a better way to make my function independent without using the global variables.

Any suggestions are extremely appreciated


RE: Returning Queue values from function


you can you use a reference parameter --> myFunction(*QUEUE)
So you dont need global variable.


RE: Returning Queue values from function

Thank you Cagiv but may be my idea was not clear
I will give a simple example:


! calling function from screen button
      MyVar = get_list(1,4)
! Function will loop from 1 to 4 and saves results in Queue as an example


Function get_list(a,b)
 Loop i# = a to b
     ! Add to Queue
 Return ! the Queue
 ! I want the values stored in the Queue to be stored in MyVar that can be used in the main routine.

Thank you


RE: Returning Queue values from function

Thats's what i mean:

DATA Declaration in Main
l:MyQueue QUEUE
  test      STRING(20)

Call in Main:

Prototype Procedure get_List:

PROCEDURE get_list(a,b,pMyQueue)
r:MyQueue QUEUE
  test      STRING
!Fill local Queue with Data
 Loop i# = a to b
   r:MyQueue:test = 'Test '& i#
!Transfer Data to referenced Queue
 LOOP i# = 1 TO RECORDS(r:MyQueue)
  pMyQueue = r:MyQueue

RE: Returning Queue values from function

Sry, i wrote:

Prototype Procedure get_List:

i did mean:
Prototype Procedure get_List:


RE: Returning Queue values from function

Thanks alot cagiv,
It worked as I wanted.
THanks again

RE: Returning Queue values from function

Thanks alot cagiv,
It worked as I wanted.
THanks again

RE: Returning Queue values from function

Dear newtoclarion,
As we are working in the same place.. make sure to write comments from your account :)


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!


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