# Storing Output from a step to a vairable

**URL:** https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117
**Category:** Discussion
**Created:** [June 26, 2006, 12:05pm UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117 "2006-06-26T12:05:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 26, 2006, 12:05pm UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117/1 "2006-06-26T12:05:47Z")

</div>

Hi guys,  
  
I have a small FB project which syncs code from perforce and then builds it.  
  
How can i check the output from the sync from perforce part, check if all code is sync to head, if so skip the [vs.net](http://vs.net) build, else do the build?  
  
I am trying to assign the output from the perforce step to a varibale but i am struggling to do so.  
  
Any help greatly appreciated  
  
Thanks  
Dave

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [June 26, 2006, 12:42pm UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117/2 "2006-06-26T12:42:14Z")

</div>

Dave,  
  
You first of all need to create a FinalBuilder user or project variable, go to Tools menu, Edit Variables.  
Then in Perforce Sync action (or any for that matter), go to the Properties tab of the action and set the “Log to variables” checkbox.  
  
But… if you want to scan each line of the output for some text, you can do so using the OnStatusMessage event (look in the Script Editor tab at the bottom of the FB IDE when you’ve selected the Perforce Sync action). This event will get called with the output of the action (it will get called multiple times, and StatusMessage may have more than one line of output each time).  
  
Or… if you are trying to detect if the sync has done anything or not, you could use the “Fail if no files synced” option in the Sync Options tab.  
  
hth.  
.t8

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 26, 2006, 3:18am UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117/3 "2006-06-26T03:18:40Z")

</div>

Thats Tate,  
  
That worked a charm,  
I didn’t want to fail on no file sync, because i send e-mails out on any failure. So if a schedule FB to run every hour and there are no syncs i dont want e-mails been sent out.  
  
I did a text search on the output which i assigned to a variable. I check for ‘File(s) up-to-date’.  
I then use and ‘if then’ to check for a match, if nothing then build the solution  
  
Is this a good approach?  
  
Cheers  
  
Dave

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [June 27, 2006, 1:14am UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117/4 "2006-06-27T01:14:45Z")

</div>

Posted By Dave Curtin on 26 Jun 2006 8:18 AM  
  
I did a text search on the output which i assigned to a variable. I check for 'File(s) up-to-date'.  
I then use and 'if then' to check for a match, if nothing then build the solution  
  
Is this a good approach?  
  

  
  
It's fine. With FinalBuilder there are often several ways to achieve what you want, if it works and performs ok then I wouldn't worry about it.

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [June 27, 2006, 2:02am UTC](https://www.finalbuilder.com/forums/t/storing-output-from-a-step-to-a-vairable/117/5 "2006-06-27T02:02:12Z")

</div>

Dave,  
  
As Vincent says, there are many ways to skin a cat :)  
  
Another way (but not necessarily better) would be to use the exception handling actions, eg:  
  
TRY  
Perforce Sync (fail if no files sync'ed)  
CATCH  
// no files synced, so abort the build  
Stop Run (set Result to Success)  
END  
// now actually do the build  
  
  
.t8
