Results 1 to 8 of 8

Thread: file and replace qt :)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    Jul 2009
    Age
    44
    Posts
    57
    Rep Power
    21

    file and replace qt :)

    hello.

    I am working out a new project. will include all parts at the end in my gui with a lot of functions !. perhaps this first step is fussy or antique, but I go this way to make it. If anyone knows better way, say it. I am open to make it better. there might be better way to use replacing words by open files !

    my script includes textfile to load. but how I can change text file by open any script file if I don`t know what script I am using with ? *laugh* other things you see when I show the script.

    I suppose better use file_seek file_put or other things, then replace words. the script works, but not for replacing these two words I wished: "ZUCCHERO" into "zucherox" (only an example). see you.

    my script:

    [code=thinbasic] uses "file","console", "ui"

    dim lastString as string value "last one"
    dim newString as string value "new songs and lyrics"
    dim fileBuffer as string value ""
    dim lydFile as string value "lyd_test_song.txt"
    dim myResult as dword
    dim nfile as string
    dim sfilter, p as string
    dim numero_line, z as long
    dim nfile_putin as string value file_load(nfile)
    dim nfile_putout as string value "output_lydiaSongs.txt"
    dim my_output_text as string
    dim nfile_in_lines() as string
    dim counter as long

    printl

    '' 1 ) open file and replace words of song text file ------------------

    sfilter = "thinbasic files (*.tbasic, *.tbasicc)|*.tbasic;*.tbasicc|"
    sfilter += "all files (*.*)|*.*"
    nfile = dialog_openfile(0, "open a new file",dir_getcurrent , sfilter, "tbasic", %ofn_filemustexist or %ofn_hidereadonly or %ofn_enablesizing)
    numero_line = parsecount(nfile_putin, $crlf)
    numero_line = parse(nfile_putin, nfile_in_lines, $crlf)

    for counter = 1 to numero_line
    for z = 1 to len(nfile_in_lines(counter))
    mid$(nfile_in_lines(counter),z,1) = ucase$(mid$(nfile_in_lines(counter),z,1))
    next
    p = nfile_in_lines(counter)
    p = replace$( app_sourcepath + "lyd_test_song.txt" + p, "ZUCCHERO_", "zucherox_")
    my_output_text += p + $crlf
    next

    msgbox 0, "intermediate qt: all ok with script ?"

    file_save(app_sourcepath + nfile_putout , my_output_text)

    '' 2 ) load file and save it as copy with whole song text of zucchero -----------------

    printl
    printl "-- first work of replacing word done, I hope so !.."
    printl
    printl "-- next task.. save file, push any key "

    waitkey

    printl

    printl "hello, save my file and song text of zucchero"

    fileBuffer = file_load(lydFile)
    if lydFile = "" then msgbox 0, "good!: file was found and will save now.." end if

    fileBuffer = Replace$( fileBuffer, lastString, newString)
    if filebuffer = "" then msgbox 0, "error: no file was select and found..", %MB_ICONINFORMATION, "file error !" : stop

    myResult = file_save(app_sourcepath+"LydSavedSongCopy.txt", fileBuffer)

    printl

    if myResult = 0 then msgbox 0, "I have saved your file, it's all ok"
    else msgbox 0, "oh no, file save error!"
    printl
    printl "file was saved with success!"

    waitkey[/code]

    weapons out, please beat me!

    songtext of zucchero I include as attachement.

    good evening. lydia
    Attached Files Attached Files
    hasta la vida

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •