Sign in to follow this  
Followers 0
lokster

Parsing Koda .kxf file?

14 posts in this topic

Hm... I got an Idea to make script which parses Koda *.kxf file and creates the form defined in it.

Something like Glade. I mean, instead of

$Form1 = GUICreate("Form1", 320, 240, -1, -1)
;etc. ....
GUISetState(@SW_SHOW)
oÝ÷ Ù:!j÷¬¢g­)à)jëh×6
GUICreateFromKXF("form1.kxf")

The XML parsing is not a big problem.

The problem is that I don't know is it possible to create variable variables in autoit, so when the XML parser finds

<object type="TAForm" name="AForm1">

to create variable named $AForm1... Any Ideas?

Share this post


Link to post
Share on other sites



Hm... I got an Idea to make script which parses Koda *.kxf file and creates the form defined in it.

...

The XML parsing is not a big problem.

The problem is that I don't know is it possible to create variable variables in autoit, so when the XML parser finds

<object type="TAForm" name="AForm1">

to create variable named $AForm1... Any Ideas?

I think this can be easily done with UDF. Autoit can create variables with Assign function.

But what the advantage of this method over regular? You anyway need to handle your GUI in some way.

Share this post


Link to post
Share on other sites

But what the advantage of this method over regular? You anyway need to handle your GUI in some way.

Yes, of course, but why not? I will try it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <array.au3>
$sString = FileRead('AForm1.kxf')
$aArray = StringRegExp($sString, '(?s)(?i)\<object type=".*?" name="(.*?)">', 3)
$sHoldArray = ''
For $iCC = 0 To UBound($aArray) - 1
    $sHoldArray &= '$' & $aArray[$iCC] & @LF
Next
$aNewArray = StringSplit(StringTrimRight($sHoldArray, 1), @LF)
_ArrayDisplay($aNewArray)

Edit:

After reading this again, I may have the wrong idea of what you are wanting ...

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Hmm, interesting idea but it does mean you have to include a GUI file with the code.

I'd rather have Koda accept actual script and you can edit that.

Share this post


Link to post
Share on other sites

that would indeed be verry strong functionality (@manadar)

I was hoping KODA could one day figure out from a script what the gui form should look like.


Share this post


Link to post
Share on other sites

No SmOke_N - you get the idea right. Today I sarted to work on form parser with _XMLDomWrapper.au3

Share this post


Link to post
Share on other sites

But Zenda, Import is not equal to editing the actual gui code. For me it's not practical to have the gui stored in 2 different files with two different formats - the .kxf file and the real au3 code.

This is my personal opinion. Anyway, I will continue wokring on the kxf parser script and when (if) I finsh it I will post i in the forum - maybe someone will make use of it.

Share this post


Link to post
Share on other sites

I think you've got a good idea going here. You said you were unsure how to create variables, look up Assign() in the help file. It allows you to declare variables if they do not exist when you set them using Assign().

Share this post


Link to post
Share on other sites

10x Mr Icekirby, but in the 2nd post Lazycat told me about this func.

I already have partially working parsing of the kxf, but for now it's too buggy and incomplete to post it...

Share this post


Link to post
Share on other sites

But Zenda, Import is not equal to editing the actual gui code. For me it's not practical to have the gui stored in 2 different files with two different formats - the .kxf file and the real au3 code.

This is my personal opinion. Anyway, I will continue wokring on the kxf parser script and when (if) I finsh it I will post i in the forum - maybe someone will make use of it.

Technically it's not impossible to save/load actual code, but in this case generated code should have strong structure, for example without literal styles that allow easier code reading by human, but harder parsing.

Second way, that some time ago I had a thought: xml - is just a text, so it's possible to keep form in the script inside comment tag. This is very easy to implement, except the only problem - when big picture loaded, size of form grows a lot, so it's need to change in way, that pictures will not keep inside form (this behaviour btw I'm dislike a long time).

Share this post


Link to post
Share on other sites

Oh, I didn't notice that Lazycat said that. Are you parsing the kxf using your own code or a generic XML reader?

Share this post


Link to post
Share on other sites

I am using the _XMLDomWrapper.au3 UDF, but later maybe I will try without it - I don't want the final script to be dependent on other scripts.

Share this post


Link to post
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
Sign in to follow this  
Followers 0