Author |
|
pingmustard Newbie
Joined: September 13 2010
Online Status: Offline Posts: 18
|
Posted: October 22 2012 at 02:51 | IP Logged
|
|
|
Could someone tell me why this doesn't create a message of true or 1? Running this in multi editor shows a msgbox with blank instead.
ph_msgbox("mo", string( 1=1 ), 5)
Thanks!
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: October 22 2012 at 07:28 | IP Logged
|
|
|
String returns a null string if the format of string data is not valid. 1=1 is not valid string data nor one of the other listed types such as Date, DateTime, etc.
To display the result of an If operation use the following as a guide
ph_msgbox("mo", string(if(1=1,"true","false")), 5)
Edited by grif091 - October 22 2012 at 07:35
__________________ Lee G
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 22 2012 at 12:57 | IP Logged
|
|
|
PH supports booleans and boolean logic and arithmetic are integral to the inner workings. Theres just no conversion from boolean to string unless you use an if statement or similar like Lee suggested.
The inner workings of PowerHome are based upon its native language PowerBuilder and what is supported there. I have vastly extended the built in language support with the ph_ functions but the problem with these functions (PowerBuilder global functions actually) is that there is no option for overloading. The string function is an internal function that obviously doesnt support converting a boolean to a string. I could write a replacement "string" function as a ph_string function but without overloading, I would have to create a different function for each possible datatype. Probably not the best solution.
Hope this helps,
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 22 2012 at 19:45 | IP Logged
|
|
|
Just wanted to post a followup on this.
I performed a number of tests and the environment does not allow me to pass a boolean to ANY function. Even if I declare the function parameter as a boolean datatype. No matter what, it eventually ended up in PH crashing and the strange thing is the environment wouldnt even allow me to trap the runtime error.
I was able to come up with a workaround though:
ph_msgbox("mo",ph_formula("1=1"),5)
In this case, the boolean is contained in a string (so is not passed as a function argument as a boolean). The ph_formula function evaluates the formula, it evaluates to a boolean and internally, the result is converted to a string. This string will be either "true" or "false" and this string value is passed to the ph_msgbox function. So we skirted the issue by never passing a boolean as an argument to a ph_xxx function.
Dave.
|
Back to Top |
|
|
pingmustard Newbie
Joined: September 13 2010
Online Status: Offline Posts: 18
|
Posted: October 23 2012 at 23:42 | IP Logged
|
|
|
Quite an interesting behavior. Thank you all for clarifying :) I'll try work around the situation for now.
|
Back to Top |
|
|