Load File as Binary into a string
Load File as Binary into a string
How to do that?
I need hex Values for each Position inside the string.
openfile and filetostring don´t seem to do it right.
I need hex Values for each Position inside the string.
openfile and filetostring don´t seem to do it right.
Re: Load File as Binary into a string
Might not help you since it requires those files first be created with Hollywood.
But what i have been doing is to save tables as binary. Dont remember rightaway, but i think the command was maybe simpy SaveTable and LoadTable.
example code (commands might not be right):
will result in:
10
200
But what i have been doing is to save tables as binary. Dont remember rightaway, but i think the command was maybe simpy SaveTable and LoadTable.
example code (commands might not be right):
Code: Select all
mytable = {x=10, y=200}
SaveTable(mytable, "myfilename")
mysecondtable = LoadTable("myfilename")
debugprint(mysecondtable.x)
debugprint(mysecondtable.y)
10
200
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Load File as Binary into a string
To get the ASCII value of a string character, just use
where "xxx" is the offset of the character starting from 0. If you want the value as hex, use
Code: Select all
c = Asc(MidStr(s$, xxx, 1))
Code: Select all
c = HexStr(Asc(MidStr(s$, xxx, 1)))
Re: Load File as Binary into a string
Thanks for your valuable hint Andreas!
Here's the result how to know if Compositing for Windows on Workbench is enabled or not:
Here is how i get the knownledge what byte is responsible for it:
Here's the result how to know if Compositing for Windows on Workbench is enabled or not:
Code: Select all
OpenFile(1,"SYS:Prefs/Env-Archive/Sys/gui.prefs")
s$ = ReadLine(1)
CloseFile(1)
c = HexStr(Asc(MidStr(s$, 58, 1)))
if c = "$3" then o = "Compositing is on"
if c = "$2" then o = "Compositing is off"
DebugPrint(o)
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Load File as Binary into a string
Keep in mind that the offset can change with every new version of OS4 so directly peeking at a hard-coded offset is not a clean way that ensures future compatibility
Btw, you don't have to use HexStr() for that at all. You can also just use:
Btw, you don't have to use HexStr() for that at all. You can also just use:
Code: Select all
c = Asc(MidStr(s$, 58, 1))
if c = $3 then o = "Compositing is on"
if c = $2 then o = "Compositing is off"
Re: Load File as Binary into a string
I know, for this case i will have a "compositing off" fallback, if this byte don´t return a valid value. Another way is to look which version of Workbench/GUIPrefs is installed/running.Andreas wrote:Keep in mind that the offset can change with every new version of OS4 so directly peeking at a hard-coded offset is not a clean way that ensures future compatibility
Very useful!Btw, you don't have to use HexStr() for that at all. You can also just use:
Code: Select all
c = Asc(MidStr(s$, 58, 1)) if c = $3 then o = "Compositing is on" if c = $2 then o = "Compositing is off"
Re: Load File as Binary into a string
Is there any way in Hollywood itself to check if compositing is on nowadays? For MorphOS and OS4 at least... I have no idea about AROS, but if it has a similar situation, that too
I thought I've seen such thing, but now it seems that I can't find any info about it. So if it's not there still, could we get such a function (ASAP)? I'm making a program with alpha transparent windows, which is progressing nicely, but when I now started to think about making a fallback solution for traditional modes, I can't seem to find any clean solution to find it out. Having user to select something manually will be out of question...
I thought I've seen such thing, but now it seems that I can't find any info about it. So if it's not there still, could we get such a function (ASAP)? I'm making a program with alpha transparent windows, which is progressing nicely, but when I now started to think about making a fallback solution for traditional modes, I can't seem to find any clean solution to find it out. Having user to select something manually will be out of question...
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Load File as Binary into a string
No, it's currently not possible. I could add this to Hollywood but of course I prefer to keep platform-specific APIs at a minimum level. Isn't it possible to find out whether compositing is enabled using some other means? (maybe env variables, Rexx script, examining system prefs or some 3rd party tool?)
Re: Load File as Binary into a string
In MorphOS you can read it in plain text from ENV:MUI/screens.txt, but reading this thread it seems to be more uncertain with OS4. I don't have proper setups for OS4 and AROS to find it out... anyone else done any research? I'd rather avoid any 3rd party tools and offer my program without dependencies.