Jump to content

return a value,passed by reference to teststand


slair
 Share

Recommended Posts

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

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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.

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

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

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...