Page 1 of 1

English to Finnish String Replace Problem

Posted: Sun Dec 28, 2008 10:21 pm
by Mark.s
Hello, i am making a English to Finnish compiler. But now i have problem in this.

In lang file are:

Code: Select all

test

Call 

out
I want those to:

Code: Select all

testi  

kutsu 

ulos 
But code changes that lang words to this:

Code: Select all

testi 
testi 
kutsu 
kutsu 
ulos 
So how i can do that right? In source are:

Code: Select all

Dim string.s(99)

Macro Instr(Begin,OriginalString,StringToFind) 
 FindString(OriginalString,StringToFind,Begin) 
EndMacro 

Procedure.s GetWord(_Stri$,Which,Separator$)
    For Iterator = 1 To Len(_Stri$)
      ConStri$ = ConStri$ + Mid(_Stri$,Iterator,1)
      If InStr(1,ConStri$,Separator$) 
        Count = Count + 1
        If Count = Which 
          ProcedureReturn Left(ConStri$,Len(ConStri$)-1)
        EndIf
        ConStri$ = ""
      EndIf
    Next Iterator
    ProcedureReturn ConStri$
EndProcedure

If ReadFile(0,"file.Lang")
  i = 0
  While Eof(0) = 0
    s$ = Trim(ReadString(0)) + " "

    com$ = GetWord(s$, 1," ") 
    s$ = Right(s$, Len(s$) - Len(com$) - 1) 
   
    Select LCase(com$)
      Case "console"
         s2$ = "konsoli"
      Case "hi"
         s2$ = "terve"
      Case "wait"
         s2$ = "odota"
      Case "end"
         s2$ = "loppu"
      Case "Finland"
         s2$ = "Suomi"
      Case "title"
         s2$ = "Otsikko"
      Case "test"
         s2$ = "testi"
      Case "call"
         s2$ = "kutsu"
      Case "out"
         s2$ = "ulos"
    EndSelect
    string.s(i) = s2$ + " " +  s$
    i + 1
  Wend
  
  CloseFile(0)
  for i = 0 to 15
      debug string.s(i)
  next 
Endif

Posted: Sun Dec 28, 2008 10:23 pm
by Kaeru Gaman
set s2$ to "" again at the beginning of the loop.

... and next time, please chose a descriptive topic title.

Posted: Mon Dec 29, 2008 10:47 am
by Rings
edited topic