Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - External File - Lookup Table

Reply
 
Old 10-24-2008   #1 (permalink)
IT Staff


 
 

External File - Lookup Table

In my script, i used a switch statement.

Is there a way that the script points to a external file and get the values
from external files ?

Eg

External_file.txt
1 good
2 bad
3 neutral

Is there similar thing like #include <external_file.txt>, and the powershell
loads the value from external files ?




My System SpecsSystem Spec
Old 10-24-2008   #2 (permalink)
tojo2000


 
 

Re: External File - Lookup Table

On Oct 23, 10:26*pm, "IT Staff" <jkk...@xxxxxx> wrote:
Quote:

> In my script, i used a switch statement.
>
> Is there a way that the script points to a external file and get the values
> from external files ?
>
> Eg
>
> External_file.txt
> 1 good
> 2 bad
> 3 neutral
>
> Is there similar thing like #include <external_file.txt>, and the powershell
> loads the value from external files ?
Are you creating this file? Why not just create a switch statement in
the file and then do:

.. .\External_file.ps1
My System SpecsSystem Spec
Old 10-24-2008   #3 (permalink)
IT Staff


 
 

Re: External File - Lookup Table

Thanks it works. However for performance, which method is better ?


a) calling a external file (but my main script is shorter)
b) put my functions into main script (longer script without external file)


"tojo2000" <tojo2000@xxxxxx> wrote in message
news:df7275cd-fd92-4c42-8d32-2482f5ca97b7@xxxxxx
On Oct 23, 10:26 pm, "IT Staff" <jkk...@xxxxxx> wrote:
Quote:

> In my script, i used a switch statement.
>
> Is there a way that the script points to a external file and get the
> values
> from external files ?
>
> Eg
>
> External_file.txt
> 1 good
> 2 bad
> 3 neutral
>
> Is there similar thing like #include <external_file.txt>, and the
> powershell
> loads the value from external files ?
Are you creating this file? Why not just create a switch statement in
the file and then do:

.. .\External_file.ps1


My System SpecsSystem Spec
Old 10-24-2008   #4 (permalink)
tojo2000


 
 

Re: External File - Lookup Table

On Oct 24, 12:33*am, "IT Staff" <jkk...@xxxxxx> wrote:
Quote:

> Thanks it works. However for performance, which method is better ?
>
> a) calling a external file (but my main script is shorter)
> b) put my functions into main script (longer script without external file)
>
> "tojo2000" <tojo2...@xxxxxx> wrote in message
>
> news:df7275cd-fd92-4c42-8d32-2482f5ca97b7@xxxxxx
> On Oct 23, 10:26 pm, "IT Staff" <jkk...@xxxxxx> wrote:
>
>
>
Quote:

> > In my script, i used a switch statement.
>
Quote:

> > Is there a way that the script points to a external file and get the
> > values
> > from external files ?
>
Quote:

> > Eg
>
Quote:

> > External_file.txt
> > 1 good
> > 2 bad
> > 3 neutral
>
Quote:

> > Is there similar thing like #include <external_file.txt>, and the
> > powershell
> > loads the value from external files ?
>
> Are you creating this file? *Why not just create a switch statement in
> the file and then do:
>
> . .\External_file.ps1
The difference should be miniscule for most applications. If you are
going to be importing this section of code from an external file, then
I would wrap it in a function so that you only have to import it
once. Generally it is helpful to import a script when the code will
be reused, when you want to make it easier to change just that one
section, or when it makes your main script more readable, but in
general the difference in performance should be negligible.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Typed datasets and table table adapters components not showing inToolbox .NET General
Export SQL Server table to text file VB Script
HTA file - display data from DB records in table like ASP - how? VB Script
Out-File after Format-Table via a filter PowerShell
How do I read a XML file into a hash table? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46