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
 How to Convert String to Integer?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Eberhard2010

8 Posts

Posted - 04/12/2009 :  03:29:56 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8SR0
Operating System:WINXP Pro SP3

Hi,

My import filenames will be set as comments in the column. The data is already imported. I found a way to seperate 73 from G02N02_73K_1.dat
But I ve two more problems. How to Get the comment with wcol()? wcol(2).comment$ doesn't work anyway. How to Convert the String to int? Perhaps its a simple thing but I haven't found it.

My Code so far:

[Main]

string strbk$ = %H;
string strSh$ =;

range wks = [strBk$]strSh$!; //This is the sheet range

p=2;
for(;p<=wks.ncols;){

range cc=[strBk$]strSh$!wcol(p); //Set a new col range
string Temp$=cc.comment$; //Hole den Comment aus der Spalte
Temp=%[%[Temp, >'_'],'K']; //Extrahieren von 73 aus G02N02_73K_1.dat
int temp=273.14; //Konvertierung von String nach Int
wcol(p)/=(temp*temp);
p+=1;
};

type("done I/T");



Sincerely Eberhard

vincenth

30 Posts

Posted - 04/13/2009 :  11:36:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Problem #1 --- Extracting the comment from a column

In order to extract the comment from a specific data column, make use of the system variable "C", which stores the row index of the comment field for the column. For example, replace this line of code:

string Temp$ = cc.comments$

with the following line:

string Temp$ = cc[C]$

But there is one more problem! (see below)

Problem #2 --- Converting string to int

The code, as it is written, assigns a new variable of type 'int' the value '273.14'. Variables with the same name but different variable types can exist simultaneously, so there is no conversion issue that I see here.

There is, however, one more problem. The following notation:

%[Temp, >'_']

does not work (according to my tests) with a declared string variable. The string value must be evaluated using the %(stringToEvaluate) notation.

So, I recommend changing two lines of code to fix both problems as I understand them. Replace these two lines:

string Temp$=cc.comment$;
Temp=%[%[Temp, >'_'],'K'];

With this line:

// cc[C] contains the string "G02N02_73K_1.dat"
// temperature will get the value 73
int temperature = %[%[%(cc[C]$), >'_'],'K'];


Regards,
Vince H

Edited by - vincenth on 04/13/2009 5:28:00 PM
Go to Top of Page

Eberhard2010

8 Posts

Posted - 04/13/2009 :  5:51:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi vincent,

many thanks to You. I get it to work. yeah. I'm so happy.
With your help. I modified the code as follows:

[Main]

string strBk$ = %H;
string strSh$ =;

range wks = [strBk$]strSh$!; //This is the sheet range

p=2;
for(;p<=wks.ncols;){

range cc=[strBk$]strSh$!wcol(p); //Set a new range
%A=cc[C]$; //Get the Column Comment

%A=%[%[%A, >'_'],'k']; //Extract the Temp 73 out of G02N02_73k_1.dat

//type "%A";
wcol(p)/=(%A * %A);

p+=1;
};

type("done I/T");

Problem #1
Thanks your help works very well!

Problem #2
This problem solved it self cause %A is either a string variable. But it can also be used to calculate column values.

Happy Easter!

Regards Eberhard

Edited by - Eberhard2010 on 04/13/2009 5:53:40 PM
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