Can you change the names of files or delete files through robotic?
Does fwrite_pos start at 0 or 1?
When you set a position does it read that position or the very next position?
How would file access go about reading the config file for MegaZeux? I understand that when writing to a file, robotic places a '*' (or whatever you set as the delimiter) at the end of a string but not a number, is that right? How would it work in the case of the config file though, would the entire contents of the file be written to a single string and then modified there?
Page 1 of 1
File access questions I have a few questions
#1
Posted 03 November 2016 - 01:15 AM
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#2
Posted 03 November 2016 - 02:36 AM
No
0
That position
Easiest way to go would probably be to set fread_delimiter to the newline character (10) and read it line by line.
There are 4 different fwrite commands. Some of them share names with each other which might confuse you at first, but make no mistake, they are utterly distinct.
This writes a single byte containing the value 65 (in other words, the character A) to the file.
This writes four bytes to the file and those four bytes represent the value 8239. I can't recall if this is machine endianness or not, but you can probably expect little endian - in other words, this will write the bytes 47, 32, 0 and 0 to the file.
This writes the contents of $string followed by the FWRITE_DELIMITER character to the file.
This writes the first 10 bytes of $string and no delimiter to the file. As a result, this is often more useful than plain fwrite. If you want to write the entire string, but with no delimiter, use:
String fread and fread# work the same way - but, of course, if you want to read a string in from a file without a delimiter you'll need to know in advance how long it is.
0
That position
Easiest way to go would probably be to set fread_delimiter to the newline character (10) and read it line by line.
Quote
I understand that when writing to a file, robotic places a '*' (or whatever you set as the delimiter) at the end of a string but not a number, is that right?
There are 4 different fwrite commands. Some of them share names with each other which might confuse you at first, but make no mistake, they are utterly distinct.
set "fwrite" 65
This writes a single byte containing the value 65 (in other words, the character A) to the file.
set "fwrite_counter" 8239
This writes four bytes to the file and those four bytes represent the value 8239. I can't recall if this is machine endianness or not, but you can probably expect little endian - in other words, this will write the bytes 47, 32, 0 and 0 to the file.
set "$string" "fwrite"
This writes the contents of $string followed by the FWRITE_DELIMITER character to the file.
set "$string" "fwrite10"
This writes the first 10 bytes of $string and no delimiter to the file. As a result, this is often more useful than plain fwrite. If you want to write the entire string, but with no delimiter, use:
set "$string" "fwrite&$string.length&"
String fread and fread# work the same way - but, of course, if you want to read a string in from a file without a delimiter you'll need to know in advance how long it is.

<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
#3
Posted 03 November 2016 - 03:26 AM
I'd stay away from editing the config file. You have to worry about parsing out comments and whitespace and stuff...
You can just throw game-specific settings for thisgame.mzx into a thisgame.cnf and it should overwrite the config defaults.
You can just throw game-specific settings for thisgame.mzx into a thisgame.cnf and it should overwrite the config defaults.
Need a dispenser here.
#4
Posted 03 November 2016 - 03:46 AM
I've a funny feeling Graham wants to do something weird here, like specifying resolution options / fullscreen / scaler options from a configuration screen in the game itself, probably for the purposes of standalone distribution. In that case a per-game .cnf won't cut it.

<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
#5
Posted 03 November 2016 - 04:36 AM
Dr Lancer-X, on 02 November 2016 - 07:46 PM, said:
I've a funny feeling Graham wants to do something weird here, like specifying resolution options / fullscreen / scaler options from a configuration screen in the game itself, probably for the purposes of standalone distribution. In that case a per-game .cnf won't cut it.
You got it. As I'm wrapping up the game I want to look into that. But for the time being, I am trying to edit servo.cnf to get a feel for how it will work. I'm trying to add the option to select keyboard, xbox360 controller or custom game pad to the gam and have configurable buttons. Thanks guys.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#6
Posted 03 November 2016 - 12:27 PM
Btw, the config file is only accessed once by MegaZeux when it starts running right? So any changes to it will not be seen until you exit and reopen it?
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#7
Posted 03 November 2016 - 07:13 PM
Yup. Though - I wonder what happens when you load a world with a world-specific .cnf and then load a world without one.
Need a dispenser here.
#8
Posted 03 November 2016 - 08:15 PM
I think the game.cnf files are accessed when you load that game, though the settings seem to continue even when you load a different game. I've noticed I still have controller support when I play a different game, even though I only set it up for servo
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#9
Posted 03 November 2016 - 09:20 PM
Well, the config files don't wipe old settings, they just override the old settings with new ones. So if you load a game that doesn't contain a joystick profile your existing one won't change.

<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
Share this topic:
Page 1 of 1

Help







