---
title: "Ask Our Ace: Tips on Variable Names, Strings and Integers"
description: "Ask Our Ace: Tips on Variable Names, Strings and Integers"
---

- [Webinars](http://www.finit.com/webinars)
- [Contact Us](http://www.finit.com/contact-us)
- [Blog](http://www.finit.com/finance-blog)

[![Finit](https://blog.finit.com/hubfs/Finit_December2018/images/finit_logo.png)](http://www.finit.com/)

- [Home](https://finit.com/)
- [Solutions](http://www.finit.com/solutions/financial-close-consolidation) 
    - [Close & Consolidation](http://www.finit.com/solutions/financial-close-consolidation)
    - [Planning, Budgeting & Forecasting](http://www.finit.com/solutions/Planning-Budgeting-Forecasting)
    - [Profitability & Management Reporting](http://www.finit.com/solutions/profitability-management-reporting)
    - [Data Integration](http://www.finit.com/solutions/infrastructure-integration)
    - [OneStream Solution Exchange](https://finit.com/solutions/) 
          - [AllocateIt](https://finit.com/allocateit/)
          - [DrillIt](https://finit.com/drillit/)
          - [ToolkIt](https://finit.com/toolkit/)
          - [Application Control Manager (RequestIt)](https://finit.com/services/requestit-a-complete-cfo-change-management-platform/)
- [Services](http://www.finit.com/services/oracle-hyperion-epm) 
    - [OneStream](http://www.finit.com/onestream-xf-cpm) 
          - [OneStream XF CPM](http://www.finit.com/onestream-xf-cpm)
          - [OneStream Services](http://www.finit.com/onestream-services)
          - [Application Control Manger (RequestIt)](https://finit.com/services/requestit-a-complete-cfo-change-management-platform/)
          - [ReportIt: Security](https://finit.com/reportitsecurity/)
    - [Service Areas](http://www.finit.com/services/service-areas)
    - [Approach](http://www.finit.com/services/approach) 
          - [Approach Overview](http://www.finit.com/services/approach)
          - [Implementation Methodology](http://www.finit.com/services/approach/implementation-methodology)
          - [Design Methodology](http://www.finit.com/services/approach/design-methodology)
- [Clients](http://www.finit.com/clients/client-list) 
    - [Client List](http://www.finit.com/clients/client-list) 
          - [OneStream Client List](http://www.finit.com/clients/onestream-client-list)
    - [Success Stories](http://www.finit.com/success-stories-0)
    - [Client Testimonials](https://info.finit.com/client-testimonials)
- [About](http://www.finit.com/about) 
    - [About Finit](https://info.finit.com/about-us)
    - [Finit Values](https://finit.com/about/finit-values/)
    - [Our Culture of Diversity](https://finit.com/about/our-culture-of-diversity/)
- [Careers](http://www.finit.com/careers/finit-experience) 
    - [The Finit Experience](http://www.finit.com/careers/finit-experience)
    - [The Finit Consultant](http://www.finit.com/careers/finit-consultant)
    - [Finit Employee Advocacy](http://www.finit.com/careers/finit-employee-advocacy)
    - [Career Opportunities](https://finit.com/careers/career-opportunites/)

# Blog

**HFM User:**

Do you have any tips on rules? I currently have some rules that are not running, and I don’t know why.

**Chris Barbieri:**

I’ve seen a few cases recently in which rules are not running because the variables that the conditions use are not handled properly.  I pulled together some design and troubleshooting tips to identify and understand these situations.  Additionally, using these techniques can simplify your application and reduce ongoing maintenance.

**Use structured variable naming**

I include an explanation like this at the top of each rules file.  It explains the prefix naming scheme I use, to help whoever is reading the rules file understand the purpose and meaning of each variable:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-1.png)

Here are variables that incorporate the above naming scheme.  I include this section at the top of the Sub Calculate.  In addition, I include a subset of these variables at the top of Sub Translate and Sub Consolidate.

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-2.png)

**Use Subroutines**

Here is an example of how I use these variables in a custom subroutine, from within Sub Calculate:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-3.png)

This shows the syntax for the custom subroutine that “receives” the variables:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-4.png)

The variables can be passed to the subroutine in any order, but they must be received in that same sequence.

**Notes on String comparisons**

String comparisons are case sensitive, so you must carefully match the upper and lower case characters of the entity, scenario, value members.  Alternatively, you can force the string to be all upper (or lower) case by using the UCASE (or LCASE) functions like this:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-5.png)

If you omit the quotation marks from around a string, vbscript may interpret it as a variable:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-6.png)

In this case, **JULFCST** is an undefined variable, so the contents of the variable **pov\_scenario** will be compared to a null (empty variable.)  Accordingly, this condition will never be True.  

The solution is to wrap the string in quotation marks so that HFM identifies it as a string:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-7.png)

**Switch between strings and integers**

Occasionally, I see a problem with a string that needs to be treated as if it were an integer.  The CINT function turns a string into an integer, which can then be used in arithmetic formulas.  For example, I may take the last two characters from the scenario’s label.  Let’s review how this condition would work for a scenario called **Forecast02**:

**sPeriod = Right(sPovScenario,2)**               ‘Note the variable starts with “s” indicating this is a string.  The result must be a string because sPovScenario is a string and I’m using a vbscript string to parse the string and return only the last two characters.

**If CINT(sPeriod) > 3 Then**                             ‘This converts the string “02” into an integer: 2

Alternatively, I could accomplish the same thing by storing the period number in a variable this way:

**iPeriod = CINT(Right(sPovScenario,2))**

**If iPeriod > 3 Then**

**Use Comments**

Make extensive use of comments!  Before I write or update any rule, I first write comments to explain what I’m doing and why.  Not only does this help me think through the rule, but it can help me later recall why I made the change in the first place.  Additionally, this context and explanation can be invaluable for someone else who is trying to understand the rule.

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-8.png)

In this situation, I walk the reader through the calculation step-by-step:

![](https://blog.finit.com/hubfs/Imported_Blog_Media/Tips-and-Tricks-9.png)

Lastly, it is very important to INDENT code and to use subroutines!  At some point, each of us has spent time troubleshooting rules and missed a condition from several hundred lines above our rules that still applies and prevents our particular rule from running.  Visual indentation can help immensely by quickly showing which conditions are still being used in specific sections of the rules file.  To make things even easier to read, I prefer to indent my comments to the same level as the rules and conditions to which they apply.

I hope that you enjoyed reading these rule-writing tips.  

Do you have an issue or topic that you’d like Chris to discuss in his next blog post?  Please e-mail us at [insights@finit.com](mailto:insights@finit.com?subject=Ask%20Our%20Ace%20&body=Ask%20Our%20Ace%20Question%3A%0ACompany%3A%0ATitle%3A%0ACompany%20Email%20Address%3A) and we will “Ask our ACE”!

 

Tags: [Uncategorized](https://blog.finit.com/tag/uncategorized)

Posted By:  jbulman

[ Prev post](https://blog.finit.com/2018/03/caution-usd-total-in-hfm)

[Next post ](https://blog.finit.com/2018/03/ask-our-ace-scalc-in-webforms-how-to-get-the-sum-of-a-row-that-is-a-list-of-items)

## Subscribe to our blog

Contact Us: [services@finit.com](mailto:services@finit.com)   
Subscribe: [subscribe@finit.com](mailto:subscribe@finit.com)   
**Finit Solutions, LLC** © Copyright 2016

<https://twitter.com/Finit_Solutions> <https://www.linkedin.com/company/finit-solutions> <https://www.youtube.com/channel/UCIweHOVZkPe_bD0Qyca_51A>

### Solutions

- [Close & Consolidation](http://www.finit.com/solutions/financial-close-consolidation)
- [Planning, Budgeting & Forecasting](http://www.finit.com/solutions/Planning-Budgeting-Forecasting)
- [Profitability & Management Reporting](http://www.finit.com/solutions/profitability-management-reporting)
- [Infrastructure & Integration](http://www.finit.com/solutions/infrastructure-integration)

### Services

- [Oracle Hyperion EPM](http://www.finit.com/services/oracle-hyperion-epm)
- [OneStream](http://www.finit.com/onestream-xf-cpm)
- [Service Areas](http://www.finit.com/services/service-areas)
- [Approach](http://www.finit.com/services/approach)

### Clients

- [Client List](http://www.finit.com/clients/client-list)
- [Success Stories](http://www.finit.com/success-stories-0)

### About

- [About Finit](http://www.finit.com/about)
- [The Finit Culture](http://www.finit.com/finit-culture)
- [The Finit Difference](http://www.finit.com/finit-difference)

### Careers

- [The Finit Experience](http://www.finit.com/careers/finit-experience)
- [The Finit Consultant](http://www.finit.com/careers/finit-consultant)
- [Finit Employee Advocacy](http://www.finit.com/careers/finit-employee-advocacy)