Sign in to follow this  
Followers 0
slair

return a value,passed by reference to teststand

16 posts in this topic

Hi eveyone...

i had a quick question am. i've created a script using autoit, in the which I would like to return an integer (actually 1 or 0) to teststand.

am not really sure how this works in autoit, this is my second day using it...i've been looking in the forums and in the help file, but am not 100% sure still.

usually in C I would do somehting like

Function(int *value)

{

value = 50/2;

}

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to AutoIt and the forum!

Func _YourFunctionName()
    Return 50/2
EndFunc
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for the quick response...ill give that a try.

but am used to passing values to TestStand by reference, how would i do that?

all the functions I send TestStand are declared as void.

but that could work

Share this post


Link to post
Share on other sites

.... i don't seem to be getting the value am attempting to send TestStand

Share this post


Link to post
Share on other sites

Post the script you're using.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

When you talk about "TestStand" what is it? Another application?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

[autoit]

Global $c, $x,$pf

ShellExecute("file.pro","","C:FlashPro", "", @SW_MAXIMIZE)

Sleep(4000)

;MsgBox(0, "StringCompare Result (mode 2):", $x)

Call("tst","")

Sleep(1000)

ControlClick("FlashPro", "" , 3218) ;ok button

MsgBox(0, "StringCompare Result (mode 2):", $c)

Func tst (ByRef $x)

Local $sReady = ControlGetText("FlashPro" , "Ready", 59393) ;status bar

$x = StringCompare($sReady,"Ready", 2 )

;local $e

While $x <> 0

Local $sReady = ControlGetText("FlashPro" , "Ready", 59393)

$x = StringCompare($sReady,"Ready", 2 )

$c=$c + 1

If $c == 50 Then ExitLoop

WEnd

;Return $x

EndFunc

[autoit]

I call executable from teststand, to program a device, if successful return 0 to teststand....btw i think testand is expecting a string and not an integer to be returned, but am not sure but it was selected as default. i switch it to integer and TestStand returned an error.

Yes water TestStand is another application

Share this post


Link to post
Share on other sites

There's no reason to use ByRef here. You're not actually sending the function anything so I'm not surprised when it doesn't even run.

Perhaps this might be closer to what you're trying to achieve.

Global $c
ShellExecute("file.pro", "", "C:\FlashPro\", "", @SW_MAXIMIZE)
Sleep(4000)

;MsgBox(0, "StringCompare Result (mode 2):", $x)
$c = tst()
Sleep(1000)

ControlClick("FlashPro", "", 3218) ;ok button
MsgBox(0, "StringCompare Result (mode 2):", $c)

Func tst()
    Local $sReady = ControlGetText("FlashPro", "Ready", 59393) ;status bar
    $x = StringCompare($sReady, "Ready", 2) 
    While $x <> 0
        Local $sReady = ControlGetText("FlashPro", "Ready", 59393)
        $x = StringCompare($sReady, "Ready", 2)
        $c = $c + 1
        If $c = 50 Then ExitLoop ; btw this will execute in about 100 ms so not sure what it's purpose is.
     WEnd
     Return $x
EndFunc

NOTE: I didn't test this, I am only changing the way the function is accessed and the value returned.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

the function seems to be running fine...eitherway. ok so now I have my value in that $c variable, sooo how would would I send that $c to lets say another executable/program. or maybe send the location of where that value is stored

I mean can AutoIt do that?

i think I found a workaround, not with AutoIt. but I would like to preferably do it all with one pieace of code if possible

appreciate the help

-Thanks

Edited by slair

Share this post


Link to post
Share on other sites

if you want to send the value to another GUI then use AutoIt WIndow Info Tool to get the ControlID. In your script you use function ControlSend to send the content of the variable to the control.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

the function seems to be running fine...eitherway.

That function wouldn't run the way you accessed it. You sent it "" which is not a variable or an array. As far as AutoIt is concerned you sent it a constant, which you can't do using byref.

ok so now I have my value in that $c variable, sooo how would would I send that $c to lets say another executable/program. or maybe send the location of where that value is stored

I'm not sure what you're trying to do with it, so I can't really answer that. You're all over the place in what you want to do with the return value.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

consolewrite() will work :) thx for the help

Share this post


Link to post
Share on other sites

btw what would be the most efficient way of implementing waits, while checking a gui till ready to continue the next step...the program am trying to atomate has some serious (at least two) long load times.

I

Share this post


Link to post
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
Sign in to follow this  
Followers 0