I'm currently running the following script I've made for practice as I'm attempting to improve my powershell skills, I wanted to start with some basics in case I missed things as I slowly pieced together my knowledge and was calculating circles and other shapes/forms to work with functions a bit.
function calculate-circle{
$pi = 3.14
[float]$radius = read-host "What is the radius?"
$surface = $radius*$radius*$pi
write-host "The surface area of a circle with radius $radius is $surface"
}
Within the Powershell ISE, this executes without a flaw and I'm able to input a radius and come up with calculations.
In VS Code I get the following, after highlighting the entire script and running it using the hotkey for "Run Selected Text In Active Terminal".
PS C:\> function calculate-circle{
Missing closing '}' in statement block or type definition.
At line:0 char:0
PS C:\> $mypi = 3.14
PS C:\> [float]$radius = read-host "What is the radius?"
What is the radius?:
PS C:\> $surface = $radius*$radius*$mypi
PS C:\> write-host "The surface area of a circle with radius $radius is $surface"
The surface area of a circle with radius 0 is 0
PS C:\> }
At line:1 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
What I can't figure out is, is this an issue with my code or is this some quirk of Powershell within VS Code? I was really enjoying some of the VS Code functionality so I'm a bit miffed. Thanks a ton!