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
 string case problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

asteria

USA
Posts

Posted - 10/05/2006 :  1:25:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: XP Home

In Origin C, it seems that it can not keep the case of the input. It always change it to upcase. For example, in OriginC:
int test(string sWks)
{ printf("sWks' name is:%s\n", sWks);
return 1;}
Afer compiling, I use this function in script window:
test("d")=
It always gives:
sWks' name is:D // note D, insted of d
TESTD("D")=1

How to solve this?

rlewis

Canada
253 Posts

Posted - 10/05/2006 :  2:25:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
After compiling asteria's test code I also noticed the following ...

test(CCcc);
sWks' name is:CCcc

test(CCcc)=;
sWks' name is:CCCC
TEST(CCCC)=1

test("CCcc")=;
sWks' name is:CCCC
TEST("CCCC")=1

test("CCcc");
sWks' name is:CCcc
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/06/2006 :  07:51:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Literal strings are often converted to upper case when passed from LabTalk to Origin C. Passing the string as a letter variable is no better...

%A=d;
test(%A)=;
sWks' name is:D
TEST(d)=1

The solution is to use Origin 7.5's new $ string variable...

strVar$=d;
test(strVar$)=;
sWks' name is:d
TEST(STRVAR$)=1;

See the Programming Guide for more about $ string variables.
LabTalk Language Reference > Overview... > Data Types > String Variables

...Note that a letter string variable will work if you use LT_get_str to get its value.

int test2(string strLetter)
{
char chBuffer[16];
LT_get_str("%" + strLetter, chBuffer, 16);
printf("sWks' name is:%s\n", chBuffer);
return 1;
}

%A=d;
test2(A)=;
sWks' name is:d
TEST2(A)=1

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/06/2006 08:35:42 AM

Edited by - Mike Buess on 10/06/2006 08:44:20 AM
Go to Top of Page

asteria

USA
Posts

Posted - 10/06/2006 :  12:58:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
What Mike said is right.
I did further test. It seems the return type of the OC function is related.

void test1(string sWks)
{
printf("test1 sWks is:%s\n", sWks);
}
int test2(string sWks)
{
printf("test2 sWks is:%s\n", sWks);
return 1;
}

%R="ddDD";
test1(%R);
test1 sWks is:ddDD

test2(%R)=;
test2 sWks is:DDDD
TEST2(ddDD)=1
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