The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Problenm with LT_set/get_var
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rlewis

Canada
253 Posts

Posted - 04/25/2006 :  5:18:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Pro7.5_SR6:
Operating System: Win-XP
The following OriginC function is intended to make some fine adjutments on line objects drawn on a graphpage.However when implemented as shown below, the LT_get_var and LT_set_var functions both return true but do NOT set or get the variables concerned. Is this a bug or am I missing something ??

 
bool Adjust_Lines()
{
GraphPage gP=Project.GraphPages(-1);
GraphLayer gL=gP.Layers();
if(gL.IsValid()==true)
{
foreach (GraphObject gO in gL.GraphObjects)
{
if(gO.GetObjectType().CompareNoCase("Line")==0)
{
double Value;
string strLine=gO.GetName();
string strLTvar=strLine;
strLTvar+=".x1";
if(LT_get_var(strLine,&Value)==false) return (false);
Value=nint(Value);
if(LT_get_var(strLine,&Value)==false) return (false);
strLTvar=strLine;
strLTvar+=".x2";
if(LT_get_var(strLine,&Value)==false) return (false);
Value=nint(Value);
if(LT_get_var(strLine,&Value)==false) return (false);
strLTvar=strLine;
strLTvar+=".y1";
if(LT_get_var(strLine,&Value)==false) return (false);
Value=nint(Value);
if(LT_get_var(strLine,&Value)==false) return (false);
strLTvar=strLine;
strLTvar+=".y2";
if(LT_get_var(strLine,&Value)==false) return (false);
Value=nint(Value);
if(LT_set_var(strLine,Value)==false) return (false);
}
}
return (true);
}
return (false);
}

Mike Buess

USA
3037 Posts

Posted - 04/25/2006 :  6:20:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Object.X1|X2|Y1|Y2 are read-only properties. Try this from the script window with a single rectangle in the graph layer...

Rect.x1=;
RECT.X1=some_value
Rect.x1=some_other_value;

RECT.X1 is an illegal name for defining a variable. It must not start...
#Command Error!

To position the left and right sides of the rectangle you must use Rect.X (center) and Rect.DX (width) which can be cumbersome but you don't need LabTalk because corresponding OC properties (gO.X and gO.DX) exist.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/25/2006 6:26:21 PM
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 04/25/2006 :  8:47:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That’s not the problem Mike …
The function is designed to work on line objects (Note the “if(gO.GetObjectType().CompareNoCase("Line")==0)test) for which there is read/write access to Object.x1/y1/x2/y2. After some more testing the problem seems to be ..

LT_get_var(“Line11.y1”,&Value); // Works if the Line object “Line11” exists.

However ..

string strVar=”Line11.y1”;
LT_get_var(strVar,&Value);// Fails …
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/25/2006 :  10:08:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, I missed that crucial if. However, I can't exactly reproduce your problem with Line objects. I drew a line on a graph layer and named it Line11. The first time I ran the following test() function it returned Line11.Y1=7.64571 but on subsequent runs it returned Line11.Y1=7.99885. The new value is admittedly not an exact integer but the placement is as accurate as I have ever been able to achieve with graph objects.
void test()
{
GraphPage gP=Project.GraphPages(-1);
GraphLayer gL=gP.Layers();
double dVal;
string str;
foreach (GraphObject gO in gL.GraphObjects)
{
if( gO.GetObjectType().CompareNoCase("Line")==0 )
{
str = gO.GetName() + ".Y1";
LT_get_var(str,&dVal);
out_double(str + "=",dVal);
LT_set_var(str,nint(dVal));
}
}
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/25/2006 10:17:46 PM
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 04/25/2006 :  11:42:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I retested the OC function on my home computer and it now works as designed .... Go Figure ...
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000