Author |
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: April 09 2010 at 17:36 | IP Logged
|
|
|
I think I found a bug. space(0) returns a single space (bad), as does space(1) (good). I think
space(0) should return "". Also, PH consistently crashes (on my computer anyway) if I pass it a
negative number. 100% reproducible.
Finally, is there a max(n1, n2) and min(n1, n2) function? I was sure I saw one in here, but now I
can't find it.
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: April 10 2010 at 04:13 | IP Logged
|
|
|
There have been some issues with negative numbers. Putting a space around the dash ( , - 50 ) may help. Dave has negative number processing on his list of things being changed in the upcoming beta.
__________________ Lee G
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: April 10 2010 at 06:38 | IP Logged
|
|
|
Unfortunately I am calculating that number based on the length of a string and subtracting it from the length of the display.
If PH calculates that as a negative number (because my string was too long for the display) and stores that internally,
that's what I was passing to the space() function. I was using the space function to calculate how many spaces to add at the
front of the string to center it in the display. If the string is too long, I shouldn't be adding any spaces at all. I
thought the space() function itself would handle the negative numbers and zeroes. I have now modified my code to do that
checking myself.
By the way, when I said passing the space function caused PH to crash, I mean completely crash. You have to completely close
and restart PH after passing space(-1).
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: April 10 2010 at 08:40 | IP Logged
|
|
|
That all makes sense. There is no internal check for a negative number. You might want to post this on Bug Reports.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 17 2010 at 16:59 | IP Logged
|
|
|
Ive checked into this and all is confirmed. In the current 2.1b version, a negative number will crash PowerHome, but this is not a result of the negative number bug. Since the "space" function is an internal function (part of the PowerBuilder programming language and not a "PowerHome" specific function...they all start ph_), I have no control over how it functions or is processed. I can create a PowerHome function such as ph_space with different functionality however.
On the latest beta, I have confirmed that Sybase (the creators of PowerBuilder) have fixed the negative number crashing the "space" function bug. However, the default functionality of the space function is that it will always return at least a single space (negative numbers, space(0) and space(1) all return a single space) and I cant change it.
A current workaround for the crashing and a more desireable result for what you're trying to achieve is another internal function called "fill". fill(" ",1) will return a single space. fill(" ",0) will return an empty string. fill(" ",-1) will not crash but will return a null string (probably not what you want because the output of this will cause the entire formula to be null).
Probably the best way to handle this is to create a new PowerHome function called ph_fill (rather than a more limited ph_space) that will treat negative numbers the same as 0.
Dave.
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: April 17 2010 at 17:47 | IP Logged
|
|
|
Wow, what a mess. But it makes me happy that you are responsive to these buggies and making sure that we,
your customers, are updated on the status and given good work-arounds.
|
Back to Top |
|
|