Jump to content

reecedorward

Active Members
  • Posts

    27
  • Joined

  • Last visited

reecedorward's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. The idea is that I want to save user names to a text file.. then be able to recall or 'Load' users saved to that text file in a list.. I need the list to be displayed within the GUICtrlCreateList function.. Here is the code I'm having trouble with, it displays a list of arrays using _arraydisplay BUT I dont want it displayed in columns and rows... #include #include #include #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 277, 254, 192, 124) $write = GUICtrlCreateInput("", 16, 16, 161, 21) $enter = GUICtrlCreateButton("Enter", 192, 8, 73, 25) $names = GUICtrlCreateList("", 24, 56, 209, 175) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $userspath = "C:\Documents and Settings\matthews\My Documents\Reece's Scripts\Users.txt" $readusers = fileread($userspath) Local $array $read = _Filereadtoarray($userspath, $array) guictrlsetdata($names, $read) _arraydisplay($array) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $enter $readwrite = guictrlread($write) guictrlsetdata($names, $readwrite) guictrlsetdata($write, "") filewrite($userspath, $readwrite & @CRLF) EndSwitch WEnd
  2. Im having trouble understanding arrays, never used them before, seen them in the help files, just havent used them.. So what im guessing is that on the line where you've written "Local $Result[$items + 1]"... That is saying that because $items = 'user input, lets say 4 for example' that $result will occur 4 times? I dont really understand it at all lol especially the + 1 after it.. Is the + 1 representing the next variable? That being $SUM? Would you be able to go more into detail with the array section please? Also at the start of the script when you call "addup" you didnt write 'call("addup")' and it still called the func.. Never seen that before.. I have also got to ask one more question.. And that is... Why did you convert the $numberofitems variable to $items? Any particular reason? Much appreciated!
  3. Yes! This is exactly what I was after! would you mind going through your script and explaining how it works? Thanks
  4. Hi, I'm trying to make a script that will help adding up certain things e.g. money, bills etc Basically I want to make a variable that equals an InputBox that asks the user "how many items need to be added". If the user types in, for example, 5 the variable then becomes "5". I want then to use that variables number to then make "5 input boxes" enabling the user to add 5 different items. at the end using a msgbox to show the total $NumberOfItems = Inputbox("Number of Items", "Enter the number of items you want to add up") If $NumberOfItems > "1" Then call("addup") endif Func addup() #cs This is where i want to have the amount of inputboxes come up. the amount being what the string of $NumberOfItems variable equals. So the first inputbox comes up, user types in say $20.50.. presses enter, the next inputbox comes up, user types in $15.10 etc etc after the final inputbox comes up there needs to be a formula that says "first inputbox + second inputbox + third inputbox etc" then at the end a msgbox appears with the total cost. #ce endfunc
  5. Haha so simple.. Thanks buddy!
  6. StringIsAlNum() Allows for letters and numbers... but that is it.. how do I tell the script that if the string contains numbers, letters, spaces and other operators... if the string contains any type of input that then it can continue... would I just write (referring to the script below) If $testf = True then Call("test1f")? Call("Testf") Func testf() While 1 Global $testf = InputBox("Giggy Launcher v1.0", "Type in TV Series" & @CR & @CR & "What TV series would you like to Download?", "e.g. Game Of Thrones") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf If StringIsAlpha($testf) Then Call("test1f") EndIf WEnd EndFunc ;==>testf
  7. Is there a quicker way of writing it other than this: $num = InputBox("num", "") If StringIsDigit($num) Then If $num = "0" Then $num = "00" If $num = "1" Then $num = "01" If $num = "2" Then $num = "02" If $num = "3" Then $num = "03" If $num = "4" Then $num = "04" If $num = "5" Then $num = "05" If $num = "6" Then $num = "06" If $num = "7" Then $num = "07" If $num = "8" Then $num = "08" If $num = "9" Then $num = "09" EndIf MsgBox(0, "num", $num) If StringIsAlpha($num) Then MsgBox(0, "alph", "alph") EndIf Exit
  8. hey speaking of numbers... with this script: $num = InputBox("num", "") If StringIsDigit($num) Then MsgBox(0, "num", "num") ElseIf StringIsAlpha($num) Then MsgBox(0, "alph", "alph") EndIf Exit If i want the first numbers from 0 to 9 to have a zero in front of them eg. 00, 01, 02, 03... instead of just 0, 1, 2, 3 etc how would I go about doing that?
  9. Ah thanks again kaotkbliss! Works like a charm!
  10. AH HA! Thats it!... i must have read the help file wrong... With the Function StringIsDigit... it says in the help file Checks if a string contains only digit (0-9) characters. So is that saying the number from zero to nine.. or just numbers in general? Thanks mate
  11. Is it possible to retrieve a Variable outside a Func... for example Func test2f() While 1 Local $test2 = InputBox("Giggy Launcher v1.0", "Greys Anatomy" & @CR & @CR & "Enter the Episode Number", "Episode Number") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf If StringIsAlNum($test2) Then ExitLoop EndIf WEnd EndFunc ;==>test2f Local $goto = MsgBox(4, "Get Var", $test2) How can I retrieve the variable from within the Function Loop cycle?
  12. $num = InputBox("num", "") If StringIsAlNum($num) Then MsgBox(0, "num", "num") ElseIf StringIsAlpha($num) Then MsgBox(0, "alph", "alph") EndIf Exit I look at that and think.. yep i can see the general direction that its headed.... if its a number > msgbox Num > exit.. elseif its alpha > msgbox alph > exit BUT NOPE! :S
  13. Thankyou jchd, Realm & kaotkbliss! You have all been very helpful (and patient) It's all a learning process for me, and have learned alot already since first finding out about AutoIt. I had a mate show me his way of doing it, which worked to an extent, though I managed to edit it further and accomplish the EXACT result I was looking for. Here is the final script: Call("Test1f") Func test1f() While 1 Local $test1 = InputBox("Test1", "Test1", "Type a Number") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf If $test1 = True Then Call("test2f") EndIf WEnd EndFunc ;==>test1f Call("Test2f") Func test2f() While 1 Local $test2 = InputBox("Test2", "Test2", "Type a Number Again") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf If $test2 = True Then Call("test3f") EndIf WEnd EndFunc ;==>test2f Call("Test3f") Func test3f() While 1 Local $goto = MsgBox(4, "Time to go back", "Press Yes to goto $test1 Inputbox or press No to goto $test2 Inputbox") If $goto = 6 Then Call("Test1f") If $goto = 7 Then Call("Test2f") WEnd EndFunc
  14. This is the CLOSEST SOLUTION I have had yet! Thanks for that... Though I have edited your script around a little and I came up with this: _Test1() _Test2() Local $goto Func _test1() Local $test1 = InputBox("Test1", "Test1", "Type a Number") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf If $test1 = True Then _Test2() ; EndFunc ;==>_test1 Func _Test2() Local $test2 = InputBox("Test2", "Test2", "Type a Number Again") If @error Then $exit = MsgBox(4, "Exit?", "Are you sure?") If $exit = 6 Then Exit EndIf ; EndFunc ;==>_Test2 While 1 $goto = MsgBox(4, "Time to go back", "Press Yes to goto $test1 Inputbox or press No to goto $test2 Inputbox") If $goto = 6 Then _Test1();### Goto $test1 InputBox ElseIf $goto = 7 Then _Test2();### Goto $test2 InputBox Else ;do something else, or maybe exit application EndIf WEnd Exit Run this script and you will see that all but 1 error remains.. and that is after you type a number in the first inputbox, it goes to the second inputbox.. which is all good untill you goto type a number into the second inputbox, it for some reason (instead of going to the final msgbox) brings up the second inputbox for a second time.. AND THEN.. it goes to the msgbox... after that the loop then becomes exactly how I wanted it and nothing goes wrong.. I just cant figure out why the script makes the second inputbox come up twice the first time round.... If anyone knows why or how to prevent this, please feel free to let me know, Thanks for everyones help!
×
×
  • Create New...