rehnmark Posted June 9, 2006 Share Posted June 9, 2006 Hi there! I would really need some help, hope you can help me This is my code: antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1() if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2() if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3() EndFunc My question is, how do i get the variables (and its values) $ws1, $ws2 and $ws3 to the functions ominstallation1(), ominstallation2() and ominstallation3()? Thanx for your help! Link to comment Share on other sites More sharing options...
pinkfoyd Posted June 9, 2006 Share Posted June 9, 2006 (edited) make an array and call your function with it in return element ie : Dim $array[4] $table = antaldatorer() put all you variable in the array and put this a the end of your function : return($array) Edited June 9, 2006 by pinkfoyd Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 9, 2006 Moderators Share Posted June 9, 2006 Put them in a Global scope, that way each function can use them... Exampleexpandcollapse popupGlobal $ws1, $ws2, $ws3 antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1() if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2() if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3() EndFuncoÝ÷ Øêî±êZ©µêìjëh×6antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1($ws1, $ws2, $ws3) if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2($ws1, $ws2, $ws3) if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3($ws1, $ws2, $ws3) EndFunc Func ominstallation1($ws1, $ws2, $ws3) ;something EndFunc ;etc... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
rehnmark Posted June 12, 2006 Author Share Posted June 12, 2006 Put them in a Global scope, that way each function can use them... ExampleGlobal $ws1, $ws2, $ws3 antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1() if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2() if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3() EndFuncoÝ÷ Øêî±êZ©µêìjëh×6antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1($ws1, $ws2, $ws3) if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2($ws1, $ws2, $ws3) if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3($ws1, $ws2, $ws3) EndFunc Func ominstallation1($ws1, $ws2, $ws3) ;something EndFunc ;etc... Thank you! Global worked like a sharm Link to comment Share on other sites More sharing options...
Uten Posted June 12, 2006 Share Posted June 12, 2006 Using Globals, when they can be awoided, is a bad habit that will bite your tail at some point down the road. So , you would be better of passing arguments. antaldatorer() func antaldatorer() $wsid = InputBox("Ominstallation - PeDeploy", "Ange datornamn för de tre datorer som ska installeras om, ex: W65401010; W65401011; W65401012 ", "W6540", " M") if @error Then Exit $ws1 = StringMid($wsid, 1, 9) $ws2 = StringMid($wsid, 12, 9) $ws3 = StringMid($wsid, 23, 9) $null = StringMid($wsid, 230, 9) if $ws2 = $NULL and $ws3 = $NULL then ominstallation1($ws1, $ws2) if $ws2 <> $NULL and $ws3 = $NULL then ominstallation2($ws1, $ws2, $ws3) if $ws2 <> $NULL and $ws3 <> $NULL then ominstallation3($ws1, $ws2, $ws3) EndFunc ; ; ByRef: Pass by reference. Changes done in ominstallation1 will affect calling function ; $ws3 = "W6540": Default value is W6540, You don't have to use this argument possition ; in the calling function if you accept the default value. Func ominstallation1(ByRef $ws1, $ws2, $ws3 = "W6540") ;Do job EndFunction Func ominstallation1(ByRef $ws1, $ws2, $ws3 = "W6540") ;Do job EndFunction Func ominstallation1(ByRef $ws1, $ws2, $ws3 = "W6540") ;Do job EndFunction Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now