Sign in to follow this  
Followers 0
lgwapnitsky

Resetting all variables in a script

6 posts in this topic

#1 ·  Posted (edited)

I have a fairly complicated script that does user provisioning for my Windows network (I've been working on other issues in other parts of the forum). What I'd like to do is have an option at the very end of the script that asks if I want to create a new user and, if yes, clears all variables. I will admit, my script has gotten rather large and probably a bit disorganized with the amount of fields, etc. that I've created, but I was hoping there was a relatively simple solution. I'm more than happy to post my script if anyone wants to see what is going on inside of it.

Regards,

Larry

Update: Found a good solution to my problem here. There's a _restart function that was written that does the job simply and perfectly.

Edited by lgwapnitsky

Share this post


Link to post
Share on other sites



Why do the variables need to be "cleared"? Aren't their values correctly initialized when you do each user? If not, correct your script so they are.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Why do the variables need to be "cleared"? Aren't their values correctly initialized when you do each user? If not, correct your script so they are.

:mellow:

Because each user might be in a different office with different address/phone info, different security groups, etc.

anyway, I found an solution that I've posted in my initial question above.

Thanks

Share this post


Link to post
Share on other sites

lgwapnitsky.

I was hoping there was a relatively simple solution

Alas I fear not. :P

My best suggestion is to tidy up your "disorganized" code so that you have a nice grouping of initial variable declarations to copy to a function and so be able to reset them with a single call.

Sorry not to be more optimistic, but you will probably benefit from the tidying in any case! :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Because each user might be in a different office with different address/phone info, different security groups, etc.

anyway, I found an solution that I've posted in my initial question above.

I think Valuator would rather you clean up your script too. That trick just temporarily extends the life cycle of a script that badly needs a rewrite.

Sounds like you did the whole thing in one string of spaghetti code. For example, if a GUI collects the required information, then makes a call to function(s) to do the work, the local variables in the functions are recreated fresh every time the function is called and they disappear when the function returns. There's no point in "clearing" them.

A single reset function could prep the GUI for input of the next user's info, but what if you have to do several similar users? Must you clear the department every time for example, when you might be setting up ten users in the same department and location, and appreciate not having to re-enter that over and over again? Other fields of course could reset every time, like last name.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I do have a lot of global variables because items are constantly being changed throughout and accessed multiple times. I agree that it is spaghetti code, but it does work for what i need right now. I can try to optimize going forward, but right now i don't have the time to do do anything but make it functional.

As for needing to clear the department, it's more of a multi-location office situation with different addresses, phone numbers, default groups, different OUs, etc. The script itself creates the user, populates all necessary fields in AD, creates the mailbox, then sets up home and profile directories on our DFS servers.

btw - if you'd like to see my "spaghetti" code, let me know. I can post it, but it's almost 700 lines.

Edited by lgwapnitsky

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