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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How to Convert String to Integer?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Eberhard2010 Posted - 04/12/2009 : 03:29:56 AM
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
2   L A T E S T    R E P L I E S    (Newest First)
Eberhard2010 Posted - 04/13/2009 : 5:51:49 PM
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
vincenth Posted - 04/13/2009 : 11:36:12 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000