Jump to content

Setting value of an Input, getting 2 extra junk characters


 Share

Recommended Posts

I am trying to set the value of an input, It works fine except that i get to junk characters after the correct data. I beive it is a character return.

Here is my code: (see line 94, near bottom)

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.4.9

Author: myName

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>

#include <database.au3>

#include <A3LToolbar.au3>

Global Enum $idNew=1000, $idOpen, $idSave, $idHelp

; Script Start - Add your code below here

$main = GUICreate("Spell Inventory", 800, 500, -1,-1, $WS_OVERLAPPEDWINDOW)

GUISetState ()

$dbname = "C:\Documents and Settings\sjraisbe\Desktop\SI\database.mdb"

$tblname = "Spells"

$fldname = "Spell"

;MI = menu item

;-----File Menu-----

$fileMenu = GuiCtrlCreateMenu ("File")

$importMI = GuiCtrlCreateMenuitem ("Import File",$filemenu)

$separator = GuiCtrlCreateMenuitem ("",$filemenu)

$ppOptionsMenu = GuiCtrlCreateMenu ("Print Preview Options",$filemenu)

$separator = GuiCtrlCreateMenuitem ("",$filemenu)

$exitMI = GuiCtrlCreateMenuitem ("Exit",$filemenu)

;-----Tools Menu-----

$toolsMenu = GuiCtrlCreateMenu ("Tools")

$manageSpellbooksMI = GuiCtrlCreateMenuitem ("Manage Spellbooks",$toolsMenu)

$manageSchoolsMI = GuiCtrlCreateMenuitem ("Manage Schools",$toolsMenu)

$manageSpellsMI = GuiCtrlCreateMenuitem ("Manage Spells",$toolsMenu)

$separator = GuiCtrlCreateMenuitem ("",$toolsMenu)

$manageScrollsMI = GuiCtrlCreateMenuitem ("Manage Scrolls",$toolsMenu)

$separator = GuiCtrlCreateMenuitem ("",$toolsMenu)

$searchMI = GuiCtrlCreateMenuitem ("Search",$toolsMenu)

;-----Window Menu-----

$windowMenu = GuiCtrlCreateMenu ("Window")

$tileMI = GuiCtrlCreateMenuitem ("Tile",$windowMenu)

$separator = GuiCtrlCreateMenuitem ("",$windowMenu)

$cascadeMI = GuiCtrlCreateMenuitem ("Cascade",$windowMenu)

;-----About Menu-----

$aboutMenu = GuiCtrlCreateMenu ("About")

$helpTopicsMI = GuiCtrlCreateMenuitem ("Help Topics",$aboutMenu)

$separator = GuiCtrlCreateMenuitem ("",$aboutMenu)

$aboutMI = GuiCtrlCreateMenuitem ("About SI",$aboutMenu)

;$hToolbar = _Toolbar_Create($main)

; Add standard system bitmaps

;_Toolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

; Add buttons

;_Toolbar_AddButton ($hToolbar, $idNew , $STD_FILENEW)

;_Toolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)

;_Toolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)

;_Toolbar_AddButtonSep($hToolbar)

;_Toolbar_AddButton ($hToolbar, $idHelp, $STD_HELP )

$viewSpell = GUICtrlCreateButton ("1", 0,0,30,30,$BS_ICON)

GUICtrlSetImage (-1, "shell32.dll",134)

do

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitMI

ExitLoop

Case $msg = $viewSpell

$child = GUICreate("View Spells", 200, 200, 40, 0, $WS_OVERLAPPEDWINDOW)

DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child), "hwnd", WinGetHandle($main))

GUISetState ()

$Lspell = GUICtrlCreateLabel ("Spell", 10, 35, 70)

GUICtrlSetResizing (-1,$GUI_DOCKALL)

$IBspell = GUICtrlCreateInput ("", 40, 35, 100, 20)

GUICtrlSetResizing (-1,$GUI_DOCKALL)

$query = "SELECT " & $tblname & "." & $fldname & " FROM " & $tblname & " WHERE " & $tblname & ".ID=2"

$strData = _ReadOneFld($query, $dbname, $fldname)

GUICtrlSetData($IBspell, $strData)

Case $msg = $aboutMI

Msgbox(0,"About","Spell Inventory")

EndSelect

until $msg = $GUI_EVENT_CLOSE

GUIDelete()

Exit

Link to comment
Share on other sites

I am trying to set the value of an input, It works fine except that i get to junk characters after the correct data. I beive it is a character return.

Why not just delete the @CR and @LF characters and see if that gets rid of the problem then?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I did not add any charachters, they just showed up. If you are talking about deleting them using code, please explain how to.

Here is a rather long-winded example of getting rid of characters in a string

$f = 'start' & @CR & 'MIDDLE' & Chr(14) & 'end'
$wrong = ''
MsgBox(0,'string is',$f)
For $n = 1 To StringLen($f)
    $fmid = StringMid($f,$n,1)
    If (Not StringIsAlNum($fmid)) Then $wrong = $wrong & $fmid
    Next
    
If $wrong <> '' Then
    For $n = 1 To StringLen($wrong)
        $f = StringReplace($f,StringMid($wrong,$n,1),'')
    Next
EndIf

MsgBox(0,'corrected string is',$f)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...