computer name with environmental variable

jam176jam176 Member Posts: 27
edited 2005-04-13 in Navision Attain
hello!

i'm looking for an easy way to find out the current computername. searching the forum i found a topic where the environmental variable %COMPUTERNAME% was mentioned.

well, but how can i read this variable? i tried out
sCN:= ENVIRON(Computername);
but the result is nonsens.

environment: windows 2000, navision 3.60

can anyone give an advice?

thx
jam176
thx
jam176

Comments

  • jhoekjhoek Member Posts: 216
    Open a command prompt on your Win2K machine and type SET | MORE. Do you see a variable called COMPUTERNAME?
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • jam176jam176 Member Posts: 27
    yes, i do!
    thx
    jam176
  • jhoekjhoek Member Posts: 216
    Perhaps the variable names are case sensitive?! Could you call the ENVIRON function and pass the variable name, using the exact same character case as you saw in your Command Prompt window?
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • HalMdyHalMdy Member Posts: 429
    You have to put COMPUTERNAME between ' .

    Try :
    MESSAGE('%1',ENVIRON('COMPUTERNAME'));

    It works ...
  • jam176jam176 Member Posts: 27
    that's it! boah! thanks a lot. quite simple, isn't it. shame on me.

    thanx again jhoek!
    thx
    jam176
  • jhoekjhoek Member Posts: 216
    I don't think your code would compile if you forget the quotes?! Or... do you perhaps have a variable named ComputerName in the same object/scope?
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • jam176jam176 Member Posts: 27
    ineet i've made a big mistake:

    the environ() call is inside a table, where computername is a tablefield! when i called computername without the qoutes i got the fielddata instead of the environmental varible.

    thank you all!
    thx
    jam176
  • jhoekjhoek Member Posts: 216
    At the risk of sounding like a standards zealot... :wink:

    Field names should be in English, and in that language, I believe ["computername"] would be written as "computer name" (with a space). In this particular case, spelling the field name like that would have prevented some rather time-consuming troubleshooting...

    And yes, I know, I should mind my own business... :wink:
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
Sign In or Register to comment.