Question
· Aug 7, 2022

Basic ObjectScript not working in Linux Command Line

I’m a complete novice with ObjectScript.

I’m trying to write some Object Script directly into command line interface on Linux using some examples on the internet

 

sudo -u irisowner iris session SCRTC

Username: superuser

Password: ************

AUMHSCRTC:USER>a SET x=1

AUMHSCRTC:USER> WHILE x<10 {

AUMHSCRTC:USER> WRITE !," Looping",x

AUMHSCRTC:USER> SET x=x+1

AUMHSCRTC:USER> }

AUMHSCRTC:USER> WRITE !,"DONE"

AUMHSCRTC:USER>do a

 Looping1

 Looping2

 Looping3

 Looping4

 Looping5

 Looping6

 Looping7

 Looping8

 Looping9

DONE

That seems to work!

 

How if I put these commands into a file:

cat > /tmp/a.scr

superuser

xyz

a SET x=1

 WHILE x<10 {

  WRITE !," Looping",x

  SET x=x+1

 }

 WRITE !,"DONE"

do a

 

Then:

cat /tmp/a.scr|sudo -u irisowner iris session SCRTC

 

DOES NOT work.

 

Why?

 

Also “routine” or “class” code in Wikipedia - https://en.wikipedia.org/wiki/Cach%C3%A9_ObjectScript these examples do not work either directly or in a file:

hello // hello world routine

    write "hello world"

end quit  // end

DO ^hello

 

AND

 

Class User.Helloworld

{

  ClassMethod HelloWorld()

  {

    // Write to console

    Write "Hello World"

    Quit

  }

}

DO ##class(User.Helloworld).HelloWorld()

Why?

Thanks for any help

Discussion (16)1
Log in or sign up to continue

you are mixing things.
#1) working:
1.1 yo talk to login + authentication
1.2 you talk to command prompt that stores your code locally. 
#2) not working
 authentication from script is not supported, the rest goes nowhere
#3) not working examples
both assume that
3.1 you enter the code in Studio, VSCode, ...and COMPILE  it.
3.2 you call the compiled code from the command line

ALL code needs compiling. You just don't recognize it.
<tab> as the first separator indicates that you to want to store a local commandline.

WRITE<space>123 executes immediately while

WRITE<tab>123  stores a line labeled WRITE with a nonsense code 123

WRITE<tab>WRITE<apace>123  creates a useful command line that you may run by

DO<space>WRITE

This just explains what is happening. But this is not a programming tutorial.