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 9231703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:08:14+00:00 2026-06-18T06:08:14+00:00

For an .ini file with property_value pair, I’d like to define the datatype for

  • 0

For an .ini file with property_value pair, I’d like to define the datatype for property_name such that I will convert the datatype based on the input argument data type .

For this reason I have been trying to read the specificed datatype from the ini file in struct format. However I am getting the error : invalid fieldname. How can I define property_name and datatype such that I’ll be able to read it, and also be able to write to the ini file if i’d like to add property_datatype_vlaue pair?

[system] % string
value
[application] % string
value

I also need tot be able to set this datatype from my input argument.

How to sort property -value pair in alphabetical order with Matlab

  • 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-18T06:08:15+00:00Added an answer on June 18, 2026 at 6:08 am

    Modifying the struct from this answer to contain value and type

    function fileData = readFileIntoStruct( fileName )
    %
    % read [property] value pairs file into struct
    % 
    fh = fopen( fileName, 'r' ); % read handle
    line = fgetl( fh );
    while ischar( line )
        % property
        tkn = regexp( line, '\[([^\]+)]\]\s*%\s*([^%]+)\s*$', 'once', 'tokens' );
        % read next line for value
        val = fgetl( fh );
        fileDate.(tkn{1}).val = val;
        fileDate.(tkn{1}).type = tkn{2};
        line = fgetl( fh ); % keep reading
    end
    fclose( fh ); % don't forget to close the file at the end.
    

    Assumptions:

    1. The properties’ names are legitimate Matlab field names (see variable naming for details).

    2. The value of each property is always a string.

    3. I did not include any error-checking code in these examples (files not found, wrongly formatted strings, etc.)

    4. I assume the input file is strictly “[prop] val” pairs without any additional comments etc.

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

Sidebar

Related Questions

I need to create an application that will take an .ini file which will
I have an .ini file which looks like: password = password123 username = username123
Basically, I would like a simple, easy, one-file way to parse an INI file
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want to read a INI file from python, and I came up with
I am using wamp server so my.ini file is the new my.cfn file. I
I want to map a INI file as a python object. So if the
I wish to fine tune my eclipse.ini file to best suit my system and
I'm trying to write an INI file using the WritePrivateProfileString and WritePrivateProfileStruct functions. I
I am getting ini Parsing Error for the following ini file : [photo] price

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.