Jump to content

Need advice on finding tutorial


Recommended Posts

I'm pretty much new to programming of any sort and I've been reading through several of the helpful tutorials around. But, I want to do a few specific operations that I can't find information on. I'm trying to make a GUI editor for a game's AI config files. There is some text in the config file (Enemy name etc) but most of it is binary number values as in "00 @ 0x30 = defending off" "01 @ 0x30 = defending on).

One main thing I need to do is 'send' assembled data to a generic data file (aka save the new config file to disk). I've seen the tutorials on saving a txt file through simulated keystrokes, but I doubt that is the best way to go for text/binary data.

Any advice or tutorial links would be greatly appreciated- Thanks! :mellow:

Link to comment
Share on other sites

Hi and Welcome to the forums!

Look at FileOpen() and FileWrite() in the helpfile, there's examples there too :mellow:

Edited by AdmiralAlkex
Link to comment
Share on other sites

Thanks again AdmiralAlkex, you narrowing down where to look has really helped. Now I'm starting to understand some of the lingo enough to where I can mentally process the help file's info. I've gotten the bare-bones load/save functions outlined and working- yay!

One more question- can someone point me to the functions for limiting how much text the user can type into a GUI 'input' box. There are 30 characters available for enemy names so I need to restrict the input to that length. Thanks! :mellow:

Link to comment
Share on other sites

One more question- can someone point me to the functions for limiting how much text the user can type into a GUI 'input' box. There are 30 characters available for enemy names so I need to restrict the input to that length. Thanks! :mellow:

If you are referring to GUICtrlCreateInput() then look at GUICtrlSetLimit().

GUICreate(@ScriptName, 640, 240)
GUICtrlCreateInput("Write here", 10, 10, 400, 30)
GUICtrlSetLimit(-1, 30)
GUISetState()

Do
Until GUIGetMsg() = -3   ; -3 = $GUI_EVENT_CLOSE

:)

Link to comment
Share on other sites

Perfect! Thank you. This programming stuff is kind of fun; I feel like a kid on Christmas morning every time I run the code to see if my changes did what I hope. I keep bugging my wife- making her come and see, "Look hon, I made a data file with "00" in it!!!" She kind of rolls her eyes, pats me on th head and goes back to what she was doing ha ha. :mellow:

Link to comment
Share on other sites

I ran into another quandary. My GUI has two Input Boxes for numbers entered by the user.

The value in Box2 needs to be at least as big as Box1 so I'm using this:

If GUICtrlRead( $InputBox1) > GUICtrlRead( $InputBox2) Then
GUICtrlSetData($InputBox2, GUICtrlRead($InputBox1))
EndIf

Problem is, it's treating the input boxes values like an alphabetized list-

namely "8 > 7" comes out true but "18 >7" fails because 18 starts with a 1.

Is there a fix/workaround for this? Thanks :mellow:

Edited by EddieBoy
Link to comment
Share on other sites

Ran into another quandary. Tried all day to figure it out but no luck so hope someone can help.

I'm trying to delete the selected line from the list when the 'delete' button is pushed but I can't get it to work.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ListViewConstants.au3>
#include <ListboxConstants.au3>

$GUI_Main= GUICreate("GUI", 600, 510)


$List = GUICtrlCreateListView("1|2|3", 25, 45, 150, 100)

$Delete_Button = GUICtrlCreateButton("Delete Selected Entry", 25, 145, 150, 25)
$Input = GUICtrlCreateInput("000,0000,1", 25, 175, 80, 20)
GUICtrlSetLimit ($Input, 10)
$Add_Button= GUICtrlCreateButton("Add", 105, 175, 60, 25)

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()


    Switch $nMsg

        Case $Input
            If StringRegExp(GUICtrlRead($Input), "[^\d\,]") Then
                GUICtrlSetData($Input, StringRegExpReplace(GuiCtrlRead($Input), "[^\d\,]", ""))
            EndIf


        Case $Add_Button
            $Temp = GUICtrlRead($Input)
            $Temp = StringRegExpReplace($Temp, ",", "|")
            GUICtrlCreateListViewItem($Temp,$List)

; PROBLEM!
        Case $Delete_Button
            $Selected = GuiCtrlRead($List)
            $Item_To_Delete = ControlCommand ( $GUI_Main, "", $List, "FindString", $Selected  )
            ControlCommand ( $GUI_Main, "", $List, "DelString", $Item_To_Delete  )



        Case $GUI_EVENT_CLOSE
            Exit



    EndSwitch
WEnd
Link to comment
Share on other sites

ArgHHH!! Nevermind. Just found out I was researching the wrong type of control. I am using a 'List View' but was using delete commands for a 'List Box'. Which explains why I couldn't get anything to work.

Anyways, the answer couldn't be simpler!

_GUICtrlListView_DeleteItemsSelected($hWnd)

Hopefully my stupidity will help someone else. :mellow:

Link to comment
Share on other sites

A related question. Is there style etc that auto-sorts list view entries numerically?

My list view will only have numbers but $LVS_SORTASCENDING sorts lines as 'letters' as in:

1, 10, 100, 2, 20 etc

I tried GUICtrlCreateListViewItem(int ($num [1]) & "|" & int ($num [2]) & "|" & int ($num [3]) ,$List)

but it still sorts lines as if alphabetized. I can probably figure how to do it manually by reading the

listview's lines and rearranging them, but just wondering if there's a 'prefabricated' method.

Thanks :mellow:

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...