좋아요. 나는 학교 과제를 끝내려고하고 있으며 내 인생을 위해 그것을 이해할 수 없다. powershell을 사용하여 한 함수에서 다른 함수로 값을 전달하여 "모듈 형"유형 스크립트를 작성하려고합니다. $ script : xxxxx를 사용하지 않고 함수의 범위 밖으로 값을 이동하는 방법을 알아낼 수 없습니다. powershell의 값을 정규 인수 매개 변수로 참조로 전달하는 다른 방법이 있습니까?Powershell이 인수 값을 매개 변수로 전달하고 뒤로
여기에 내가 가진 무엇 다음 inputGrams 기능은 스크립트가 실행될 때마다 변경해야하지만이 때문에 범위 문제와 가치를 전달하지
function main
{
inputGrams($carbGrams, $fatGrams)
$carbGrams
$carbGrams
calcGrams
displayInfo
}
function inputGrams([ref]$carbGrams, [ref]$fatGrams)
{
$carbGrams = read-host "Enter the grams of carbs per day"
$fatGrams = read-host "Enter the grams of fat per day"
}
function calcGrams
{
$carbCal = $carbGrams * 4
$fatCal = $fatGrams * 9
}
function displayInfo
{
write-host "The total amount of carb calories is $carbCal"
write-host "The total amount of fat calories is $fatCal"
}
main
두 값 직후. 누구든지 올바르게 그 값을 주요 기능으로 다시 전달하는 방법을 알고 있습니까?
어느 부분 숙제, 계산 영양 정보 또는 PowerShell 스크립트를 작성입니까? 후자가 내가 학교를 좋아하는 경우 :-) –