Page 1 of 1

mac and windows command line standalone how?

Posted: Sun Feb 19, 2012 2:30 am
by josemv
Hello,

am trying to get a simple program run as a standalone from the command line accepting parameters and displaying results on the screen.

I got accepting parameters in both Windows and Mac, but there is no way to get output to the screen on Windows. I read everything on forums and list about this issue and seems it is an obscure feature or simply doesn't works.

Currently am running LC 4.6.4

This is stack code am trying:

Code: Select all



on startup
      hide this stack
      local tCommandLine  
      
   
      --put "using put hello2 plus cr" & CR into stdout
      --put "using put hello2 plus return" & return into stdout
      
      --write "using write hello2 plus return" & return to stdout
      write "using write hello2 plus cr" & CR to stdout   
      
      -- handle command line arguments here
      put word 1 to -1 of lower($1) into tCommandLine
      
      switch char 2 of tCommandLine
            case "t"
                  put "with -t param" & return after URL "file:debug.txt"
                  quit
                  break
                  
            default
                 put "any other case " & tCommandLine & return after URL "file:debug.txt"
                 quit
                 break
      end switch
end startup


This is the only way I found to get output on the screen on Mac OSX

Code: Select all

write "using write hello2 plus cr" & CR to stdout
Any body could give an example to get the same on Windows?

Thanks
Jose

Re: mac and windows command line standalone how?

Posted: Sun Feb 19, 2012 2:38 am
by sturgis
If I recall correctly, if you run from the command line with -ui switch, then you can also use "put whatever" with no target and it will show.

The way the windows console works is.. different. As mentioned recently on the use-list you can redirect the output to a file

mycommandlineapp > output.txt

and it will work. YOu can also pipe the output to another command.

mycommandlineapp | more

and it should work but of course then you have to worry about whether the output text is long enough to force pagination.

If its just for personal use you could download some unix utilities so that you have access to cat which you can use as a straight pass-through

mycommandlineapp |cat

No matter how you cut it, windows is kinda a pain in the tookus. If you have livecode server you can use it instead. It works very well.

Re: mac and windows command line standalone how?

Posted: Sun Feb 19, 2012 2:49 am
by josemv
Hi,

thanks for your help.

Need a solution as simple as possible to run an .exe file getting arguments and outputting results to the screen. Server is not an option, I will try with -ui and piping, but doesn't looks the simpler solution for that kind of users.

Jose

Re: mac and windows command line standalone how?

Posted: Mon Feb 20, 2012 1:53 am
by mwieder
Sounds like piping the output to a temporary file (see the "tempname" entry in the dictionary) would be your answer here. After piping the output to a temp file, load it into a variable for further work or into a field for display.

Re: mac and windows command line standalone how?

Posted: Mon Feb 20, 2012 8:18 am
by josemv
Hi

thanks all for your help. Got working with -ui and | more allow to output to the screen in Windows. Mac version works ok too.

Jose