Jump to content
Sign in to follow this  
MirnesC2

saving information

Recommended Posts

MirnesC2

Is there any other way to save variables besides saving it into a .ini? Like saving it into the actual program, so it can be re-used after user exits.

Edited by MirnesC2

Share this post


Link to post
Share on other sites
enaiman

Do a search for "Alternate Data Stream" or ADS; there were plenty of examples.

Or you might consider using the registry.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
MirnesC2

Oh thank you! The only problem is that it only reads and writes, it doesn't delete the previous entry. So it would just stack up to be something like... Test!Test!Test!Test!. Thanks for the reply, this will come in use somewhere in the future. But not exactly what I am looking for. +1REP

I didn't want to cluster the forum by creating yet another thread, but... Is there suppose to be something in this spot? Like a • dot to indicate its on/off (if so how?)? or is it just there for looks?

Posted Image

Edited by MirnesC2

Share this post


Link to post
Share on other sites
Mison

Is there any other way to save variables besides saving it into a .ini? Like saving it into the actual program, so it can be re-used after user exits.

Looking for this?


Hi ;)

Share this post


Link to post
Share on other sites
enaiman

The only problem is that it only reads and writes, it doesn't delete the previous entry. So it would just stack up to be something like... Test!Test!Test!Test!.

Not really; you can erase the stream content very easy; the same way you do with any file.

Have a look at this short example:

FileClose(FileOpen(@TempDir&"\myADStest.txt", 2))                           ;create the file
FileClose(FileOpen(@TempDir&"\myADStest.txt:testSTREAM", 2))                ;create the stream
FileWrite(@TempDir&"\myADStest.txt:testSTREAM", "My test line 1.")          ;write to stream
MsgBox(0, "ADS Content", FileRead(@TempDir&"\myADStest.txt:testSTREAM"))    ;show stream content
FileClose(FileOpen(@TempDir&"\myADStest.txt:testSTREAM", 2))                ;erase stream content
FileWrite(@TempDir&"\myADStest.txt:testSTREAM", "......NEW content.......") ;write new content
MsgBox(0, "NEW Content", FileRead(@TempDir&"\myADStest.txt:testSTREAM"))    ;read new content
FileDelete(@TempDir&"\myADStest.txt")                                       ;delete test file

There are a couple aspects of using ADS: they work only on NTFS and if you copy the file to an non-NTFS support you lose any streams.

Other than that - it's your choice :)


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
jvanegmond

You can always write to the Windows registry. That's actually the preferred method when you don't want to use an .ini file..

Share this post


Link to post
Share on other sites
MirnesC2

Not really; you can erase the stream content very easy; the same way you do with any file.

Have a look at this short example:

FileClose(FileOpen(@TempDir&"\myADStest.txt", 2))                           ;create the file
FileClose(FileOpen(@TempDir&"\myADStest.txt:testSTREAM", 2))                ;create the stream
FileWrite(@TempDir&"\myADStest.txt:testSTREAM", "My test line 1.")          ;write to stream
MsgBox(0, "ADS Content", FileRead(@TempDir&"\myADStest.txt:testSTREAM"))    ;show stream content
FileClose(FileOpen(@TempDir&"\myADStest.txt:testSTREAM", 2))                ;erase stream content
FileWrite(@TempDir&"\myADStest.txt:testSTREAM", "......NEW content.......") ;write new content
MsgBox(0, "NEW Content", FileRead(@TempDir&"\myADStest.txt:testSTREAM"))    ;read new content
FileDelete(@TempDir&"\myADStest.txt")                                       ;delete test file

There are a couple aspects of using ADS: they work only on NTFS and if you copy the file to an non-NTFS support you lose any streams.

Other than that - it's your choice :)

FileClose(FileOpen(@TempDir&"\myADStest.txt:testSTREAM", 2))                ;erase stream content

Whoa!, I can't see how that erases the content but it works. Thanks!

EDIT: doesn't seem to work

#Include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>


GUICreate("Encrypted Save", 280, 300)
GUISetState(@SW_SHOW)

FileClose(FileOpen(@ScriptDir&"\myADStest.txt", 2))                 ;create the file
FileClose(FileOpen(@ScriptDir&"\myADStest.txt:testSTREAM", 2))      ;create the stream
FileWrite(@ScriptDir&"\myADStest.txt:testSTREAM", "Hello! 123")      ;write to stream

$content = FileRead(@ScriptDir&"\myADStest.txt:testSTREAM")

$console = GUICtrlCreateEdit($content,10,10,100,50)

$save = GUICtrlCreateButton("save",80,80)

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    Case $save
        FileClose(FileOpen(@ScriptDir&"\myADStest.txt:testSTREAM", 2))                ;erase stream content
        FileWrite(@ScriptDir&"\myADStest.txt:testSTREAM", GUICtrlRead($console)) ;write new content
    EndSwitch
WEnd

You can always write to the Windows registry. That's actually the preferred method when you don't want to use an .ini file..

Maybe this it would be easier as well? Can you hint me on what to look up in help files for create,write,read, and delete?

+REP to all who replied, thanks for support.

Edited by MirnesC2

Share this post


Link to post
Share on other sites
GEOSoft

Help File >> Function Reference >> Registry Management


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
MirnesC2

Thanks problem solved, works like a charm!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×