[Lib] ObjDump / ObjLoad - Object Backup

Post your working scripts, libraries and tools
arcticir
Posts: 576
Joined: 17 Nov 2013, 11:32

Re: [Lib] ObjDump / ObjLoad - Object Backup

26 Feb 2016, 04:42

Thanks. This awesome ~
I have more hope, Title becomes the default parameters. :D
arcticir
Posts: 576
Joined: 17 Nov 2013, 11:32

Re: [Lib] ObjDump / ObjLoad - Object Backup

29 Feb 2016, 01:31

BUG

Code: Select all

obj:=["test",[11]]
ObjDump(obj,var)
newobj:=ObjLoad(&var)
MsgBox % ObjTree(newobj)
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

01 Mar 2016, 19:35

This should be fixed now, additionally ObjDump will compress data to reduce size :)
arcticir
Posts: 576
Joined: 17 Nov 2013, 11:32

Re: [Lib] ObjDump / ObjLoad - Object Backup

02 Mar 2016, 05:34

Thanks.  
But I do not agree with your ideas.  
I define it: OBJ ← → Var
Clearly file and encryption does not belong to it.

Because it greatly affects the performance of the function: :(


Older: (20 millisecond)

Code: Select all

Timing := A_TickCount,  Counter  :=Counter()
f:={a:"a"}
Loop 10000
{
r:=ObjDump(f,a)
i:=ObjLoad(&a)
}

MsgBox % Counter(Counter)   A_Tab A_TickCount - Timing

Counter(s:=0) {
	static Frequency := QueryFrequency()
	DllCall("QueryPerformanceCounter",Int64P,Counter)
	Return (s ? (Counter-s)/Frequency : Counter)
}

QueryFrequency(){
	DllCall("QueryPerformanceFrequency",Int64P,F)
	Return F
}
The new: (1.2 second)

Code: Select all

Timing := A_TickCount,  Counter  :=Counter()
f:={a:"a"}
Loop 10000
{
r:=ObjDump(f,a)
i:=ObjLoad(&a,r)
}

MsgBox % Counter(Counter)   A_Tab A_TickCount - Timing

Counter(s:=0) {
	static Frequency := QueryFrequency()
	DllCall("QueryPerformanceCounter",Int64P,Counter)
	Return (s ? (Counter-s)/Frequency : Counter)
}

QueryFrequency(){
	DllCall("QueryPerformanceFrequency",Int64P,F)
	Return F
}
ObjLoad () change not good, This means I have a lot of scripts need to be modified. = =

---------------------

we can use the built-in encryption and decryption function to ZIP files?
I now use 7z. exe, I would like to get rid of it. :D
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

02 Mar 2016, 16:02

I have changed ObjDump not to compress data by default.
arcticir
Posts: 576
Joined: 17 Nov 2013, 11:32

Re: [Lib] ObjDump / ObjLoad - Object Backup

02 Mar 2016, 16:29

New error
Error: CONTINUABLE EXCEPTION_ACCESS_VIOLATION

Mouse and Keyboard hooks have been disabled.

- Press yes to exit thread and continue execution.
- Press no to continue thread (debug).
- Press cancel to exit application.

Exception was caused in thread id: 9328
Line: 5
Specifically: ObjDump(f,a)
LineFile: C:\03月03日_New.ahk
serzh82saratov
Posts: 72
Joined: 01 Jul 2017, 03:04

Re: [Lib] ObjDump / ObjLoad - Object Backup

15 Nov 2017, 08:34

the keys are missing
AutoHotkey v1

Code: Select all

arr := {"  11":"888   ","11	":"	999"}

for k, v in arr
	MsgBox, , Original, % "|" k  "|"  v "|"
	
ObjDump(arr,Obj)
for k, v in ObjLoad(&Obj)
	MsgBox, , ObjLoad, % "|" k  "|"  v "|"
I did as you did.
Spoiler
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

15 Nov 2017, 19:14

Thanks, that should be fixed now.
Note, your version converts everything to strings which is not appropriate and will increase memory and affect speed!
serzh82saratov
Posts: 72
Joined: 01 Jul 2017, 03:04

Re: [Lib] ObjDump / ObjLoad - Object Backup

16 Nov 2017, 00:55

But I have no such problem.

Code: Select all

arr := {"  11":"42949672954294967295","11  ":"-42949672954294967295"}

for k, v in arr
	MsgBox, , Original, % "|" k  "|"  v "|"
	
ObjDump(arr,Obj)
for k, v in ObjLoad(&Obj)
	MsgBox, , ObjLoad, % "|" k  "|"  v "|"
User avatar
Relayer
Posts: 125
Joined: 30 Sep 2013, 13:09
Location: Delaware, USA

Re: [Lib] ObjDump / ObjLoad - Object Backup

16 Nov 2017, 11:31

When I run this example:

Code: Select all

obj:={a:1,b:2,c:[1,2,"test"],d:{a:0}}
ObjDump(A_ScriptDir "\Test.bin",obj)
for k,v in ObjLoad(A_ScriptDir "\Test.bin")
  If !IsObject(v)
    MsgBox % "Parent:`n" k ": " v
  else for k,v in v
    MsgBox % "Child:`n" k ": " v

... the returned object from the load function appears return {a:1,b:2,c:[1,2,"test"],d:0.00000} instead of the original. Not only is the element "d" demoted, the value has gone from integer to a float. Should it not faithfully reproduce the original object?

Relayer
toralf
Posts: 607
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: [Lib] ObjDump / ObjLoad - Object Backup

20 Jul 2018, 01:41

I read that compression was once possible. But was removed for storage in a variable.
Is compression still being done for file or Is it still optional available/possible?
ciao
toralf
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

22 Jul 2018, 17:04

Compression is only supported in AHK_H build in func: http://hotkeyit.github.io/v2/docs/commands/ObjDump.htm
For this lib func you will have to compress afterwards using for example VarZ: https://autohotkey.com/board/topic/4195 ... mpression/.
toralf
Posts: 607
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: [Lib] ObjDump / ObjLoad - Object Backup

23 Jul 2018, 04:53

Thanks for the reference.
That lib seems to only compress the Content of a variable.
I was looking for a way to compress the dumped file as a whole (before writing it to file).
ciao
toralf
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

23 Jul 2018, 14:59

Yes, you can write the variable to file after compression.
teadrinker
Posts: 901
Joined: 29 Mar 2015, 09:41
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

25 Jul 2018, 05:04

There is a bug in ObjDump().

Code: Select all

f:=FileOpen(obj,"rw-rwd"),VarSetCapacity(v,sz:=RawObjectSize(var,mode)+8,0)
Since file encoding could be UTF-8 or UTF-16, obviously the code must be:

Code: Select all

f:=FileOpen(obj,"rw-rwd"),f.Pos := 0
SAbboushi
Posts: 145
Joined: 08 Dec 2014, 22:13

Re: [Lib] ObjDump / ObjLoad - Object Backup

25 Jul 2018, 13:02

I downloaded the v2 versions. Getting error:
Error in #include file "J:\StandaloneApps\AutoHotkeyV2\Lib\ObjDump.ahk":
Type mismatch.

Line#
046: objects[obj]:=1
047: For k,v in obj
048: {
049: if IsObject(k)
050: sz+=objects.HasKey(k)?9:RawObjectSize(k,buf,objects)+9
051: Else
051: if Type(k)="String"
---> 052: sz+=StrPut(k)*2+9
053: Else
053: sz+=InStr(k,".")||k>4294967295?9:k>65535?5:k>255?3:k>-129?2:k>-32769?3:k>-2147483649?5:9
054: if IsObject(v)
055: sz+=objects.HasKey(v)?9:RawObjectSize(v,buf,objects)+9
056: Else
056: if Type(v)="String"
057: sz+=(buf?obj.GetCapacity(k):StrPut(v)*2)+9

The current thread will exit.
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

25 Jul 2018, 15:35

teadrinker wrote:There is a bug in ObjDump().

Code: Select all

f:=FileOpen(obj,"rw-rwd"),VarSetCapacity(v,sz:=RawObjectSize(var,mode)+8,0)
Since file encoding could be UTF-8 or UTF-16, obviously the code must be:

Code: Select all

f:=FileOpen(obj,"rw-rwd"),f.Pos := 0
Thanks that has been updated to f:=FileOpen(obj,"rw-rwd","CP0").
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Lib] ObjDump / ObjLoad - Object Backup

25 Jul 2018, 15:35

SAbboushi wrote:I downloaded the v2 versions. Getting error:
Error in #include file "J:\StandaloneApps\AutoHotkeyV2\Lib\ObjDump.ahk":
Type mismatch.

Line#
046: objects[obj]:=1
047: For k,v in obj
048: {
049: if IsObject(k)
050: sz+=objects.HasKey(k)?9:RawObjectSize(k,buf,objects)+9
051: Else
051: if Type(k)="String"
---> 052: sz+=StrPut(k)*2+9
053: Else
053: sz+=InStr(k,".")||k>4294967295?9:k>65535?5:k>255?3:k>-129?2:k>-32769?3:k>-2147483649?5:9
054: if IsObject(v)
055: sz+=objects.HasKey(v)?9:RawObjectSize(v,buf,objects)+9
056: Else
056: if Type(v)="String"
057: sz+=(buf?obj.GetCapacity(k):StrPut(v)*2)+9

The current thread will exit.
Please provide full example.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Chunjee, joedf and 35 guests