2017-01-04 5 views
-3

とても頑張って、何が間違っているのか分かりません。それは私があなたが私は、これはあなたが書くしようとしている言語であると仮定しPowerShellのようにこれをタグ付けしましたこのpowershellスクリプトで何が問題になっていますか?

Param(
[string]$i = "", 
[int]$start, 
[int]$end, 
[int]$width, 
[int]$height, 
[string]$o = "" 
) 

if ($i.Length == 0 or $o.Length == 0 or ($width == 0 and $height == 0)) 
{ 
    Write-Host "input, output, either of width of height are required" 
    Exit 
} 
$sum = $start + $end 
if (not ($sum==0) and ($sum == $start or $sum == $end)) 
{ 
    Write-Host "When either of the start or end is supplied, the other has to be supplied too" 
    Exit 
} 

$widthString = $width.ToString() 
$heightString = $width.ToString() 

if (($width -ge 0) and $height==0) 
{ 
} 

Error shown on the ISE

+0

まあ、その上の行はおそらく '$ heightString = $ height.ToString()'であるべきですが、それはあなたのエラーを引き起こすとは思わない。 –

+0

私が見る最大の問題は、[比較演算子](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_comparison_operators)を使用して、 '=='の代わりに '-eq'と'と 'の代わりに'と 'を使います – BenH

+2

あなたは明らかに多くの機能概念を取り上げましたが、このスクリプトではすべてが間違っています。あなたは実際にこれで達成しようとしているものを(英語で)記述できますか?あなたが問題を抱えている多くの制約は、スクリプトの中ではなく、 'param'ブロックに実装されている可能性があります( –

答えて

5

をあきらめ、些細なと恥ずかしい何かであることが判明するかもしれませんか?

トークンはPowerShellでは有効ではありません。比較/論理演算子の一覧はhereです。

しかし要するに

==-eqand-andor-orなどであるべきであるべきであるべきです。

+2

'not'も' -not'でなければなりません –

関連する問題