dwaltosz Posted June 4, 2015 Share Posted June 4, 2015 so I am writing a Body Composition calc and a application to help with my clients but I have having trouble with the Fun menubar() and getting the notes to be added to the .txt file I got all the rest of the application to work but all that happens when I try to add notes it just adds the date and not the text that I put in the input. As always any help is much appreciatedexpandcollapse popup#RequireAdmin #include <WinAPIFiles.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <Date.au3> Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc Global $hGuiMain = GUICreate("Body Analysis Report", 500, 500) GUISetBkColor(0x009900) Global $date = @MON & "/" & @MDAY & "/" & @year Global $BT1 = GUICtrlCreateButton("Exit", 400, 450, 60) Global $BT2 = GUICtrlCreateButton("Calculate", 330, 450, 60) GUICtrlCreateLabel("Current weight", 8, 75) GUICtrlCreateLabel("Visceral Fat", 80, 75) GUICtrlCreateLabel("Current hight", 140, 75) GUICtrlCreateLabel("Current AGE", 240, 75) GUICtrlCreateLabel("Body Fat%", 340, 75) GUICtrlCreateLabel("Muscle%", 420, 75) GUICtrlCreateLabel("Name", 30, 15) Global $LB1 = GUICtrlCreateLabel("Fat", 110, 140) GUICtrlSetState($LB1, $GUI_HIDE) Global $LB2 = GUICtrlCreateLabel("Muscle", 195, 140) GUICtrlSetState($LB2, $GUI_HIDE) Global $LB3 = GUICtrlCreateLabel("LBM", 295, 140) GUICtrlSetState($LB3, $GUI_HIDE) Global $LB4 = GUICtrlCreateLabel("RMR", 295, 200) GUICtrlSetState($LB4, $GUI_HIDE) Global $name = GUICtrlCreateInput("", 30, 35) Global $IN1 = GUICtrlCreateInput("", 30, 90) Global $IN10 = GUICtrlCreateInput("", 85, 90) Global $IN2 = GUICtrlCreateInput("", 140, 90) Global $IN3 = GUICtrlCreateInput("", 240, 90) Global $IN5 = GUICtrlCreateInput("", 340, 90) Global $IN6 = GUICtrlCreateInput("", 420, 90) Global $IN4 = GUICtrlCreateInput("", 140, 140) GUICtrlSetState($IN4, $GUI_HIDE) Global $IN7 = GUICtrlCreateInput("", 240, 140) GUICtrlSetState($IN7, $GUI_HIDE) Global $IN8 = GUICtrlCreateInput("", 340, 140) GUICtrlSetState($IN8, $GUI_HIDE) Global $IN9 = GUICtrlCreateInput("", 340, 200) GUICtrlSetState($IN9, $GUI_HIDE) Global $chb1 = GUICtrlCreateRadio("Male", 30, 110) Global $chb2 = GUICtrlCreateRadio("Female", 75, 110) Global $toolmenu = GUICtrlCreateMenu("Tools") Global $toolitem1 = GUICtrlCreateMenuItem("Notes", $toolmenu) GUISetState(@sw_show) ;~ sleep(5000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGuiMain) Exit Case $BT1 Exit Case $BT2 FATlbs() MUSlbs() LBM() RMR() folder() Print() Print2() Case $toolitem1 ;~ Global $usr = InputBox("User", "what user to add notes to?") menubar() EndSwitch WEnd Func FATlbs() Global $bweight = GUICtrlRead($IN1) Global $fatp = GUICtrlRead($IN5) Global $fatlbs = Execute("$bweight * $fatp") GUICtrlSetState($IN4, $GUI_SHOW) GUICtrlSetState($LB1, $GUI_SHOW) GUICtrlRead($fatlbs) GUICtrlSetData($IN4, $fatlbs) EndFunc Func MUSlbs() Local $mscp = GUICtrlRead($IN6) Global $msclbs = Execute("$bweight * $mscp") GUICtrlSetState($IN7, $GUI_SHOW) GUICtrlSetState($LB2, $GUI_SHOW) GUICtrlRead($fatlbs) GUICtrlSetData($IN7, $msclbs) EndFunc Func LBM() Global $lbm = Execute("$bweight - $fatlbs") GUICtrlSetData($IN8, $lbm) GUICtrlSetState($IN8, $GUI_SHOW) GUICtrlSetState($LB3, $GUI_SHOW) EndFunc Func RMR() Global $rbr = Execute("$lbm * 14") ;~ MsgBox("", "", $rbr) GUICtrlSetData($IN9, $rbr) GUICtrlSetState($IN9, $GUI_SHOW) GUICtrlSetState($LB4, $GUI_SHOW) EndFunc Func folder() Global $nme = GUICtrlRead($name) DirCreate("C:\" & $nme) EndFunc Func Print() Global $VF = GUICtrlRead($IN10) Local Const $sFilePath = "C:\" & $nme & "\" Global $BCS = FileOpen($sFilePath & $nme & " Body Composion.txt", $FO_APPEND) FileWrite($BCS, $date & @CRLF) FileWrite($BCS, "Current Weight: " & $bweight & @CRLF & @CRLF) FileWrite($BCS, "Current Fat lbs: " & $fatlbs & @CRLF & @CRLF) FileWrite($BCS, "Current Muscle lbs: " & $msclbs & @CRLF & @CRLF) FileWrite($BCS, "Lean Body Mass: " & $lbm & @CRLF & @CRLF) FileWrite($BCS, "Resting Metabolic Rate: " & $rbr & @CRLF & @CRLF) FileWrite($BCS, "Visceral Fat: " & $VF & @CRLF & @CRLF) EndFunc Func Print2() FileWrite($BCS, "This Next section is your Meal Plan" & @CRLF) EndFunc Func menubar() Global $hGuiSecond = GUICreate("BAR Notes", 200, 200) GUISetBkColor(0x66CC66) GUISetState(@sw_show) ;~ sleep(5000) Global $nme = GUICtrlRead($name) Global $BT3 = GUICtrlCreateButton("Append", 110, 140, 60) Global $barnote = GUICtrlCreateInput("", 10, 10, 170, 100) Global $nt1 = GUICtrlRead($barnote) Local Const $sFilePath = "C:\" & $nme & "\" Global $BCS = FileOpen($sFilePath & $nme & " Body Composion.txt", $FO_APPEND) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGuiSecond) Return Case $BT3 ;~ MsgBox("", "", $nt1) FileWrite($BCS, $date & @CRLF) FileWrite($BCS, $nt1 & @CRLF) EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
spudw2k Posted June 5, 2015 Share Posted June 5, 2015 (edited) You are reading the control too far in advance. Move the $nt1 = GUICtrlRead($barnote) line under Case $BT3Func menubar() Global $hGuiSecond = GUICreate("BAR Notes", 200, 200) GUISetBkColor(0x66CC66) GUISetState(@sw_show) ;~ sleep(5000) Global $nme = GUICtrlRead($name) Global $BT3 = GUICtrlCreateButton("Append", 110, 140, 60) Global $barnote = GUICtrlCreateInput("", 10, 10, 170, 100) ;Global $nt1 = GUICtrlRead($barnote) Local Const $sFilePath = "C:\" & $nme & "\" Global $BCS = FileOpen($sFilePath & $nme & " Body Composion.txt", $FO_APPEND) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGuiSecond) Return Case $BT3 ;~ MsgBox("", "", $nt1) $nt1 = GUICtrlRead($barnote) FileWrite($BCS, $date & @CRLF) FileWrite($BCS, $nt1 & @CRLF) EndSwitch WEnd EndFuncAlso, (I haven't analyzed all of the code, but) I don't see a need to make the Global Scope variables within the menubar function.Question...why #requireadmin? Just curious. Edited June 5, 2015 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now