The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Cleaning up code - help me
12-15-2015, 05:57 AM
Post: #1
Cleaning up code - help me
Hi,
I have static INPUT code, which looks like this:
Code:
EXPORT testinput()
BEGIN
INPUT({{L3(1),[0],{40,10,1}},{L4(1),[0],{60,10,1}},
{L3(2),[0],{40,10,2}},{L4(2),[0],{60,10,2}}},
"Variable domains",
{"'A' is FROM ","TO ",
"'B' is FROM ","TO "},
{"Lower limit for 'A'",
"Upper limit for 'A'",
"Lower limit for 'B'",
"Upper limit for 'B'"});
END;

But number of fields is dependent on previous user's input, so I wrote this:
Code:
Loop;
Temp;
Temp1;
Temp2;
EXPORT testinput2()
BEGIN
Temp:="INPUT({";
Temp1:="";
Temp2:="";
FOR Loop FROM 1 TO SIZE(L2) DO
 Temp:=Temp+"{L3("+Loop+"),[0],{40,10,"+Loop+"}},{L4("+Loop+"),[0],{60,10,"+Loop+"}}";
 IFTE(Loop<SIZE(L2),Temp:=Temp+",",Temp:=Temp+"}");
 Temp1:=Temp1+STRING("'"+L2(Loop)+"' is FROM ")+","+STRING("TO ");
 IFTE(Loop<SIZE(L2),Temp1:=Temp1+",",Temp1:=Temp1+"},");
 Temp2:=Temp2+STRING("Lower limit for '"+L2(Loop)+"'")+","+STRING("Upper limit for '"+L2(Loop)+"'");
 IFTE(Loop<SIZE(L2),Temp2:=Temp2+",",Temp2:=Temp2+"})");
END;
Temp1:="{"+Temp1;
Temp2:="{"+Temp2;
Temp:=Temp+","+STRING("Variable domains")+","+Temp1+Temp2;
EXPR(Temp);
END;

Please, is there other way how to make dynamic input than this almost unreadable code?
   

Prime G2, 15C CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Cleaning up code - help me - chromos - 12-15-2015 05:57 AM
RE: Cleaning up code - help me - chromos - 12-17-2015, 06:25 AM



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