Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:14:14+00:00 2026-06-09T00:14:14+00:00

I am trying to load .clp file in my iPhone application. For that I

  • 0

I am trying to load .clp file in my iPhone application. For that I am using below code

    NSString *filePath = [[NSBundle mainBundle]
                          pathForResource:@"autodemo" ofType:@"clp"];

    environment = CreateEnvironment();
    char *clipsFileChar = (char *)[filePath cStringUsingEncoding:NSASCIIStringEncoding];
    Load(clipsFileChar);
    Reset();
    Run(-1);

    NSString *evalS = [NSString stringWithFormat:@"(find-all-facts ((?f state-list)) TRUE)"];
    char * evalStr = (char *)evalS;

    DATA_OBJECT obj;// = {0,-1};
//    obj.type = STRING;
//    obj.value = evalStr;

    int i = Eval(evalStr, &obj);
    NSLog(@"%d",i);

now when I run this code Eval(evalStr, &obj) gives me 0 every time.
I am using autodemo.clp file from this link.
So, how to make Eval() command work and how do I get response returned by clp file?

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:14:15+00:00Added an answer on June 9, 2026 at 12:14 am

    below code solved my problem, hope it will help to someone else.. 🙂


    InitializeEnvironment();
    Clear();
    
    NSString *filePath = [[NSBundle mainBundle]
                          pathForResource:@"autodemo" ofType:@"clp"];
    char *clipsFileChar = (char *)[filePath cStringUsingEncoding:NSASCIIStringEncoding];
    
    IncrementGCLocks();
    Load(clipsFileChar);
    Reset();
    Run(-1);
    DecrementGCLocks();
    
    [self nextUIState];
    

    - (void)nextUIState
    {
        DATA_OBJECT theDO;
        NSString * evalS = @"(find-all-facts ((?f state-list)) TRUE)";
        char *evalStr = (char *)[evalS cStringUsingEncoding:NSASCIIStringEncoding];
    
        int j = EnvEval(GetCurrentEnvironment(), evalStr, &theDO);
        NSLog(@"j = %d",j);
    
        if(factDict)
        {
            [factDict release];
            factDict = nil;
    
            factDict = [[NSMutableDictionary alloc] init];
        }
    
        id value = [self objectForDataObject:&theDO];
    
        NSLog(@"%@",[value description]);    
    }
    

    -(id) objectForDataObject: (DATA_OBJECT*) arg
    {
        switch(arg->type)
        {
            case FACT_ADDRESS:
            {
    
                DATA_OBJECT data = { 0 };
                struct fact* aFact = (struct fact*) arg->value;
    
                if(EnvGetFactSlot(GetCurrentEnvironment(),aFact,(char*)[@"current" UTF8String],&data))
                {
                    [factDict setObject:[self objectForDataObject: &data] forKey:@"current"];
                    [factDict retain];
                }
                return factDict;
            }
            case SYMBOL:
            {
                NSString *str = [NSString stringWithUTF8String: ValueToString(arg->value)];
                if ([str isEqual: @"nil"]) return nil;
                if ([str hasPrefix: @"<<<"] && [str hasSuffix: @">>>"])
                {
                    return [self dataFromSymbolString: str];
                }
                return str;
            }
            case STRING:
            {
                return [NSString stringWithUTF8String: ValueToString(arg->value)]; 
            }
            case INTEGER:
            {
                return [NSNumber numberWithInt: ValueToInteger(arg->value)];
            }
            case FLOAT:
            {
                return [NSNumber numberWithDouble: ValueToDouble(arg->value)];
            }
            case EXTERNAL_ADDRESS:
            {
                return (id) arg->value;
            }
            case MULTIFIELD:
            {
                int i, count = GetpDOLength(arg);
                NSMutableArray *args = [NSMutableArray arrayWithCapacity: count];
                FIELD_PTR fptr = (FIELD_PTR) GetMFPtr(GetpValue(arg),GetpDOBegin(arg));
                for(i = 0; i < count; ++i, ++fptr)
                {
                    DATA_OBJECT dobj;
                    dobj.type = fptr->type;
                    dobj.value = fptr->value;
                    [args addObject: [self objectForDataObject: &dobj]];
                }
                return args;
            }
            default:
                return nil;
        }
    }
    

    If you find out any other and better way(ofcourse there is), please let me know. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to load a image at runtime in WPF using the following code
Im trying to load a csv file into a datatable using oledb. This is
I'm trying to load an external XML file that contains references to images in
Im trying to load an xml file using the jquery ajax function,it works fine
I'm trying to load an entire/partial html using jquery's load function. I'm aware that
I am trying to load a CSV file to BigQuery using a python script
I am trying to load a file which is being uploaded using PHP script.
i m trying load UIImages from server asynchronously in UITableViewCell. My code worked fine
Trying to load a small .txt file into mysql but get all my data
I trying to load and save setting with this code but when I closing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.