# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
def isint(s):
    if len(s) == 0:
        res = False
    else:
        res = True
        for i in range(len(s)):
            if (s[i] < '0') or ('9' < s[i]):
                if (i != 0) or (s[i] != '-'):
                    res = False
    return res

def isintx(s):
    if len(s) == 0:
        res = False
    else:
        res = True
        for i in range(len(s)):
            if (ord(s[i]) < 48) or (57 < ord(s[i])):
                if (i != 0) or (ord(s[i]) != 45):
                    res = False
    return res

def test(s):
    print('"%s" : %r' % (s, isint(s)))
    print('"%s" : %r' % (s, isintx(s)))

test('123')
test('-123')
test('ABC')
test('123X')
test('')
