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
 copy notes into label
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OndrejMM

Australia
81 Posts

Posted - 10/24/2010 :  10:40:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi guys, how can i modify the following script that in copies notes into a label on a graph page instead of layout? thanks, ondrej

////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.
void Notes2Label(string sNotes)
{
Note noteWin(sNotes);
if( !noteWin ) return;
Layout lay = Project.ActiveLayer();
if( !lay ) return;
string str = noteWin.Text;
GraphObject go = lay.GraphObjects("Notes");
if( !go )
{
lay.LT_execute("label -s -sa -n Notes Text");
go = lay.GraphObjects("Notes");
}
go.Text = str;
}

Penn

China
644 Posts

Posted - 10/25/2010 :  02:34:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ondrej,

You can just use the GraphLayer instead of Layout.

// Layout lay = Project.ActiveLayer();
GraphLayer lay = Project.ActiveLayer();


Penn
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/25/2010 :  6:16:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi Penn, i've modified the script, but it still doesn't work,... here is my modification:

void NotesToLabel(string sNotes)
{
Note noteWin(sNotes);
if( !noteWin ) return;
GraphLayer lay = Project.ActiveLayer();
if( !lay ) return;
string str = noteWin.Text;
GraphObject go = lay.GraphObjects("xxx");
if( !go )
{
lay.LT_execute("label -s -sa -n Notes Text");
go = lay.GraphObjects("xxx");
}
go.Text = str;
}


i then compiled the script and added to the project, then I've tried to run as follows (there is already label with name 'xxx':

win -o TTTCCTgraph1 {
NotesToLabel(note.txt); //copy note text to label
doc -uw; //refresh
};



Go to Top of Page

Penn

China
644 Posts

Posted - 10/26/2010 :  01:35:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ondrej,

It works fine on my computer. I just follow the steps below:

1. create a new project, and then add a new graph and a new note window to the project.
2. rename the note window with "note.txt" and type some words in this new note window.
3. rename the graph with "TTTCCTgraph1" and add a text label to this graph, then rename the text label as "xxx", and displayed text is "aaa".
4. open the Code Builder and create a new .c file, copy the function code to this new file and compile it.
5. in the Script Window, run your script.

Then I can see that the displayed text is replaced by the word in the note window.

I see that the note window name is "note.txt", so, I wonder if you want to read the text from a text document, but not from the note window. If so, you can refer to File IO functions to read text in a file.

Penn
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/26/2010 :  02:08:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
yes, it works, sorry, i'm being stupid,...
thanks, ondrej
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