TTY Name

ezequiel

Member
I feel like a dummie. Can anybody tell me how can I get the name of the TTY where USERID is connected?

Thnks
 
The first problem is mapping USERID to a particular connection (there can be more than 1 connection with the same id). i.e.:

Code:
for each _connect no-lock:
  display _connect-id _connect-usr _connect-name _connect-device.
end.

If your system has a large -n you really, really want to use _connect-id as your key. VSTs do not have indexes per se, they are reflections of in memory data structures (arrays and linked lists) and for almost all of them the only efficient access is via the "id' field. The 4GL will otherwise end up building a result list and sorting it -- and that can get very slow.

Presuming that you got a usr# from the .lg file, PROMON or an error message:

Code:
find _connect no-lock where _connect-id = usrNum + 1.
display _connect-device.[/code]

To understand why you need the "+ 1":

Code:
find _myconnection no-lock.
find _connect no-lock where _connect-usr = _myconn-userid.
display _connect-usr _connect-id _myconn-userid.
find _userio no-lock where _userio-usr = _connect-usr.
display _userio-id _userio-usr.
 
Thank you, Paul.

What I needed was to find the name of the current workstation.

I did what follows (I'm not sure about using "ON" or "IN", sorry about that)


On a include file:

DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
DEFINE VARIABLE ptrToString AS MEMPTR NO-UNDO.

PROCEDURE GetComputerNameA EXTERNAL "KERNEL32.DLL":
DEFINE OUTPUT PARAMETER ptrToString AS MEMPTR.
DEFINE INPUT-OUTPUT PARAMETER intBufferSize AS LONG.
DEFINE RETURN PARAMETER intResult AS SHORT.
END PROCEDURE.



On the program:


RUN GetComputerNameA (OUTPUT ptrToString,
INPUT-OUTPUT intBufferSize,
OUTPUT intResult).

IF intResult = 1 THEN
DO:
ASSIGN chrComputerName = GET-STRING(ptrToString,1).
END.
ELSE
ASSIGN chrComputerName = "Estacion no identificada".


This worked.


Thnkns again
 
I'm with Paul. And Tom, too. How on earth do you get that the Windows workstation name is the same thing as the "name of the TTY where USERID is connected?"
 
Back
Top