Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Simple Logical Operator / Bool Question Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
pingmustard
Newbie
Newbie


Joined: September 13 2010
Online Status: Offline
Posts: 18
Posted: October 22 2012 at 02:51 | IP Logged Quote pingmustard

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


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: October 22 2012 at 07:28 | IP Logged Quote grif091

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

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: October 22 2012 at 12:57 | IP Logged Quote dhoward

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

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: October 22 2012 at 19:45 | IP Logged Quote dhoward

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 View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
pingmustard
Newbie
Newbie


Joined: September 13 2010
Online Status: Offline
Posts: 18
Posted: October 23 2012 at 23:42 | IP Logged Quote pingmustard

Quite an interesting behavior.   Thank you all for clarifying :) I'll try work around the situation for now.
Back to Top View pingmustard's Profile Search for other posts by pingmustard
 

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