+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
Windows Server 2000/2003 Thread, Learning Scripting in Technical; Do you have any programming knowledge at all? Without meaning to sound annoying... could be worth while learning the basis ...
  1. #16
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,214
    Thank Post
    156
    Thanked 146 Times in 131 Posts
    Rep Power
    102
    Do you have any programming knowledge at all?

    Without meaning to sound annoying... could be worth while learning the basis of things like variables, constants, functions, loops, conditional statements & data types first... it may make it easier to understand what is going on rather than diving in - the best site i found at uni was learning pseudocode... i found it easier to then 'visualise' the code if that makes any sense.

  2. #17
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    [ame=http://en.wikipedia.org/wiki/Pseudocode]Pseudocode - Wikipedia, the free encyclopedia[/ame]

  3. #18
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,214
    Thank Post
    156
    Thanked 146 Times in 131 Posts
    Rep Power
    102
    I meant to attach that, haha! Yes, Wikipedia and pseudocode was a great help :-)

  4. #19

    Join Date
    Aug 2009
    Posts
    25
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    i did a years worth of vb whilst at college so i have an idea about variables constants, loops etc but its well worth me having a look over them again and having a look at that site.
    Cheers for that!

  5. #20

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    not to side track as I have used constants but what is the point of them ie

    Code:
    const strShareOne = "HP_Colour"
    
    MapPath "\\server\" & strShareOne
    As apposed to

    Code:
    MapPath "\\server\HP_Colour"
    Obviously am making the commands up but just to give you an idea

    Unless someone can post back a good example of when and why you would use constants whether in vbscript, vb .net or whatever

  6. #21

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    There's 2 reasons really - the first is about the fact that it's something that you might want to use loads of times and you don't want to have to change the value throughout the script. The second is the fact that you're saying that the value can't be changed - this avoids making errors where you accidentally change something.

    Take an example, you're writing a script which is going to connect printers on a server. Let's suppose the server is called server1. You could list all your printers as "\\server1\printer1" "\\server1\printer2" etc but then when you get a new server you have to change all those references. If you have const sServer="\\server1\" at the beginning and then lines like mapprinter sSever & "printer1" then all you have to do is update the const value at the start.

    It can also make scripts more readable - you don't get bogged down in long string literals but you have a meaningful name (although that's also true for using variable names)

  7. #22

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    Quote Originally Posted by srochford View Post
    There's 2 reasons really - the first is about the fact that it's something that you might want to use loads of times and you don't want to have to change the value throughout the script. The second is the fact that you're saying that the value can't be changed - this avoids making errors where you accidentally change something.

    Take an example, you're writing a script which is going to connect printers on a server. Let's suppose the server is called server1. You could list all your printers as "\\server1\printer1" "\\server1\printer2" etc but then when you get a new server you have to change all those references. If you have const sServer="\\server1\" at the beginning and then lines like mapprinter sSever & "printer1" then all you have to do is update the const value at the start.

    It can also make scripts more readable - you don't get bogged down in long string literals but you have a meaningful name (although that's also true for using variable names)
    I did something like that for a printer script I did on here somewhere where I used const values for the share names as the print server was only one server so I made the share names const values.

    Thanks for the clarification

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. New to scripting, need help
    By speckled in forum Scripts
    Replies: 1
    Last Post: 22nd November 2009, 08:09 AM
  2. os x scripting
    By mac_shinobi in forum Mac
    Replies: 5
    Last Post: 22nd August 2008, 09:30 AM
  3. Scripting and msi's
    By stu in forum How do you do....it?
    Replies: 5
    Last Post: 26th June 2008, 06:47 PM
  4. Printer Scripting
    By dave.81 in forum How do you do....it?
    Replies: 2
    Last Post: 23rd April 2008, 12:50 PM
  5. New to scripting
    By FN-GM in forum Scripts
    Replies: 26
    Last Post: 10th August 2007, 10:31 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •