PHP-Funktionen für AHK

Veröffentliche deine funktionierenden Skripte und Funktionen

Moderator: jNizM

User avatar
SAPlayer
Posts: 48
Joined: 30 Sep 2013, 13:38
Location: Germany
Contact:

PHP-Funktionen für AHK

Post by SAPlayer » 30 Sep 2013, 14:02

Hallo,
ich bin dabei, einige - meiner Meinung nach nützliche - PHP-Funktionen (in möglichst gleicher Funktionsweise) in AHK zu "importieren".
Dabei soll das Verhalten sowie der Aufruf möglichst nah an der originellen PHP-Funktion gehalten werden.
Hier mal mein Anfang:

Code: Select all

count(var, mode=0){
	if(var = "")
		return 0
	if(!IsObject(var))
		return 1
	count := 0
	if(mode = 0){
		for i, k in var
			count++
	}
	else if(mode = 1){
		this := var
		RecursiveCounting:
		for i, k in this
		{
			count ++
			if(IsObject(k)){
				this := k
				gosub RecursiveCounting
			}
		}
		return count
	}
	return count
}

print_r(input){
	output := ""
	if(!IsObject(input))
		return input
	this := input
	tabs := ""
	ThisArray:
	if(IsObject(this)){
		output .= "Array`n" tabs "(`n"
		tabs .= "`t"
		for i, k in this
		{
			if(IsObject(k)){
				this := k
				output .= tabs "[" i "] => "
				gosub ThisArray
			}
			else
				output .= tabs "[" i "] => " k "`n"
		}
		tabs := SubStr(tabs, 1, -1)
		output .= tabs ")`n"
	}
	return Trim(output, "`n")
}

time(timestamp="UTC") {
	if(timestamp = "UTC")
		timestamp := A_NowUTC
	timestamp -= 1970, S
	return timestamp
}
Ich werde mit der Zeit noch weitere Funktionen umschreiben. Dabei könnt ihr mir gerne helfen.
Last edited by SAPlayer on 01 Oct 2013, 11:43, edited 1 time in total.

User avatar
joedf
Posts: 9000
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: PHP-Funktionen für AHK

Post by joedf » 30 Sep 2013, 20:58

Interessant! ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

Alibaba
Posts: 480
Joined: 29 Sep 2013, 16:15
Location: Germany

Re: PHP-Funktionen für AHK

Post by Alibaba » 01 Oct 2013, 03:40

Sehr gut!
Die String und Array Funktionen wären noch hilfreich!
"Nothing is quieter than a loaded gun." - Heinrich Heine

User avatar
SAPlayer
Posts: 48
Joined: 30 Sep 2013, 13:38
Location: Germany
Contact:

Re: PHP-Funktionen für AHK

Post by SAPlayer » 01 Oct 2013, 11:44

Neu: count()

Post Reply

Return to “Skripte und Funktionen”