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
 LabTalk Forum
 String array population by workbook name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 07/25/2022 :  8:27:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Win10

Hello,

I have many workbooks separated into 2 types of short name: the first starts with an At, the second starts with an Ox.

I would like to create 2 different string arrays: one for At workbook names, and another for Ox.

To test my code, I created a project with 1 At workbook and 1 Ox workbook only. I have tried the following:
doc -e W
{
	string sName$ = page.name$; //Example: A550C360d0p5z
	string sNameAt$;
	string sNameOx$;
	
	if (Left(sName$,1)$ == "A")	sNameAt$ = sName$;
	if (Left(sName$,1)$ == "O")	 sNameOx$ = sName$;
	
	ArrSampAt.Add(sNameAt$);
	ArrSampOx.Add(sNameOx$);
}


What I got was: both arrays had 2 entries: one empty, and the other one with the correct name.

Why is this happening?

Is there a simpler way to achieve this? I thought it might be simpler to collect all workbook names in an array to later separate them in two groups, so that Origin would only work with text entries instead of looping through books (which should be easier?), but I can't seem to make it work. Maybe I am overthinking.

aplotnikov

Germany
170 Posts

Posted - 07/26/2022 :  01:09:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
doc -e W
{
	string sName$ = page.name$; //Example: A550C360d0p5z
	
	if (Left(sName$,1)$ == "A") {
		ArrSampAt.Add(sName$);
	} else {
		if (Left(sName$,1)$ == "O") {
			ArrSampOx.Add(sName$);
		}
	}
}


Instead of many workbooks with complicated names you may use a single large workbook with a column containing corresponding workbook IDs. In this case you can apply column filtering (e.g., to select data with certain ID) that works fast. Moreover it may simplify further data processing and/or data scrolling for interactive data analysis. A certain increase of data size seems to be a reasonable compromise for convenience.

MfG

Alexei

Edited by - aplotnikov on 07/26/2022 01:11:11 AM
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 07/29/2022 :  10:42:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Than you, it worked!

While your suggestion is a really good idea, right now I don't have the time to study its implementation. I'll go back to it whenever I need to do something similar again.
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