What code should I put into a .PS1 file if I want to pipe into its filename? [closed] - powershell

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 days ago.
The community is reviewing whether to reopen this question as of 10 days ago.
Improve this question
I want to do something like $foo | .\bar.ps1, and handle $foo inside bar.ps1. What's the minimal example of bar.ps1 in which I can access the value of $foo?
Edit:
The question has been closed, but I have found the answer: write in the file as if it's a function, but just strip function {} keyword, just put what you would put inside the {}. If you don't have a process{} block, use $input to access the piped value. If you have a process{} block, use $PSItem.
It's worth noting that $input can only be accessed once, so save it to a variable first.

Related

How to keep function variable in workspace to avoid load .mat file repeatedly in matlab? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
function A(B,C)
load d.mat
my code
end
Is there a way that I can use d.mat file without load/import it. Or is there a way that do not need to load/import d.mat file every time I run function A.
You can pass the variable/content of d.mat as an extra parameter to the function A.

Need Regular expression [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can some one tell me the regular expression for below file :
Input string
Exp :
com.skype.raider
com.instagram.android
com.android.phone
com.android.gallery
com.android.launcher
com.Zeus.webbrowser
Desired Strings(o/p)
com.android.phone
com.android.gallery
com.android.launcher
I tried like : $line =~ /com.android.*/ but its not working the way i wanted to be :(
I assume you're looking for a regular expression to match anything that begins with com.android.
If that is the case, try something like this:
com\.android\..*
Tested using RegexPlanet

What happens when a file is "run" [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
If I write a function in a .m file and try to run it by pressing the "run" button, will the function just be set in the environment or also run, maybe without arguments?
If the function does not take any arguments, then it will simply be executed. If the function does take arguments, and you try to run it via the GUI, you should be prompted to enter a set of default arguments that should be used. These arguments will be used if you ever run the script in the future.
This is described in Matlab's documentation here.
There are two types of mfiles (files with .m extension) in Matlab:
Scripts and Functions. (See Scripts vs. Functions)
See Calling a function for how to use a function programmatically.

how to write a LaTeX macro for conditional compiling? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I want to write some notes in the draft of a LaTeX document, and at a later point I want to compile the document without them. I saw someone doing something like the following (but I forgot what he did). Write notes as {\scriptsize some_text}, and in the end replace all {\scriptsize ...} with {} with a \newcommand. But I can't figure out how to write a \newcommand to replace all {\scriptsize some_text} occurrences by empty strings. I can then just comment or uncomment the \newcommand line.
Declare in the beginning of your file
\somevariabletrue
%\somevariablefalse
so you can quickly uncomment one and comment second, and in the later part of your code:
\ifsomevariable
...
\else
...
\fi

Variable in a Variable iPhone? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
For my iPhone app in objective-c is it possible, and if so how can I make a variable inside a variable?
For example, I have one named Var1 and then I can combine it with Var2. Lets say Var2 is a number, so it displays Var1 like Var11, the second one being Var2. Make sense? Anyway if Im not making sense, could you let me know how a variable in a variable can be done, and used? Thanks.
Are you talking about arrays? Use Arrays.