PDA

View Full Version : does anyone have a program



kryton9
02-06-2008, 08:03
Actually instead of trying to explain it, it is probably easier just to show.
Using a text file it will go through and take code that looks like this:

IF TBGL_GETWINDOWKEYSTATE( HWND, %VK_UP) THEN CAM.DELTAMOVE += 5/FRAMERATE

and by running through the list and also some additional checks for coding style end up as:

If tbgl_GetWindowKeyState ( hWnd, %vk_Up ) Then Cam.DeltaMove += 5 / FrameRate

The latest is located here:
http://community.thinbasic.com/index.php?topic=1812.0

kryton9
02-06-2008, 09:36
I found a list of 3000 words and have been going through and editing it and got it down to 2034 words.
I wanted to mention this, in case anyone else thinks about doing something similar with the list in the first post.

Michael Clease
02-06-2008, 11:32
your link just points at a create your own website portal ???

matthew
02-06-2008, 12:42
your link just points at a create your own website portal ???


I think that this (http://www.mieliestronk.com/wordlist.html) might be the correct link.

Michael Clease
02-06-2008, 14:14
Sorry if my previous post was a bit short but no I don’t have a script for that :)

I am glad they deleted the American version and that they have chosen the correct way of spelling. British English. :P ;D

Thanks

Matthew

kryton9
02-06-2008, 18:24
I don't know what happened to the link Abraxas, but sorry that it messed up. Matthew has the working link in his Post.
Here is my latest list that I am editing down and then adding too as needed.

I posted my current list in the first post. This is edited down from another list I got of 3,000 of the most common words.
I will continue to edit it until over time, the mix casing works pretty well. Since I didn't see any existing scripts, I will work on one today
as a start to see how it goes :)

Thanks for the link help Matthew!

kryton9
02-06-2008, 21:33
I am experimenting with the Replace$ command.
It works one way, but then in my main development test project it doesn't. I am lost as to why ?

This works:

Dim MainText As String VALUE "IF TBGL_GETWINDOWKEYSTATE(HWND, %VK_TAB) THEN"
Dim MatchText As String VALUE "TBGL_"
Dim ReplaceText As String VALUE "tbgl_"
Dim s,s1,s2 As String
s1 = REPLACE$(MainText, MatchText, ReplaceText)
s2 = REPLACE$("IF TBGL_GETWINDOWKEYSTATE(HWND, %VK_TAB) THEN", "TBGL_", "tbgl_")
s = s1 + $crlf +s2+$crlf+"Both of these work"
MSGBOX 0, s

But this doesn't:

uses "ui"
uses "file"
dim file as string
dim filter, s as string
filter = "thinbasic files (*.tbasic, *.tbasicc)|*.tbasic;*.tbasicc|"
filter += "all files (*.*)|*.*"
file = dialog_openfile(0, "open a file",dir_getcurrent , filter, "tbasic", %ofn_filemustexist or %ofn_hidereadonly or %ofn_enablesizing)
'--- msgbox 0, file

dim t1, t2 as ext
dim num_lines , x as long
dim file_in as string value file_load(file)
dim file_out as string value "outfile_mixedcase.txt"
dim output_text as string
dim file_in_lines() as string
dim count as long

num_lines = parsecount(file_in, $crlf)
num_lines = parse(file_in, file_in_lines, $crlf)

for count = 1 to num_lines
for x = 1 to len(file_in_lines(count))
mid$(file_in_lines(count),x,1) = ucase$(mid$(file_in_lines(count),x,1))
next
'msgbox 0,"before >"+file_in_lines(count)+"<"
s = file_in_lines(count)
replace$( s, "TBGL_", "tbgl_") '<<<<<<<<<<<<<< why doesn't this work as I expect?
'msgbox 0,"changed? >"+file_in_lines(count)+"<"
output_text += s + $crlf
next

file_save(app_sourcepath + file_out , output_text)

It saves to a file named: outfile_mixedcase.txt
But as you will see it doesn't seem to work.

I removed the attachment, the latest version will be here:
http://community.thinbasic.com/index.php?topic=1812.0

Petr Schreiber
02-06-2008, 21:39
Kent,

try to change:


replace$( s, "TBGL_", "tbgl_") '<<<<<<<<<<<<<< why doesn't this work as I expect?


to:


s = replace$( s, "TBGL_", "tbgl_") '<<<<<<<<<<<<<< why doesn't this work as I expect?


You tried to use replace$ as a command, but it is a function.


Petr

kryton9
02-06-2008, 21:47
Thanks Petr, I would have wasted all day and not think of that!!

kryton9
03-06-2008, 00:04
I was surprised with how much can be done with minimal code and pretty quickly.
I think once the word lists are tweaked maybe Roberto can put this into thinAir.

The latest version will be here:
http://community.thinbasic.com/index.php?topic=1812.0