Jump to content

Give return value to calling script


Recommended Posts

I need to return a string value to the calling script. All i can find is the exit function, but that's just for ints. Is there a way to output text to the console? Or to modify an EnvVar?

<{POST_SNAPBACK}>

lots of ways to do that, tmp files, registry etc, probably the easiest is to declare a global variable outside of the function in your script, and have your function set it.

example:

Global $myvar = ""

...

Func ReturnSomething()
$myvar = "global variables are FUN"
EndFunc
Link to comment
Share on other sites

@CameronsDad

Global Variables dont work between scripts.

@P T R

Using some sort of a text file would be the way I would have to suggest, without knowing more about your project.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I need to return a string value to the calling script. All i can find is the exit function, but that's just for ints. Is there a way to output text to the console? Or to modify an EnvVar?

<{POST_SNAPBACK}>

Envar is pretty good, or RegWrite(), RegRead() or ClipPut(), ClipGet(), Text files, TCPSend(), etc.. lots of ways, just choose one.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

@CameronsDad

Global Variables dont work between scripts.

@P  T  R

Using some sort of a text file would be the way I would have to suggest, without knowing more about your project.

JS

<{POST_SNAPBACK}>

Oops, obviously right, i was thinking about between functions rather than scripts...to use between scripts, i'd #include the script being called, and have a global variable setup in the calling script. the script being called CAN edit the global variable if it is included by the calling script. the only real change that may be required would be to put the contents of the second script into a function if they're not already.
Link to comment
Share on other sites

I need the result/output from the autoit script outside of the autoit script, so when i call it from the command line for example, it gives an output to the console or if i can use a function like 'envset' to create/modify the envvars in the console/batch environment, i can use that in the rest of the batchfile.

One of the things it does, is read out an ini value, which later on is used as a parameter for another program (no autoit script). Due to the nature of the environment, i (sadly) cannot use autoit for the whole process.

In short, i need to 'transfer' stringinfo between programs through a batchenvironment.

Thanks,

Peter

Link to comment
Share on other sites

I need the result/output from the autoit script outside of the autoit script, so when i call it from the command line for example, it gives an output to the console or if i can use a function like 'envset' to create/modify the envvars in the console/batch environment, i can use that in the rest of the batchfile.

One of the things it does, is read out an ini value, which later on is used as a parameter for another program (no autoit script). Due to the nature of the environment, i (sadly) cannot use autoit for the whole process.

In short, i need to 'transfer' stringinfo between programs through a batchenvironment.

Thanks,

Peter

<{POST_SNAPBACK}>

if you were able to have the script run the program that needs the string, it would be easy to have it grab the ini then just call the next executable with the value you want as a command line parameter. Since that isn't an option though, one thing you could do.... is have the batch file created dynamically. example... have your autoit script do everything you want it to do, then as it's closing have something like:

$blah = IniRead("File.ini","Section","Key")
$DynaBatch = FileOpen("batch.bat",2)
FileWriteLine($DynaBatch,"@echo off")
FileWriteLine($DynaBatch,"OTHER STUFF")
FileWriteLine($DynaBatch,"c:\blah\blah\arg\ack\AutoItWouldBeSoMuchEasier.exe /" & $blah)

that way the batch file is created to run your other program and the ini value is added to the call to your other program...

Link to comment
Share on other sites

One of the things it does, is read out an ini value, which later on is used as a parameter

INI value?? ==> IniRead() and IniWrite()

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Also, if you dont mind my asking. Why cant you use AutoIt for the whole process? I missed that somewhere. Everything you are talking about that needs to be done, can be done in AutoIt.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Also, if you dont mind my asking. Why cant you use AutoIt for the whole process? I missed that somewhere. Everything you are talking about that needs to be done, can be done in AutoIt.

JS

<{POST_SNAPBACK}>

he said that the 'environment doesn't allow' i figure it's just some stupid corporate policy, we have a bunch of those here (like no internet) so i can empathize.
Link to comment
Share on other sites

he said that the 'environment doesn't allow' i figure it's just some stupid corporate policy, we have a bunch of those here (like no internet) so i can empathize.

<{POST_SNAPBACK}>

I guess I can understand that, but on the other hand he is already using an AutoIt script so I dont understand what is to stop him from using a fully functional script :)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I guess I can understand that, but on the other hand he is already using an AutoIt script so I dont understand what is to stop him from using a fully functional script :)

JS

<{POST_SNAPBACK}>

yeah it took me a minute to wrap my head around that one too, but then i realized that to circumvent my company's 'no internet' policy, i access forums via AutoIT help file... still doing what i'm not 'supposed' to... but as far as i know, this is a static part of the help file that i'm running, and there is some awesome AI that creates all of the posts i respond to... so i can't really knock him too much for making a script to avoid using a script..
Link to comment
Share on other sites

Enviroment variables probably won't work.

When A Parent Process spawns a child process, the child get's a COPY of the parent's Environment variables. This is a ONE WAY transfer.

So, if the child CHANGES env variables, the parent doesn't see those changes.

So, if Parent calls ChildAutoIT, the parent can't see any changes Child.. makes to them.

Usually the way this is handled (neatly) with command line stuff (like Unix scripts, etc.) is having the command line program return a value.

Registry settings are probably going to be your best bet, but it's an "inelegant" solution.

But, better the $.50 russian pencil than the $2M NASA "zero g" Pen, right?

Link to comment
Share on other sites

Enviroment variables probably won't work.

When A Parent Process spawns a child process, the child get's a COPY of the parent's Environment variables. This is a ONE WAY transfer.

So, if the child CHANGES env variables, the parent doesn't see those changes.

So, if  Parent calls ChildAutoIT, the parent can't see any changes Child.. makes to them.

Usually the way this is handled (neatly) with command line stuff (like Unix scripts, etc.) is having the command line program return a value.

Registry settings are probably going to be your best bet, but it's an "inelegant" solution. 

But, better the $.50 russian pencil than the $2M NASA "zero g" Pen, right?

<{POST_SNAPBACK}>

when you use an #include statement though, and then call the function inside the second script, global variables are passed by reference, so changing them in the called function does actually affect the value stored...
Link to comment
Share on other sites

I solved it through a file passthrough method. The script takes a filename as argument where the output needs to get stored. By using the batch pipe options, the progs get their answer.

To expand a little on the environment, the script is more a function/tool for multiple processes/batches. That's one of the reasons i want to save the output. The file method works, but i was hoping there was a simple way to communicate the output, which i might have missed.

Link to comment
Share on other sites

I don't know if you're using the release version of AutoIt or the beta, but the current beta release has functions that let you read the console output from any child processes you call with Run, then you could test that output for success or data or whatever.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

But, better the $.50 russian pencil than the $2M NASA "zero g" Pen, right?

<{POST_SNAPBACK}>

Just thought Id point this out becasue im bored at work, kudos by the way for stating the pen cost $2m and not the normal mis conception of $12

http://www.truthorfiction.com/rumors/s/spacepen.htm

Even still the solution sounds incredibly simple, put the ink inside the pen underpressure, same idea as those toothpaste containers with the button, u press the button ur toothpaste comes out and the base of the tube moves up to keep the remaining toothpaste inside under pressure.

I cant believe it cost $2m, why not just use electronic pens and touch screens ?

Thens theres no need to supply 907.18474Kg of A4 sheets and space pens just so your astronoughts can doodle.

Edit: Corrected spelling mistake, im sure there are more

Edited by Nova
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...