' q w not used
' 48=zero 57=nine
Sub Bong()
' Author Jayanta Narayan Choudhuri
'        Flat 302
'        395 Jodhpur Park
'        Calcutta 700 068
'        Email sss@cal.vsnl.net.in
Dim MyRoman As String
Dim Roman1(60) As String
Dim Roman2(60) As String
Dim Roman3(60) As String
Dim Roman4(60) As String
Dim Roman5(10) As String
Dim Roman6(10) As String

Dim MyBengali As String
Dim Bengali1(60) As String
Dim Bengali2(60) As String
Dim Bengali3(60) As String
Dim Bengali4(60) As String
Dim Bengali5(10) As String
Dim Bengali6(10) As String

Dim MyCount1 As Integer
Dim MyCount2 As Integer
Dim MyCount3 As Integer
Dim MyCount4 As Integer
Dim MyCount5 As Integer
Dim MyCount6 As Integer

Dim RomanText As String
Dim RomanFlag As String
Dim BengaliText As String
Dim RomanSize As String

Dim i As Integer
Dim j As Integer
Dim MyLen As Integer
Dim OneByte As String

RomanText = ActiveWindow.Selection.TextRange.Text
RomanSize = Len(RomanText)
If RomanSize = 0 Then
   MsgBox "Nothing Selected", , "Please Highlight"
   End
End If

RomanFlag = RomanText
For i = 1 To RomanSize
  Mid(RomanFlag, i, 1) = "0"
Next i

Open "c:\jnc\JNC_Roma.txt" For Input As 1
Open "c:\jnc\JNC_Bong.txt" For Input As 2

MyCount1 = 0
MyCount2 = 0
MyCount3 = 0
MyCount4 = 0
MyCount5 = 0
MyCount6 = 0

StartRead:
  If EOF(1) Then GoTo EndRead
  Line Input #1, MyRoman
  Line Input #2, MyBengali
  MyLen = Len(MyRoman)
  MyBengali = MyBengali
  
  Select Case MyLen
  Case 1
     MyCount1 = MyCount1 + 1
     Roman1(MyCount1) = MyRoman
     Bengali1(MyCount1) = MyBengali
  Case 2
     MyCount2 = MyCount2 + 1
     Roman2(MyCount2) = MyRoman
     Bengali2(MyCount2) = MyBengali & Chr$(0)
  Case 3
     MyCount3 = MyCount3 + 1
     Roman3(MyCount3) = MyRoman
     Bengali3(MyCount3) = Chr$(0) & MyBengali & Chr$(0)
  Case 4
     MyCount4 = MyCount4 + 1
     Roman4(MyCount4) = MyRoman
     Bengali4(MyCount4) = Chr$(0) & MyBengali & Chr$(0) & Chr$(0)
  Case 5
     MyCount5 = MyCount5 + 1
     Roman5(MyCount5) = MyRoman
     Bengali5(MyCount5) = Chr$(0) & MyBengali & Chr$(0) & Chr$(0) & Chr$(0)
  Case 6
     MyCount6 = MyCount6 + 1
     Roman6(MyCount6) = MyRoman
     Bengali6(MyCount6) = Chr$(0) & MyBengali & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0)
  Case Else
     MsgBox "JNC_ Files Corrupt", , "Fatal Error"
     End
  End Select
GoTo StartRead

EndRead:
Close #1
Close #2

Replace9227:
  j = InStr(RomanText, Chr$(&H92))
  If j <> 0 Then
     Mid(RomanText, j, 1) = Chr$(&H27)
     GoTo Replace9227
  End If

Search6:
For i = 1 To MyCount6
Loop6:
  j = InStr(RomanText, Roman6(i))
  If j = 0 Then GoTo next6
  Mid(RomanText, j, 6) = Bengali6(i)
  Mid(RomanFlag, j, 6) = "111111"
  GoTo Loop6
next6:
Next i

Search5:
For i = 1 To MyCount5
Loop5:
  j = InStr(RomanText, Roman5(i))
  If j = 0 Then GoTo next5
  Mid(RomanText, j, 5) = Bengali5(i)
  Mid(RomanFlag, j, 5) = "11111"
  GoTo Loop5
next5:
Next i

Search4:
For i = 1 To MyCount4
Loop4:
  j = InStr(RomanText, Roman4(i))
  If j = 0 Then GoTo next4
  Mid(RomanText, j, 4) = Bengali4(i)
  Mid(RomanFlag, j, 4) = "1111"
  GoTo Loop4
next4:
Next i

Search3:
For i = 1 To MyCount3
Loop3:
  j = InStr(RomanText, Roman3(i))
  If j = 0 Then GoTo next3
  Mid(RomanText, j, 3) = Bengali3(i)
  Mid(RomanFlag, j, 3) = "111"
  GoTo Loop3
next3:
Next i

Search2:
For i = 1 To MyCount2
Loop2:
  j = InStr(RomanText, Roman2(i))
  If j = 0 Then GoTo next2
  Mid(RomanText, j, 2) = Bengali2(i)
  Mid(RomanFlag, j, 2) = "11"
  GoTo Loop2
next2:
Next i

BengaliText = ""
RomanSize = Len(RomanText)
For i = 1 To RomanSize
  OneByte = Mid(RomanText, i, 1)
  If OneByte <> Chr$(0) Then
    If Mid(RomanFlag, i, 1) = "0" Then
       For j = 1 To MyCount1
         If OneByte = Roman1(j) Then
            OneByte = Bengali1(j)
            Exit For
         End If
       Next j
    End If
    BengaliText = BengaliText & OneByte
  End If
Next i

ActiveWindow.Selection.TextRange.Text = BengaliText
ActiveWindow.Selection.TextRange.Font.Name = "AdarshaLipiNormal"
ActiveWindow.Selection.TextRange.Font.Size = 72


End Sub

' For VB5 Project!!
Sub UnBong()
' Author Jayanta Narayan Choudhuri
'        Flat 302
'        395 Jodhpur Park
'        Calcutta 700 068
'        Email sss@cal.vsnl.net.in
Dim MyRoman As String
Dim Roman(256) As String
Dim MyBengali As String
Dim Bengali(256) As String
Dim MyCount As Integer

Dim RomanText As String
Dim BengaliText As String
Dim BengaliSize As Long

Dim i As Long
Dim j As Integer
Dim OneByte As String

BengaliText = ActiveWindow.Selection.TextRange.Text
BengaliSize = Len(BengaliText)
If BengaliSize = 0 Then
   MsgBox "Nothing Selected", , "Please Highlight"
   End
End If


Open "c:\jnc\JNC_Roma.txt" For Input As 1
Open "c:\jnc\JNC_Bong.txt" For Input As 2


MyCount = 0
StartRead:
  If EOF(1) Then GoTo EndRead
  Line Input #1, MyRoman
  Line Input #2, MyBengali
  MyCount = MyCount + 1
  Roman(MyCount) = MyRoman
  Bengali(MyCount) = MyBengali
GoTo StartRead

EndRead:
Close #1
Close #2

RomanText = ""
For i = 1 To BengaliSize
  OneByte = Mid(BengaliText, i, 1)
  For j = 1 To MyCount
  If OneByte = Bengali(j) Then
     GoTo BuildRoman
  End If
  Next j
RomanText = RomanText + OneByte
GoTo Nexti
BuildRoman:
RomanText = RomanText + Roman(j)
Nexti:
Next i

ActiveWindow.Selection.TextRange.Text = RomanText
ActiveWindow.Selection.TextRange.Font.Name = "Arial"
ActiveWindow.Selection.TextRange.Font.Size = 60


End Sub



