randallf Posted January 26, 2009 Report Share Posted January 26, 2009 Hello, I am working with functions that use integer variables to store a number of hours or minutes and short of using "if mintues variable called > 9 text type 0" every time I want to call the minutes integer, how can I force it to keep the number as "02" instead of just "2"? Would I be forced to use a string? What a pain! Thanks! Quote Link to comment Share on other sites More sharing options...
stevecasper Posted January 26, 2009 Report Share Posted January 26, 2009 Hello, I am working with functions that use integer variables to store a number of hours or minutes and short of using "if mintues variable called > 9 text type 0" every time I want to call the minutes integer, how can I force it to keep the number as "02" instead of just "2"? Would I be forced to use a string? What a pain! Thanks! It really isn't that much of a problem to code this. If I understand what you're trying to do, you're saving the hours or minutes to an Integer variable that you are then using the Text Type command to type it out, and you want to avoid having code that types 0 before typing %N1% (or whichever integer variable you're using). Unfortunately, integer variables can't have leading zeroes, so you'll either need code that says, as you indicated: If %N1% <= 9 Text Type 0%N1% Else Text Type %N1%. End if As is, this should work fine and not be a problem; however, depending on what exactly you are trying to accomplish, or depending on the particular needs of your macro, you might want to convert the %N% variable into a %T% variable as I've done below (this is more complicated than the simple If/Then from up above, but it is also a little more versatile - and provides the same results): Variable Set Integer %N1% to 2 Variable Set Integer %N1% from Prompt Variable Modify Integer: Convert %N1% to text string %T1% If Variable %N1% <= 9 Variable Set String %T2% "0" Variable Modify String: Append %T1% to %T2% Variable Set String %T1% "%T2%" End If Text Box Display: T1 <IVAR2:01:01:2><IVAR2:01:02:FEnter ValueFFCenter:Center><NMVAR:05:01:0:0000001:0:0000000><IFVAR2:2:01:6:9><TVAR2:02:01:0><TMVAR2:08:02:01:000:000:><TVAR2:01:01:%T2%><ENDIF><TBOX4:T:1:CenterCenter000278000200:000:T1%T1%> Of course, in lieu of the Text Box Display that I used, you'll want to use Text Type %T1% Quote Link to comment Share on other sites More sharing options...
randallf Posted January 26, 2009 Author Report Share Posted January 26, 2009 Well really I discovered there are only a few places that I need it so it is easier to <10 and type a leading zero Text Type: %N2%: :P If Variable %N4% < 10 Text Type: 0 End If Text Type: %N4% %T2% But thank you for the great reply, it's great to know more about ME in this area! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.