Skip to content

Instantly share code, notes, and snippets.

static void AjhBase36Test(Args _args)
{
// ajh 2014-05-07: 611.23
// adapted from http://en.wikipedia.org/wiki/Base_36.
// note: handles non-negative integers only.
#define.NBASE(36)
#define.CLIST("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
int64 base36_decode(str base36_input)
{
@andyhuey
andyhuey / isUserInRole.x++
Created March 3, 2014 15:09
isUserInRole - good
/// <summary>
/// return true is the specified user is in any of the roles in the roleNames container.
/// </summary>
/// <param name="axUserId">
/// AX user id, e.g. curUserId()
/// </param>
/// <param name="roleNames">
/// container of role names to check. (use role NAME, not label.)
/// </param>
/// <returns>
@andyhuey
andyhuey / isUserInRole.x++
Created March 3, 2014 15:07
isUserInRole - bad
/// <summary>
/// return true is the specified user is in any of the roles in the roleNames container.
/// </summary>
/// <param name="axUserId">
/// AX user id, e.g. curUserId()
/// </param>
/// <param name="roleNames">
/// container of role names to check. (use role NAME, not label.)
/// </param>
/// <returns>
@andyhuey
andyhuey / AjhTestTextBuffer
Created June 20, 2013 19:03
string concatenation in AX
static void AjhTestTextBuffer(Args _args)
{
// ajh 2013-05-24: is the TextBuffer faster than using string concatenation?
// from http://www.mail-archive.com/axapta-knowledge-village@yahoogroups.com/msg07289.html
TextBuffer tb;
str a,b;
int i,j;
int ts, te;
ts = WinAPI::getTickCount();
@andyhuey
andyhuey / AjhDictEnumTest
Last active December 18, 2015 18:19
Strange behavior from DictEnum class
static void AjhDictEnumTest(Args _args)
{
// originally from http://arsalanax.blogspot.com/2012/02/get-values-of-base-enums-using-code-in.html
EnumId enumId = enumNum(ActionType);
DictEnum dictEnum = new DictEnum(enumId);
int nElements = dictEnum.values();
int i;
for (i=0; i < nElements; i++)
{
@andyhuey
andyhuey / tfs3.ps1
Last active December 16, 2015 17:30
TFS diff
param (
[string]$cs1 = $( Read-Host "Enter changeset 1 (as c9999)" ),
[string]$cs2 = $( Read-Host "Enter changeset 2 (as c9999)" )
)
[string]$tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"
[string]$npp = "C:\Program Files (x86)\Notepad++\notepad++.exe"
[string]$tempFile = "$env:temp\tfDiff.diff"
pushd
cd c:\ax2012tfs
& $tf diff cus /v:$cs1~$cs2 /r /f:unified > $tempFile
@andyhuey
andyhuey / tfs2.ps1
Created April 26, 2013 23:20
TFS status
[string]$tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"
[string]$npp = "C:\Program Files (x86)\Notepad++\notepad++.exe"
# [string]$tempFile = [System.IO.Path]::GetTempFileName()
[string]$tempFile = "$env:temp\tfStatus.txt"
pushd
cd c:\ax2012tfs
& $tf status > $tempFile
popd
& $npp $tempFile
@andyhuey
andyhuey / tfs1.ps1
Created April 26, 2013 23:18
show last 50 check-ins
[string]$tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"
pushd
cd c:\ax2012tfs
& $tf history /r /stopafter:50 *
popd
@andyhuey
andyhuey / export all projects
Last active December 16, 2015 17:29
AX - export all active projects
public void exportAllProjects()
{
// get the project list, and export all projects.
Array projects;
int i;
ProjectNode sharedProjects, privateProjects, projectNode;
str myDocsPath, filePath;
#WinAPI
@andyhuey
andyhuey / remap_comment.ahk
Created April 26, 2013 11:28
remap MorphX comment/un-comment key commands
; comment/uncomment, the way it was intended to be...
#IfWinActive ahk_class AxMainFrame
^k::
Transform, CtrlC, Chr, 3
Transform, CtrlU, Chr, 21
Input Key, L1 M T1
if Key = %CtrlC%
Send ^e^c
if Key = %CtrlU%
Send ^e^u