Post Reply 
HP PPL compiler big, nasty, hairy, smelly, creapy BUG!
01-10-2014, 03:25 PM (This post was last modified: 01-10-2014 03:31 PM by Han.)
Post: #4
RE: HP PPL compiler big, nasty, hairy, smelly, creapy BUG!
There is no bug. The problem was that you never initialized varptr so it defaulted to a real type. Then, when you entered in the name SYMBOL1 without double quotes, the program used the value of SYMBOL1, which was zero as it too was not initialized. Thus, when it executed EXPR(varptr + ":=" + var1) what it was executing was essentially the command: 0:="why" -- which is why you are getting the error. On the other hand if you used double quotes around SYMBOL1 then the INPUT() complains about invalid types.

Please pay careful attention to what I wrote earlier in the other thread (not sure why you needed to start a new one): "...type G for the varname (no need for double quotes since varptr was initialized to be a string)" Since you did not initialize your pointer variable to a string (even an empty one), this is the issue.

Code:

export SYMBOL1;

export indir()
begin
  local varptr="", var1=""; // noticed that both are initialized to an empty string

  input(varptr,"Variable name","Varname=","Enter the var name", "A");
  input(var1,"Variable value",varptr + "=","Enter the value to save",var1);
  if TYPE(var1)==2 then var1:=STRING(var1); end; // ensure double quotes for var1 preserved
  expr(varptr + ":=" + var1);
end;

NOTE: INPUT() generally expects the user's input for varptr (and var1) to be of the same type as varptr (and respectively var1) just prior to executing. That is, if var1 is a real number, INPUT() will expect the user to enter a real number. This is why we pre-initialize the variables to empty strings. If you decide that strings are not what you want, you can change the type prior to running INPUT() by simply using a dummy value (e.g. var1:=0 if you want a numeric value).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP PPL compiler big, nasty, hairy, smelly, creapy BUG! - Han - 01-10-2014 03:25 PM



User(s) browsing this thread: 1 Guest(s)