Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: space(0) returns a single space Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 09 2010 at 17:36 | IP Logged Quote MrGibbage

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 View MrGibbage's Profile Search for other posts by MrGibbage
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: April 10 2010 at 04:13 | IP Logged Quote grif091

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 View grif091's Profile Search for other posts by grif091
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 10 2010 at 06:38 | IP Logged Quote MrGibbage

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 View MrGibbage's Profile Search for other posts by MrGibbage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: April 10 2010 at 08:40 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 17 2010 at 16:59 | IP Logged Quote dhoward

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 View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 17 2010 at 17:47 | IP Logged Quote MrGibbage

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 View MrGibbage's Profile Search for other posts by MrGibbage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum