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
 Merging LabTalk and 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

peter.cook

UK
356 Posts

Posted - 11/03/2003 :  06:57:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

Just a thought re using both LabTalk and C. I think it's possible to put all LabTalk code in a c file by defining strings as the LabTalk functions/sections etc. Using '\' makes the code manageable eg

void test()
{

string LTstring="loop(numloop,1,100) {data1_a[numloop]$="pete";};"

LTexecute(LTstring);

}


Deining LTstring as a static string enables it to be called by all functions in the c file.
I think (not sure) the way to enable all the LabTalk code to 'global' is to define a function that returns the LabTalk code as a string.

This to me seems really useful and will aid managing my code and evolving from LabTalk to C over time!

Does anyone have any comment or know of possible limitations/problems that may arise (length of string?).

(Origin 7.5 attaching C files to projects : even better!)

Cheers,

Pete



easwar

USA
1965 Posts

Posted - 11/03/2003 :  09:47:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Pete,

Another way to do this is to organize your code as shown below. The Origin C compiler ignores everthing inside the ifdef LABTALK block (assuming of course LABTALK is not defined), and then to run the LabTalk code, you can issue commands from script such as:
run.section(file_path_and_name_of_C_file, MySection1)

Of course this is much easier in version 7.5 like you mentioned - Origin C files, LabTalk (OGS) files, or any other files can be attached and saved with an Origin Project.

In 7.5, when you issue a run.section command such as
run.section(just_file_name, section_name)
Origin will first look for a file and section of that name in attached files and run that if found. If not found, it will then look in User Files area, and then in the Origin EXE path.

Easwar
OriginLab.



#include <origin.h>

void MyOCFunction()
{
out_str("My OC Function\n");
}


#ifdef LABTALK
[MySection1]
type -b MySection1;
[MySection2]
type -b MySection2;
#endif LABTALK
Go to Top of Page

peter.cook

UK
356 Posts

Posted - 11/03/2003 :  11:57:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Easwar,

I guess the 'recommended' way is better! Getting carried away here...

Cheers,

Pete

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