set a = 3
set type = a
echo $($type)

How for me to get value of 3 from variable $type which is a. I can't get value 3 from what i do above? please help thanks!

Your problem comes from a couple of things. Try this:

a=3
type=$a
echo $type
a = 3
b = 2
c = 5
d = 1

foreach type(a b c d)
if(step == $$type) then
echo "the value is 3"
endif
end

my problem is something like this, how for me to get the value 3 from the variable type, i cannot assign a b c d in type as a variable, it is a value

Are we talking linux(unix) shell scripting or Windows scripting?

I am doing my script on Window using cshell

Sorry never really used that particular shell app. Try asking again and including that information and someone better qualified may have a better idea.

this code is for unix shell scripting....you better check if this works for WScript or not....

set valu=3
a = 3
b = 2
c = 5
d = 1
 
for valu in $a $b $c $d
if [ step = $valu ] then
echo "the value is 3"
fi
done
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.