T O P I C R E V I E W |
Mike Buess |
Posted - 06/02/2004 : 10:50:46 AM 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 |
2 L A T E S T R E P L I E S (Newest First) |
Mike Buess |
Posted - 06/02/2004 : 12:15:13 PM 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 |
srmcarneir |
Posted - 06/02/2004 : 11:42:54 AM 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 |
|
|