AutoHotkey Community

It is currently May 27th, 2012, 1:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: December 30th, 2011, 4:40 pm 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
It would be good to have a few standard things sript writers could put at the top of their script before posting?

I would like to see at the top
Ahk basic or AhkL or both

Also the url of their post so I can get back to them if it doesnt work or suggest something.

Lastly put the Hotkeys if any at the top so people dont have to search through the code to find them
HOTKEY is +z


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 31st, 2011, 12:35 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Jung Rae Mun wrote:
Also the url of their post so I can get back to them if it doesnt work or suggest something.
Why not just copy what's in your address bar?

If you need a link to a specific post, right click on the post icon.

Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 12:44 am 
Offline
User avatar

Joined: February 28th, 2011, 7:28 pm
Posts: 625
Location: Germany
He's talking about the stuff the script file itself I think.

I'dd add OS and other (software, library) requirements, although this should be self-evident. Oh, and if ANSI vs Unicode makes any problems, put it there, too.

_________________
RECOMMENDED: AutoHotkey_L
Image
github - ImportTypeLib
Win7 HP SP1 32bit | AHK_L U 32bit


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 9:25 am 
Offline

Joined: June 4th, 2010, 9:04 pm
Posts: 1347
Location: california
This is what i generally like to use in my production stuff but i generally don't go into all this detail when i'm writing quick and dirty.

Code:
;==================================================
; Script Header stuff
Script_Name = Prototype Skeleton
Script_Date = 2011/12/31
Script_Version = 1.0.0.0
Script_Author = GirlGamer
AHK_Version = AHK Basic V1.0.48.05

; Revisions:
;     none
; Remarks:
;     none
;==================================================

HotKeyHelpTxt =
(     Shift-Esc = End Script
      Alt-H = This Help Text
      Shift-F10 = ListLines
      Shift-F11 = ListVars
      Shift-F12 = Reload Script
)

;hotkeys go here
Hotkey, +Esc, QuitScript
Hotkey, !H, ShowHelp
Hotkey, +F10, DoListlines
Hotkey, +F11, DoListVars
Hotkey, +F12, DoReload

;--------------------------------------------------
; Script Setup
#NoEnv
#SingleInstance, force
SetTitleMatchMode, 2
CoordMode, Pixel, Relative
CoordMode, Tooltip, Relative
CoordMode, Mouse, Relative
SetKeyDelay, 10, 30

; data initializations here

; gui setups here

; main loops here

; end Autoexecute section
Return

;==================================================
; Script specific subroutines and functions go here

;==================================================
; common hotkey routines
QuitScript:
ExitApp

ShowHelp:
MsgBox,0x30,Hotkey Help, %HotKeyHelpTxt%
Return

DoListlines:
ListLines
Return

DoListVars:
ListVars
Return

DoReload:
Reload
Return

;==================================================
; End of Script

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 11:34 am 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
yes I was talking about what would be useful to put at the top of the script for the users reference.
@ GirlGamer yes the version number would be good too so you can easily check to see if you were using the latest version.
What I usually do first on downloading a script is search through it and put any hotkeys at the top of the script myself - just commented for my ref


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 12:22 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
At most I provide this info, example from nightly version of Appifyer.

Code:
ScriptVersion := "1.2"
   /*
   < Appifyer > (beta)
   Author: Simon Strålberg [sumon @ Autohotkey forums, simon . stralberg @ gmail . com]
   Autohotkey version: AHK_L (Unicode, x32)
   Dependencies:
      - AHK_L
      - Notify.ahk by gwarble & more [http://www.autohotkey.com/forum/viewtopic.php?t=48668]
      - Ini.ahk by Tuncay [http://www.autohotkey.com/forum/viewtopic.php?p=280883]
      - AddGraphicButton () by Corrupt [http://www.autohotkey.com/forum/topic4047.html]
      - TT.ahk (?)
      
   CHANGELOG:
   v.
      - 1.2. Beta version. Added a 16px icon. Removed "All apps up to date" even while notifications are enabled. Adding appspecific settings. Changed Tray menu to make Appsmenu default. Added a semitransparent Splashscreen. Changed "GUI, n: Default" to "GUI, Settings:Default" etc. Improved drag-n-drop and added support for dropping folders. [+ more, probably...]
      - 0.99 Update notification added. Live notification(s) added. Hotkeys now change directly, instead of sometimes requiring relaunch.
      - 0.98 Added update for all apps & Appifyer. Trying to launch a running app only activates it. Added fast access to Settings, and MClick on Windows Start button brings up App menu.
      - 0.97b Trimmed winkey into the "hotkey" value
      - 0.97 Added basic Settings/Help tabs, fixed an issue where non-existing icon crashed the script, Slightly improved Appify:, fixed a crash caused by a removed app.
      - 0.96 Rewritten for nicer code, proper ini system, GUI saves flawlessly. Hotkey behaviour is fine. Added "Modes".
      - 0.91 a proper INI system, Settings, update, etc.

   LICENSE:
   For Appifyer, [http://www.autohotkey.net/~sumon/strictlicense.html]
   For Ini.ahk (tuncay): Thanks to tuncay for his great library, his license is linked at [http://www.autohotkey.com/forum/viewtopic.php?p=280883]
   Icons are in some cases made by me, in other cases downloaded from http://www.iconfinder.com from Iconpacks with WTF public license. Huge thanks to the authors of Brightset icon pack.
   
   Script created using Autohotkey [http://www.autohotkey.com], AHK_L by Lexikos
*/


Things I consider useful: Script name, author, license, hotkeys, changelog.

I'll keep watching this topic and improve, for now I'll try to add topic URLs to most of my scripts.

I actually added this to my "new script" template a while ago, and I try to fill it in if I intend to post the script atleast...

Code:
/*
   < SCRIPT NAME >
   Version:
   Author: Simon Strålberg [sumon @ Autohotkey forums, simon . stralberg @ gmail . com]
   Autohotkey version: AHK_L (Unicode, x32)
   Dependencies:
      
   CHANGELOG:
   v.
      -
      -
   
   TODO:
      -
      -

   LICENSE: If no license documentation exists, [http://www.autohotkey.net/~sumon/license.html]
   Script created using Autohotkey [http://www.autohotkey.com]
   
*/

_________________
~sumon Appifyer AHK Nova halted Recommended: AHK_L (Why?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 1:27 pm 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
Wow Sumon, It would be difficult to complian about your headings - lot of useful info there.
yes a url at the top is very useful - I often copy a script and save it with a slightly different name as sometimes the names given to scripts are a bit odd or cryptic. Later on when it comes to trying the script out I find I need to consult the thread but then forget what it was called and where to find it :oops: But you provide lots of info including your user name so I could just search for scripts made by you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 3:51 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
And here is the full header of my ini lib. I like to have "talkative" headers too.

Code:
/*
Title: Basic ini string functions
    Operate on variables instead of files. An easy to use ini parser.
   
About: License
    New BSD License

Copyright (c) 2010, Tuncay
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the Tuncay nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Tuncay BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About: Introduction

    Ini files are used mostly as configuration files. In general, they have the
    ".ini"-extension. It is a simple standardized organization of text data.
    Many other simple programs use them for storing text.   
   
    AutoHotkey provides three commands IniDelete, IniRead and IniWrite. These
    commands are stable, but they have some disadvantages. First disadvantage
    is, that they access the file directly. The file on the disk is opened,
    load into memory and then read or manipulated and then saved with every
    single command.   

    With the custom functions I wrote here, the user accessess on variables
    instead of files. This is super fast, in comparison to disk access. Ini
    files can be created by Ahk just like any other variable. But Ahk itself
    does not have any function to operate on ini strings (variables). If you
    read often from ini file, then this might for you.
   
    No other framework or library is required, no special object files are
    created; just work on ordinary ini file contents or variables. The load
    and save functions are added for comfort reason and are not really needed.
   
    * *First do this:*
   
    > FileRead, ini, config.ini
   
    * *or load default file with:*
   
    > ini_load(ini)
   
    * *or create the content yourself:*
   
    (Start Code)
    ini =
    (
    [Tip]
    TimeStamp = 20090716194758
    [Recent File List]
    File1=F:\testfile.ahk
    File2=Z:\tempfile.tmp
    )
    (End Code)
   
    In this example "Tip" and "Recent File List" are name of the sections. The
    file consist in this example of 2 sections. Every section contains variables,
    so called "keys". Every key is a part of a section. In this example, the
    section "Tip" have one key "TimeStamp". And every key has a content,
    called value. The "TimeStamp" key have the value "20090716194758".
   
    After that, you can access and modify the content of the ini variable with
    the following functions. But the modifications are only temporary and must
    me saved to disk. This should be done by overwriting the source (not
    appending).
   
    *Notes*: A keys content (the value) goes until end of line. Any space
    surroounding the value is at default lost. For best compatibility, the
    names of section and key should consist of alpha (a-z), num (0-9) and the
    underscore only. In general, the names are case insensitiv.

Links:
    * Lib Home: [http://autohotkey.net/~Tuncay/lib/index.html]
    * Download: [http://autohotkey.net/~Tuncay/lib/ini.zip]
    * Discussion: [http://www.autohotkey.com/forum/viewtopic.php?t=46226]
    * License: [http://autohotkey.net/~Tuncay/licenses/newBSD_tuncay.txt]

Date:
    2010-09-26

Revision:
    1.0

Developers:
    * Tuncay (Author)
    * Mystiq (Tester and Co-Author of an important regex)
    * Fry (Tester)

Category:
    String Manipulation, FileSystem

Type:
    Library

Standalone (such as no need for extern file or library):
    Yes

StdLibConform (such as use of prefix and no globals use):
    Yes

Related:
    *Format Specifications (not strictly implemented)*
    * Wikipedia - INI file [http://en.wikipedia.org/wiki/INI_file]
    * Cloanto Implementation of INI File Format [http://www.cloanto.com/specs/ini.html]
   
    *AutoHotkey Commands*
    * IniRead: [http://www.autohotkey.com/docs/commands/IniRead.htm]
    * IniWrite: [http://www.autohotkey.com/docs/commands/IniWrite.htm]
    * IniDelete: [http://www.autohotkey.com/docs/commands/IniDelete.htm]
   
    *Other Community Solutions*
    * INI Library by Titan: [http://www.autohotkey.com/forum/viewtopic.php?t=26141]
    * [Class] IniFile by bmcclure: [http://www.autohotkey.com/forum/viewtopic.php?t=41506]
    * [module] Ini by majkinetor: [http://www.autohotkey.com/forum/viewtopic.php?t=22495]
    * Auto read,load and save by Superfraggle: [http://www.autohotkey.com/forum/viewtopic.php?t=21346]
    * globalsFromIni by Tuncay: [http://www.autohotkey.com/forum/viewtopic.php?t=27928]
    * Read .INI file in one go by Smurth: [http://www.autohotkey.com/forum/viewtopic.php?t=36601]

About: Examples
   
Usage:
   
    (Code)
    value := ini_getValue(ini, "Section", "Key")                    ; <- Get value of a key.
    value := ini_getValue(ini, "", "Key")                           ; <- Get value of first found key.
    key := ini_getKey(ini, "Section", "Key")                        ; <- Get key/value pair.
    section := ini_getSection(ini, "Section")                       ; <- Get full section with all keys.
   
    ini_replaceValue(ini, "Section", "Key", A_Now)                  ; -> Update value of a key.
    ini_replaceKey(ini, "Section", "Key")                           ; -> Delete a key.
    ini_replaceSection(ini, "Section", "[Section1]Key1=0`nKey2=1")  ; -> Replace a section with all its keys.
   
    ini_insertValue(ini, "Section", "Key" ",ListItem")              ; -> Add a value to existing value.
    ini_insertKey(ini, "Section", "Key=" . A_Now)                   ; -> Add a key/value pair.
    ini_insertSection(ini, "Section", "Key1=ini`nKey2=Tuncay")      ; -> Add a section.
   
    keys := ini_getAllKeyNames(ini, "Section")                      ; <- Get a list of all key names.
    sections := ini_getAllSectionNames(ini)                         ; <- Get a list of all section names.
    (End Code)

About: Functions

Parameters:
    Content         - Content of an ini file (also this can be one section
                        only).
    Section         - Unique name of the section. Some functions support the
                        default empty string "". This leads to look up at
                        first found section.
    Key             - Name of the variable under the section.
    Replacement     - New content to use.
    PreserveSpace   - Should be set to 1 if spaces around the value of a key
                        should be saved, otherwise they are lost. The
                        surrounding single or double quotes are also lost.

    The 'get' functions returns the desired contents without touching the
    variable.
   
    The 'replace' and 'insert' functions changes the desired content directly
    and returns 1 for success and 0 otherwise.
   
    There are some more type of functions and parameters. But these are not listed
    here.

Remarks:
    On success, ErrorLevel is set to '0'. Otherwise ErrorLevel is set to '1' if
    key under desired section is not found.
   
    The functions are not designed to be used in all situations. On rare
    conditions, the result could be corrupt or not usable. In example, there
    is no handling of commas inside the key or section names.
    Any "\E" would end the literal sequence and switch back to regex. The
    "\E" sequence is not escaped, because its very uncommon to use backslashes
    inside key and section names. To workaround this, replace at every key or
    section name the "\E" part with "\E\\E\Q":
   
    > Name := "Folder\Edit\Test1"
    > IfInString, Name, \
    > {
    >     StringReplace, Name, Name, \E, \E\\E\Q, All
    > }
    > MsgBox % ini_getValue(ini, "paths", Name)

    This allows us to work with regex, but then at the end it should be closed
    with "\Q" again.
    > ; Used regex at keyname: "Time.*"
    > value := ini_getValue(ini, "Tip", "\ETime.*\Q")
*/


Only full libraries or applications have such comprehensive headers. But nearly all published scripts have at least the most of these basics, which are the following: License, Link(s), Date, Revision, Developers / Author, Category, Type, Standalone, StdLibConform.

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2011, 5:20 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
My typical heading:
Code:
/*
Name:    Mango: Columns
By:      tidbit
Created: Thu December 15, 2011
version: 1.50 (Mon December 26, 2011)

About:
   A small program that takes a set of text and makes nicely aligned columns out of it.

Hotkeys:
   Ctrl + O           Open
   Ctrl + S           Save
   Alt + S            Save to Clipboard
   Ctrl + Shift + S   Save Settings
   Ctrl + R           Reload
   Ctrl + W           Exit
   Ctrl + Enter       Update Manually
   Enter              Update Manually (When in the left Settings Column)
   F1                 About

Notes:
   This has been created as part of my main script: Mango.
   You can delete Columns_Settings.ini and the next time the program is ran, It'll generate the default file.
   This code is NOT optimized. It does 1 thing at a time. -
    - I did not try and mash as many things into as little amount of code as possible.
    - It works and that's all I care about :).
   Requires AHK_L.
    - Unicode prefered. save in UTF-8 format.

Credits:
   infogulch           PlaceHolder function for edit controls.
   Superfraggle & Art  Tooltip function.
   titan/Polyethene    Achor resizing function.
   tkoi                ILButton function, Buttons with an image.
   zzzooo10            ini Objects with _L and unicode support.
*/


Sometimes their is more or less info.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group