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
 Help: WorksheetPage program count/sort
 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 - 08/05/2020 :  11:11:47 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to find out how OriginLab sorts the used WorksheetPages.

I am programming Origin C and need a steady WksPages which do not change their count/sort number on every reboot of OriginLab.

I am initializing my WksPages like this “WorksheetPage book1 = Project.WorksheetPages(x);”. x is the WksPage count in the project. And these counts change around every second reboot of OriginLab which means I have to check if the WksPage objects are included to the right name every time.

Can anybody tell me “HOW” this count is done by OriginLab. I tried playing with the name of the WksPages (alphabetically, creation date) but I cannot find the pattern of the count/sort in the project.


Edited by - hschausb on 08/05/2020 11:51:41 AM

Castiel

343 Posts

Posted - 08/10/2020 :  07:01:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by hschausb

I am trying to find out how OriginLab sorts the used WorksheetPages.

I am programming Origin C and need a steady WksPages which do not change their count/sort number on every reboot of OriginLab.

I am initializing my WksPages like this “WorksheetPage book1 = Project.WorksheetPages(x);”. x is the WksPage count in the project. And these counts change around every second reboot of OriginLab which means I have to check if the WksPage objects are included to the right name every time.

Can anybody tell me “HOW” this count is done by OriginLab. I tried playing with the name of the WksPages (alphabetically, creation date) but I cannot find the pattern of the count/sort in the project.





It seems to be sorted so that the active WorksheetPage (from project saved latest) is returened from Project.WorksheetPages(x) with the x as large as possible.

The following code should give you the WorksheetPage's in a stable order:
foreach(WorksheetPage wp in Project.WorksheetPages){ /* your code */}



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

hschausb

18 Posts

Posted - 08/10/2020 :  11:44:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:


It seems to be sorted so that the active WorksheetPage (from project saved latest) is returened from Project.WorksheetPages(x) with the x as large as possible.

The following code should give you the WorksheetPage's in a stable order:
foreach(WorksheetPage wp in Project.WorksheetPages){ /* your code */}





Would you mind explaining why I should use a "foreach" if the code only runs through the first Worlpage?
Also I do not understand how this sets up a static worksheet count? Which comand is it that does that?
And the last question. I am working with self made functions and everything. What is supposed to go into the "your code" part? The main programm with all sub functions? Only the main programm? Should this be in the main programm included during the inclusion of the WorksheetPages and Worksheets?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 08/10/2020 :  12:42:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Maybe you can explain a bit more on what you are trying to do? Why do you need to write code based on some count? Why not use name which is more reliable and self-explanatory?

CP
Go to Top of Page

Castiel

343 Posts

Posted - 08/10/2020 :  8:54:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by hschausb

quote:


It seems to be sorted so that the active WorksheetPage (from project saved latest) is returened from Project.WorksheetPages(x) with the x as large as possible.

The following code should give you the WorksheetPage's in a stable order:
foreach(WorksheetPage wp in Project.WorksheetPages){ /* your code */}





Would you mind explaining why I should use a "foreach" if the code only runs through the first Worlpage?
Also I do not understand how this sets up a static worksheet count? Which comand is it that does that?
And the last question. I am working with self made functions and everything. What is supposed to go into the "your code" part? The main programm with all sub functions? Only the main programm? Should this be in the main programm included during the inclusion of the WorksheetPages and Worksheets?



That code returns WorksheetPage s in stable order.Your code can be any code, for example, caching the orders.

Maybe you should follow cpyang's post, using the names of WorksheetPage s makes sense.


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

hschausb

18 Posts

Posted - 08/11/2020 :  03:27:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

Maybe you can explain a bit more on what you are trying to do? Why do you need to write code based on some count? Why not use name which is more reliable and self-explanatory?

CP




I am new to Origin C and there is a high possibility that I have missed this, so bear with me.
IT IS POSSIBLE TO INCLUDE WORKSHEETS BASED ON NAME??? I have looked for 2 hours and could not find a way to include worksheets based on their name. I also could not find a way to check if there is any Worksheet with a specific name already existing (Object.Exist is not the right thing; at least for Origin C).
If you have a way, pleas, please, pretty please tell me. You would be my hero.

quote:
Originally posted by Castiel

It seems to be sorted so that the active WorksheetPage (from project saved latest) is returened from Project.WorksheetPages(x) with the x as large as possible.

The following code should give you the WorksheetPage's in a stable order:
foreach(WorksheetPage wp in Project.WorksheetPages){ /* your code */}



Why would I use the “Active Worksheet” if this changes depending on which Worksheet I am working on?

Edited by - hschausb on 08/11/2020 03:29:22 AM
Go to Top of Page

Castiel

343 Posts

Posted - 08/11/2020 :  06:11:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by hschausb

quote:
Originally posted by cpyang

Maybe you can explain a bit more on what you are trying to do? Why do you need to write code based on some count? Why not use name which is more reliable and self-explanatory?

CP




I am new to Origin C and there is a high possibility that I have missed this, so bear with me.
IT IS POSSIBLE TO INCLUDE WORKSHEETS BASED ON NAME??? I have looked for 2 hours and could not find a way to include worksheets based on their name. I also could not find a way to check if there is any Worksheet with a specific name already existing (Object.Exist is not the right thing; at least for Origin C).
If you have a way, pleas, please, pretty please tell me. You would be my hero.

quote:
Originally posted by Castiel

It seems to be sorted so that the active WorksheetPage (from project saved latest) is returened from Project.WorksheetPages(x) with the x as large as possible.

The following code should give you the WorksheetPage's in a stable order:
foreach(WorksheetPage wp in Project.WorksheetPages){ /* your code */}



Why would I use the “Active Worksheet” if this changes depending on which Worksheet I am working on?




"Active WorksheetPage" explains why your got different WorksheetPage with identical "x" in Project.WorksheetPages(x).
How x and WorksheetPage are connected could be a little complicated for beginners. Never mind since rarely will one have to care about it.

To get a WorksheetPage by name:
WorksheetPage wp("Book1");


To get a Worksheet by name:
Worksheet wks("[Book1]Sheet1");


See the constructors of WorksheetPage and Worksheet:
https://www.originlab.com/doc/OriginC/ref/WorksheetPage-WorksheetPage
https://www.originlab.com/doc/OriginC/ref/Worksheet-Worksheet


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

hschausb

18 Posts

Posted - 08/12/2020 :  07:21:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Castiel

To get a WorksheetPage by name:
WorksheetPage wp("Book1");


To get a Worksheet by name:
Worksheet wks("[Book1]Sheet1");


See the constructors of WorksheetPage and Worksheet:
https://www.originlab.com/doc/OriginC/ref/WorksheetPage-WorksheetPage
https://www.originlab.com/doc/OriginC/ref/Worksheet-Worksheet





You are my hero. Thank you very much.
Go to Top of Page

hschausb

18 Posts

Posted - 08/18/2020 :  06:07:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can somebody please delete this post.
I cannot delete it even as the orginal author.
Thank you very much.
Go to Top of Page

Castiel

343 Posts

Posted - 08/18/2020 :  06:29:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by hschausb

Can somebody please delete this post.
I cannot delete it even as the orginal author.
Thank you very much.



Deleting the topic would delete the replies from others, including me.

I'm uncomfortable with that.

Maybe you can just delete/edit yours.


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
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