Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:38:16+00:00 2026-06-12T10:38:16+00:00

I have noticed a very odd behaviour with an IF-statement in Progress 4gl. I

  • 0

I have noticed a very odd behaviour with an IF-statement in Progress 4gl.

I define an integer with the format “999” which tells it to have 3 digits and then I assign a value lower than 100 (eg. 12) then when I display it it shows as “012” as it should.

But when I add an IF-statement inside the DISPLAY statement that really shouldn’t do anything, the variable is displayed as “12”.

This is a test code to clearify the differences. The LABEL doesn’t affect the output of the variable.

DEF VAR tmp AS INTEGER FORMAT "999".
ASSIGN tmp = 12.

DISPLAY 
    tmp LABEL "disp1".

DISPLAY
    IF TRUE THEN tmp ELSE tmp LABEL "disp2".

The same behaviour could also be acheived by changing the format to “>99”.

My question is: Why does an IF-statement change the way a variable is displayed?

Best regards
//MrBucket

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:38:17+00:00Added an answer on June 12, 2026 at 10:38 am

    Your second example is similar to:

    define variable tmp1 as integer no-undo format "999".
    define variable tmp2 as integer no-undo format "99999".
    
    display
      if true then tmp1 else tmp2
    .
    

    The compiler sees the IF function returns an integer and applies the default formatting for an integer. The compiler does not try to second guess you and notice that (in your example) both results are the same variable.

    (In this case IF is a function embedded within the DISPLAY — not a stand-alone statement of it’s own.)

    To get the result you are looking for:

    display
      ( if true then tmp1 else tmp2 ) format "999"
    .
    

    Whenever I embed an IF function I make a point of wrapping it in parenthesis — it helps make it clear that it is embedded and clearly shows where things like a FORMAT phrase apply.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just noticed a very odd behaviour with VS2010. At some point since install,
I have switched on the Codeigniter profile (very useful) and I have noticed that
I have noticed that it is possible to define a custom class and then
I noticed something odd today. I have an application that writes/read data to a
I have very odd problem and I don't know how to get rid of
I have noticed that my site in Cakephp is very very slow. I have
In my app I have noticed that it goes very slow when switching between
I have noticed that in my application, CreateProcessWithTokenW sometimes blocks for a very long
On Railcasts I have noticed a very interesting feature 'Go to symbol' window. It
We have noticed that MySQL is reporting a very high number of temporary disk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.