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
 New line in Worksheet comment section.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hschausb

18 Posts

Posted - 01/17/2021 :  07:33:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2020b
Operating System: Win 10

Hello fellow programmers.
How does one set a \n inside the comment section of a Worksheet?
If I want to save a string inside the comment section of my worksheet all characters are lined behind each other without acknowledging the presence of “\n” and therefore no new line.
Is it possible to set a new line in the comment section?

My programm looks like this.

WorksheetPage test = Project.WorksheetPages("Book1");
Worksheet wks = test.Layers(0);
char str[] = 
 “Buddy, you're a boy, make a big noise\n
 Playing in the street, gonna be a big man someday\n
 You got mud on your face, you big disgrace\n
 Kicking your can all over the place, singin'\n
 We will, we will rock you\n
 We will, we will rock you\n”
;

test.SetComment(str);
}

Output:
Buddy, you're a boy, make a big noise Playing in the street, gonna be a big man someday You got mud on your face, you big disgrace Kicking your can all over the place, singin' We will, we will rock you We will, we will rock you


You get the idea how it should be presented at the initiation. This is a representative example and not my real program.

So again: Is it possible to set a new line in the comment section?


Edited by - hschausb on 01/17/2021 08:45:50 AM

cpyang

USA
1406 Posts

Posted - 01/17/2021 :  3:51:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin use "\r\n" for new line, so add the CR character, or replace like the following:

WorksheetPage test = Project.WorksheetPages("Book1");
string str= 
 "Buddy, you're a boy, make a big noise\n"
 "Playing in the street, gonna be a big man someday\n"
 "You got mud on your face, you big disgrace"
 "Kicking your can all over the place, singin'\n"
 "We will, we will rock you\n"
 "We will, we will rock you\n"
;
str.Replace("\n", "\r\n");
test.SetComments(str);


Assuming you have no issue with using string instead of char [].

CP
Go to Top of Page

hschausb

18 Posts

Posted - 01/18/2021 :  11:57:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much CPYANG. It works fine now.

quote:

Assuming you have no issue with using string instead of char [].



Actually, yes I do. I am using a char due to the fact that a string cannot function with most “strcat” methods. The string is gradually build together over time via the “strcat” and some “strcpy” methods. And I cannot concatenate a string onto/after a string. I have to use char in the form of a sting to use these commands.

I do not know if it is due to a missing NULL terminal in the string or due to the fact, that a string cannot change its size after first initialisation (I am assuming this). But it does not work with “string” data types. Wasted a couple of hours finding this out.

Anyway. Thanks again.
.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/18/2021 :  3:09:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
string should be much easier and no need to use strcat, strcpy, like

string str="abc";
string str1="efg";
str += " ";
str += str1;



and strcpy you just make assigment

str1 = str;


CP
Go to Top of Page

hschausb

18 Posts

Posted - 01/18/2021 :  4:28:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Oh no. It would have been so easy.
Well. Today I learned.

Thanks again. Helped alot.
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