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
 Passing string arguments to Origin C
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mike Buess

USA
3037 Posts

Posted - 06/02/2004 :  10:50:46 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have an Origin C function that takes a file path\name as an argument. It works fine unless the path or name contains the percent symbol (%) in which case the OC function substitutes % + next letter with the value of the corresponding LabTalk string variable.

int MyFunction(string strPath);
{
out_str(strPath);
- more code -
};

//%F="something";
%Z=C:\Data\My %Folder\file.dat;
nn=MyFunction(%Z);
>>C:\Data\My somethingolder\file.dat

In Origin 7.5 I can fix it like this...

%Z=C:\Data\My %Folder\file.dat;
path$=%Z;
nn=MyFunction(path$);
>>C:\Data\My %Folder\file.dat

Is there a solution for Origin 7.0? (path$=%Z doesn't work in that version.)

Mike Buess
Origin WebRing Member

srmcarneir

Brazil
33 Posts

Posted - 06/02/2004 :  11:42:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Using OriginPro7, SR4, under Win2k, the following code
seemed to work:

// Compilation of Buess.c (an OriginC routine)
//
err = run.LoadOC("C:\Buess.c", 2);
if (err != 0)
type -b "Err = " $(err) " - Cannot load support Origin C file";


%F="something";
%Z="C:\Data\My %Folder\file.dat";
nn=MyFunction(%Z);
type $(nn);
//>> 1
type -v %Z;
//>> C:\Data\My somethingolder\file.dat


In order to test it, your OriginC function was simplified
in a Buess.c file:

..
#include <stdio.h>
..
int MyFunction(string strPath)
{
if (strPath == "C:\DATA\MY SOMETHINGOLDER\FILE.DAT")
return 1;
else
return 0;
}

It is funny that the path was passed (or received by the
OriginC function) in capital letters. That is why I tested
so in the if-statement.

Hope it can be of any help.

Regards,

Ricardo Carneiro
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/02/2004 :  12:15:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ricardo,

That's also what I see and want to avoid in Origin 7.0. I want to treat % like any other character because it's allowed in file and path names. I don't want %letter to be treated as a string variable and can't test against that happening (as you did) because (1) I don't know in advance what letter is and (2) I probably wouldn't know in advance what the value of %letter even if I knew what letter was.

I'm looking for a way to pass the paths C:\Data\My %Folder\file.dat or C:\Data\My Fo%lder\file.dat (or any possible variation) to an Origin C function in Origin 7.0 and prevent such substitution from happening.
quote:
It is funny that the path was passed (or received by the OriginC function) in capital letters
That's normal when providing a LabTalk string variable as an Origin C argument. It's always converted to caps.

...Adding an extra % accomplishes what I want.

%Z=C:\Data\My %%Folder\file.dat;
nn=MyFunction(%Z);
>>C:\Data\My %Folder\file.dat

But how can I find the % and precede it with another % in an arbitrary path? Note - The paths are obtained with a file dialog.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/02/2004 1:06:44 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