Build forge command for replace or substring.
3 answers
There are no native substring commands for doing substrings in Build Forge, however I experimented on the Windows shell and found that this general command will do what you want:
.bset env "subVar=`echo %testVar:~0,5%`"
Where subVar is the first 5 characters of the variable. You will have to tweak it to remove the last 5 characters, but that should get you started.
~Spencer
This works but with the defualt value only. what I am doing is I am assigning a dynamic value using bset. Then I am echo the value. Then I do the command that you have mentioned but it printing "defau" means the default value only it is breaking from 0 to 5 characters.
Is there any Idea to make this thing work with dynamic value as well.
# This works
.bset env1 "testVar='`echo helloworld`'
# this works and prints the helloworld
echo $testVar
# Your stuff
.bset env "testVar2=`echo %testVar:0,5%`"
# This prints the defau as the initial value of the testVar is default.
echo $testVar2
Any idea on that ?
Is there any Idea to make this thing work with dynamic value as well.
# This works
.bset env1 "testVar='`echo helloworld`'
# this works and prints the helloworld
echo $testVar
# Your stuff
.bset env "testVar2=`echo %testVar:0,5%`"
# This prints the defau as the initial value of the testVar is default.
echo $testVar2
Any idea on that ?
What you are describing is .tset. The .bset command will only take affect after the current step, to affect the current step (and only the current step) you want .tset. So you would need to .tset testVar and then .bset testVar2, assuming you want the value of testVar2 to persist beyond this step and not testVar.
~Spencer
~Spencer