Jump to content

GUI Conversion Script!


CyberSlug
 Share

Recommended Posts

Attached is ConvertGUI 0.1.1, a script that attempts to convert old-style GUI syntax to new-style. :(

Motivation: I didn't want AutoBuilder to become obsolete yet, I sorta promised I'd write a GUI conversion script; and I had to be "on call" for work which limited my weekend plans :ph34r:

Important Notes

0) Some bug fixes, but there are flaws in some underling assumptions. For example, I assume that parameters to GUI functions do not contains nested function calls.... Everything is ad-hoc, so I'm not sure the best way to parse the code :lol:

1) It is impossible to fully convert a script at compile time. Consider the example GUISetControl($var, "text", $left, $top)

If $var is a control type like "button", then I should convert it into GuiCtrlCreateButton.

However, if $var is a gui controlID, then I should convert the statement into GuiSetData, GuiCtrlSetPos, and GuiCtrlSetStyle.....

Since I have no way of knowing which case is correct, I perform GuiCtrlCreateXXX conversion when the type parameter is a literal string and perform the other conversion when the type param is a variable. The resulting code will contain a "CONVERSION WARNING" in any ambigious cases.

2) Do not expect your converted script to run out of the box. For example, my conversion could lead to badly formed AutoIt code if you have GUICreateEx function within a single-line IF statement.

3) I quit coding when I was able to successfully convert http://www.autoitscript.com/fileman/users/public/!Josbe/ with only a minor edit! (The edit was changing $typeCTRL to "label" in Line#128 due to the Conversion Warning mentioned above.)

4) Since my conversion removes a lot of white space, you may want to run the resulting output through http://www.autoitscript.com/fileman/users/jdeb/jdeb_autoit_stuff.htm!

5) Bug reports and easy-to-implement suggestions are welcome... but I don't promise to respond in a timely manner :lol:

Code is based on a list of GUI changes jpm send me.

Edit: Fixed typos in above text.

ConvertGUI.au3

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

My first conversion blow up at line 222 one the arg I assume 4 is not define

Thanks again

<{POST_SNAPBACK}>

Darn.

Workaround: Add the following line before 222

If UBound($args) < 4 Then ContinueLoop

I should mention that my script will probably crash if you have words such as "GuiSetControl" in comments or literal strings..... I look for these keywords regardless of context.... I added UBound checks in a few places because of this potential problem, but it looks like I missed one.

Thanks for the feedback!

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Darn.

Workaround: Add the following line before 222

If UBound($args) < 4 Then ContinueLoop

I should mention that my script will probably crash if you have words such as "GuiSetControl" in comments or literal strings..... I look for these keywords regardless of context....  I added UBound checks in a few places because of this potential problem, but it looks like I missed one.

Thanks for the feedback!

<{POST_SNAPBACK}>

The line is

GUISetControl($_HWFlg[$i], StringMid(StringStripWS($H_[$i],2), 3) )

Thanks for the superfast answer

Link to comment
Share on other sites

The line is

GUISetControl($_HWFlg[$i], StringMid(StringStripWS($H_[$i],2), 3) )

Thanks for the superfast answer

<{POST_SNAPBACK}>

I thought GuiSetControl required at least four paramters and I only see two in your example....

My _StripSpace function is causing the problems of NOT joining with StringIsInt .... I didn't test it on complex boolean expressions.... I hope to post a fixed verison tomorrow.

EDIT: Possible fix around line 357 before I fall asleep:

ElseIf $char = " " And $quote = "" And $paren > 0 And (StringMid($str,$i+1,1) = "," OR StringMid($str,$i-1,1) = ",") Then

Workaround: Only try to convert *simple* scripts :ph34r:

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

The splitting of GUIWrite between GUICtrlSetData and GUICtrlSetState is not working.

Perhaps you can also avoid to generate the splitting when it is setting the default value

GUISetControlEX($id,0,-1,-1,"par") just generate GuiCtrlSet...

I hope you have a good rest

EDIT attach an update

EDIT suppress the update see top of the thread

Edited by jpm
Link to comment
Share on other sites

Uploaded a new attachment

There are some problems in my underlying assumptions...... and all this ad-hoc text processing is rather borning to code, so I don't know about updates.....

See first post for updates.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

You really don't like text processing, do you CS?

<{POST_SNAPBACK}>

Are you saying that because of my comments in this thread or because of my really ugly code :ph34r:

Regular expressions would be nice... too bad I don't know Perl or Python well enough to write code in it.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I'm asking because of your comments and because of you making the comment in another thread about my text-processing insight being better than yours. I haven't looked at your code because I've only got one GUI script left to convert and it should take about as much time as downloading and running your script would.

Link to comment
Share on other sites

well.... thanx CS for providing the Converter from old syntax to new syntax !

Great work :ph34r:

A little bit of suggestion.... whenever I see the post, I always don't know which

one to download, whereas there are few attachments there. I don't know which

is the latest....

Therefore, is it possible for you guys to always put the LATEST attachment in

the first thread and stated down the last update date ?

By having this.... other users (like me) will know exactly which one to download.

Hope you guys can make it that way.... that is my little suggestion.

Anyway.... thanks for sharing great things with us ! :(

Link to comment
Share on other sites

Heck. More bugs: GuiWrite(...) sometimes remain even though they are converted. If you have leftover GuiWrites, simply remove them.

I believe the bug is in line# 171 in ConvertGUI. Try changing the line to

$flatCode[$i] = $startOfLine & @CRLF & "GuiCtrlSetData(" & $args[1] & "," & $args[3] & ")"

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I tested ConvertGUI.... and I'm not sure it is a bug or what.

When you run the ConvertGUI, and select a file which to be converted.

After processing, a new file will be created (with new syntax).

However, the original file syntax also changed to new syntax.

Isn't the original file should remain the contents ?? :ph34r:

Please check and confirm.... :">

Link to comment
Share on other sites

When you run the ConvertGUI, and select a file which to be converted.

After processing, a new file will be created (with new syntax).

However, the original file syntax also changed to new syntax.

Isn't the original file should remain the contents ??  :ph34r:

When you convert a file, a new file is created and the original file is not modified.

The new file should contain only new syntax, but there are still bugs in my conversion script. The original file should not change....

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • 2 weeks later...

One thing I noticed...

Spaces are stripped that sometimes affect window text references like...

WinWait("AutoIt Forums->Replying")

when it should be

WinWait("AutoIt Forums -> Replying")

Just thought I'd give the feedback. But this is a very useful script and works fine overall and thanks to CS for sharing it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...