KyleB Posted November 11, 2016 Share Posted November 11, 2016 I'm creating a script to create a new user and log into ts every time, I had it working but when i started simplifying my code into functions so i could separate them while testing, It couldn't find the variable. I'm just wondering if there is a way to take that variable from the other function. LaunchSEQ () NameGen () JoinSEQ () Func NameGen () Local $arr[26] = ["Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliet","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whisky","X-Ray","Yankee","Zulu"] $i = Random(1, 26, 1) $name = $arr[$i] & "|Burns" Send($name) EndFunc Func JoinSEQ () send("{ENTER}") Send("^s") Sleep(250) Send("{TAB}") Sleep(250) Send("^a") Sleep(250) Send($name) sleep(250) send("{ENTER}") EndFunc Error is located at the bottom regarding the variable "$name" Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 11, 2016 Moderators Share Posted November 11, 2016 (edited) I don't see the error you reference, but if you need $name to be available to the entire script, the declare it at the top as Global. If this function is going to return that variable for use in a subsequent function, use Return instead (see help file for both). Edited November 11, 2016 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KyleB Posted November 11, 2016 Author Share Posted November 11, 2016 (edited) It says "Error: Variable used without being declared.", while i have declared it above it, just within another function. $name = $arr[$i] & "|Burns" Send($name) EndFunc Sleep(250) Send($name) sleep(250) send("{ENTER}") EndFunc Edited November 11, 2016 by KyleB Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 11, 2016 Moderators Share Posted November 11, 2016 Yes, that is the code - I thought you were posting the actual error you're receiving. That will help us a great deal. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KyleB Posted November 11, 2016 Author Share Posted November 11, 2016 Fixed it, thanks Link to comment Share on other sites More sharing options...
spudw2k Posted November 14, 2016 Share Posted November 14, 2016 On 11/11/2016 at 1:46 PM, KyleB said: Fixed it, thanks It's always helpful to the forum community if you share how you resolved it. Was it the because your random function upper and lower limits were wrong (zero-indexed array...0 to 25 instead of 1 to 26)? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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