1
Well I have a table as follows:
{
Number: 15007 Name: "Variance" Value: 35
}
Before I used a txt format that was like this:
15007,Variance,35
The C-code looked something like this:
void read_names(void) {
struct st *table;
int var = 0;
const char *str = NULL;
table->number = var;
table->name = str;
table->value = var;
return;
}
I want to switch to moon now, I could use libconfig, more I’ve used once and the same is very limited, an example in lib if I were to do the above table:
void read_names(void) {
struct st *table;
int var = 0;
const char *str = NULL;
config_setting_t *names = .........
table->number = config_setting_lookup_int(names, "Number", &var);
table->name = config_setting_lookup_string(names, "Name", &str);
table->value = config_setting_lookup_int(names, "Value", &var);
return;
}
So above I could read the table I posted at the beginning of the topic.
But I want to use moon, what I want to know how I use the same way of lib and allow me to use integers and string in the names Number, Name and Value, for example:
table->number = função_lua(L, "Number", &var);
If writing cannot be that way, take into account that it was just an example.
I can’t understand what you’re doing and what you’re trying to do. You need to [Dit] the question and put more information that is relevant to the problem.
– Maniero
Edited, what I want to know is how I can call the moon for numbers in function
table->number =
in case that function would have to read the Value of the table.– carolzinha
You want to know what the function is to use a value that is numerical instead of a string as was done with
Name
?– Maniero
yes, only that you would have to read Value: it would be like a C reading that you do
printf("Value %d\n", table->name);
– carolzinha
What did you put in is doing what you want? Because you shouldn’t. What you’re describing is different from what the code is doing. Maybe put yourself in details what you’re doing, where you’re coming from and a complete code is easier to understand.
– Maniero
I added new information.
– carolzinha