home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Bila Vrana
/
BILA_VRANA.iso
/
028A
/
AUROR.ZIP
/
ASCII2.AML
< prev
next >
Wrap
Text File
|
1996-07-17
|
4KB
|
187 lines
//--------------------------------------------------------------------
// ASCII2.AML
// 2-Dimensional Ascii chart, (C) 1993-1996 by nuText Systems
//
// (See Ascii2.dox for user help)
//
// This macro displays a two-dimensional Ascii chart and shows character
// codes in decimal, hex, octal, and binary. The Ascii character at the
// cursor can be entered into the text of the current edit window.
//
// Usage:
//
// Select this macro from the Macro List (on the Macro menu), or run it
// from the macro picklist <shift f12>.
//--------------------------------------------------------------------
include bootpath "define.aml"
// colors
constant ascii_border_color = color white on gray
constant ascii_flash_color = color brightgreen on gray
constant ascii_title_color = color white on magenta
constant ascii_text_color = color black on gray
variable x, y, x2, asciival
// keep this object resident
resident ON
settype "win"
// create the ascii chart window
createwindow
setframe "bn"
setcolor border_color ascii_border_color
setcolor border_flash_color ascii_flash_color
setcolor north_title_color ascii_title_color
setcolor text_color ascii_text_color
settitle "2-D Ascii Chart - press <enter> to select"
setwinctrl '≡'
width = 47
height = 18
// center the window
ox = (getvidcols - width) / 2
oy = (getvidrows - height) / 2
sizewindow ox oy ox + width oy + height "ad"
setborder "1i"
setshadow 2 1
// draw the ascii chart
for y = 0 to 15 do
for x = 0 to 15 do
writestr (char 32 y * 16 + x 32)
end
writeline
end
// get last position
asciival = _ascii2
x = asciival mod 16
y = asciival / 16
showcursor 50 99
private function draw
if x2 then
// clear the bracket cursor
writestr ' ' '' x2 - 1
writestr ' ' '' x2 + 1
end
asciival = y * 16 + x
// write ascii info at the bottom of the chart
writestr ' char=' + (char asciival) +
' dec=' + asciival:3:'0' +
' hex=' + (base asciival 16):2:'0' +
' oct=' + (base asciival 8):3:'0' +
' bin=' + (base asciival 2):8:'0' +
'':8
(color white on magenta) 1 17
// move the cursor to the appropriate ascii cell
x2 = x * 3 + 2
gotoxy x2 y + 1
// write the bracket [ ] cursor
writestr '[' (color white on gray) x2 - 1
writestr ']' (color white on gray) x2 + 1
gotoxy x2 y + 1
end
draw
event <destroy>
// save current position for next time
prf.ascii2 = asciival
// pass on to 'close' function in win object
close
end
// mouse click
event <lbutton>
pass
case getregion
// client area
when 1
pass
if virtorow <= 16 then
y = (virtorow - 1) mod 16
end
x = (virtocol - 1) / 3
draw
end
end
event <ldouble>
call <enter>
end
event <move>
pass
if (button? 1) and getregion == 1 then
send <lbutton>
end
end
key <esc>
destroyobject
end
function '≡'
destroyobject
end
// macro help
macrofile = arg 1
key <f1>
helpmacro macrofile
end
// enter the ascii character in an edit window and exit
key <enter>
destroyobject
queue "write" (char asciival)
end
// move the cursor around in the chart
key <left>
x = if? x (x - 1) 15
draw
end
key <right>
x = (x + 1) mod 16
draw
end
key <up>
y = if? y (y - 1) 15
draw
end
key <down>
y = (y + 1) mod 16
draw
end
key <home>
x = 0
draw
end
key <end>
x = 15
draw
end
key <ctrl home>
y = 0
draw
end
key <ctrl end>
y = 15
draw
end