'Convert Windows Latin-1 to MacRoman / ver. 0.50 / by Kabuneko 2000/03/27

'y + umlaut (&hff) is excluded to avoid error on Japanese system

'Windows Latin-1 Upper ASCII Table
'
'
'
'
'
'
'
'
'

'MacRoman Upper ASCII Table
'
'A
'
'߮ 
'          
'   Ռ
'     
'
'        

const mac$ = "A߮              Ռ             "

proc main 'Win to Mac

    if @hwnd = 0 then exit proc
    dim char, r
    r = msgbox("Convert Windows Text to Mac Text?", 1)
    if r = IDCANCEL then exit proc

    @@Redraw = 0            'suppress display
    @UndoBlock = 1          'facilitate Undo
    @@FindRegExp = 1        'use regular expression
    @@FindRegExp = -2       'restore user setting afterwards
    @MoveFileTop
    @MoveBeginningLine

    do while 1
    @FindStringBottom "[-]"
        if @@SearchFound = 0 then exit do
        char = instr(mac$, chr$(@Code))
        if char > 0 then
            @Insert chr$(char + 127)
        else
            @Insert " "     '## use this string for chars not found in list
        end if
        @DeleteChar
        @MoveLeftChar       'move back to char just converted
    loop

    @ReturnCode = 2         'set return code to CR
    @MoveFileTop
    @ReplaceString2 "\n", "\n", 1

    @UndoBlock = 0
    @@Redraw = 1
    call msgbox("Conversion Done!")

end proc

proc mac2win 'Mac to Win

    if @hwnd = 0 then exit proc
    dim char, r
    r = msgbox("Convert Mac Text to Win Text?", 1)
    if r = IDCANCEL then exit proc

    @@Redraw = 0            'suppress display
    @UndoBlock = 1          'facilitate Undo
    @@FindRegExp = 1        'use regular expression
    @@FindRegExp = -2       'restore user setting afterwards
    @MoveFileTop
    @MoveBeginningLine

    do while 1
    @FindStringBottom "[-]"
        if @@SearchFound = 0 then exit do
        char = @Code
        @Insert mid$(mac$, char - 127, 1)
        @DeleteChar
        @MoveLeftChar       'move back to char just converted
    loop

    @ReturnCode = 0         'set return code to CR/LF
    @MoveFileTop
    @ReplaceString2 "\n", "\n", 1

    @UndoBlock = 0
    @@Redraw = 1
    call msgbox("Conversion Done!")

end proc