AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is the matter with this script?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Wed Sep 05, 2007 1:35 am    Post subject: What is the matter with this script? Reply with quote

Code:
#SingleInstance Off

Gui, 1:+Resize
Gui, 1:Color, C0C0C0
Gui, 1:Show, x0 y0 h498 w474, Bathroom Passes
Gui, 2:+Owner1
Gui, 2:Font, Arial
Gui, 2:Add, Edit, W350 H300 vInfo +ReadOnly
Gui, 2:Add, Button, W350 gView, View all students
Gui, 2:Show, x90 y143, Student Id's
Gui, 3:+ToolWindow +Owner1
Gui, 3:Add, Text, W50, Student Id
Gui, 3:Add, Edit, W50 vNames +Center
Gui, 3:Add, Button, W50 gRead vRead, Find
Gui, 3:Show, x6 y143 , Trips
Gui, 4:+ToolWindow +Owner1
Gui, 4:Add, Text, W100 +Center, Name of student
Gui, 4:Add, Edit, W100 vName +Center,
Gui, 4:Add, Button, W100 h20 gAdd, Add this student
Gui, 4:Show, x89 y35 , New Student

View:
FileRead, Students, C:\Student_Id's.txt
GuiControl,, Names, %Students%
Return

Add:
Gui, 4:Submit, NoHide
Random, StudentBID, 1000, 7000
IniWrite, %Name%, Bathroom Pass.ini, %StudentBID%, Name`n
IniWrite, 0, Bathroom Pass.ini, %StudentBID%, Trips
GuiControl,, Name
MsgBox, Name added to list - ID is %StudentBID%
FileAppend, %Name%`, %StudentBID%`n, Student_Id's.txt
Return

Read:
Gui, Submit, NoHide
FileRead, Id, Student_Id's.txt
Haystack = %Id%
Needle = %Names%
IfInString, Haystack, %Needle%
{

Random, Variable, 1, 100000

IniRead, Times, Bathroom Pass.ini, %Name%, Trips
Trips = %Times%

Gui, 5:+ToolWindow +Owner1
Gui, 5:Add, Edit, x6 y10 w50 h20 +ReadOnly +Number v%Variable%,
Gui, 5:Add, Button, x6 y40 w20 h20 gPlus, +
Gui, 5:Add, Button, x36 y40 w20 h20 gMinus, -
Gui, 5:Show, x9 y255  h70 w63, Edit Trips
GuiControl,, %Variable%, %Times%
Return

Plus:
Trips := Times++
IniWrite, %Trips%, Bathroom Pass.ini, %Name%, Trips
GuiControl,, %Variable%, %Trips%
Return

Minus:
Trips := Times--
IniWrite, %Trips%, Bathroom Pass.ini, %Name%, Trips
GuiControl,, %Variable%, %Trips%
Return
}
Else
{
   MsgBox, 16, Error, Name not found.
   Return
}

GuiClose:
ExitApp


The ini, and text files save just fine.. But I can't use the "View All" and "Edit Trips". They open, but don't seem to have any affect. I hope it's not some obvious error Laughing
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
slomz



Joined: 03 Sep 2006
Posts: 608
Location: Iowa, U.S.

PostPosted: Wed Sep 05, 2007 1:50 am    Post subject: Reply with quote

I didn't look at it thoroughly but sometimes a GuiControlGet helps with these situations
_________________
Back to top
View user's profile Send private message AIM Address
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Wed Sep 05, 2007 1:52 am    Post subject: Reply with quote

If you even read it briskly, you would realize that it's loading files. Not making it's own contents.
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Wed Sep 05, 2007 2:35 am    Post subject: Reply with quote

Is this more like what you are trying to do???

I still don't like the program flow though, give me 30 mins.

Code:
#SingleInstance Off

Gui, 1:+Resize
Gui, 1:Color, C0C0C0
Gui, 1:Show, x0 y0 h498 w474, Bathroom Passes
Gui, 2:+Owner1
Gui, 2:Font, Arial
Gui, 2:Add, Edit, W350 H300 vInfo +ReadOnly
Gui, 2:Add, Button, W350 gView, View all students
Gui, 2:Show, x90 y143, Student Id's
Gui, 3:+ToolWindow +Owner1
Gui, 3:Add, Text, W50, Student Id
Gui, 3:Add, Edit, W50 vNames +Center
Gui, 3:Add, Button, W50 gRead vRead, Find
Gui, 3:Show, x6 y143 , Trips
Gui, 4:+ToolWindow +Owner1
Gui, 4:Add, Text, W100 +Center, Name of student
Gui, 4:Add, Edit, W100 vName +Center,
Gui, 4:Add, Button, W100 h20 gAdd, Add this student
Gui, 4:Show, x89 y35 , New Student
Return

View:
FileRead, Students,Student_Id's.txt
GuiControl,2:,Info,%Students%
Return

Add:
Gui, 4:Submit, NoHide
Random, StudentBID, 1000, 7000
IniWrite, %Name%, Bathroom Pass.ini, %StudentBID%, Name
IniWrite, 0, Bathroom Pass.ini, %StudentBID%, Trips
IniWrite, %StudentBID%, Bathroom Pass.ini, %Name%, ID
GuiControl,, Name
MsgBox, Name added to list - ID is %StudentBID%
FileAppend, %Name%`, %StudentBID%`n, Student_Id's.txt
Return

Read:
Gui, 3:Submit, NoHide
FileRead, Id, Student_Id's.txt
IfInString, Id, %Names%
{
Random, Variable, 1, 100000
IniRead,ID,Bathroom Pass.ini,%Names%,ID
IniRead,Times,Bathroom Pass.ini,%ID%,Trips
Trips = %Times%
Gui, 5:+ToolWindow +Owner1
Gui, 5:Add, Edit, x6 y10 w50 h20 +ReadOnly +Number v%Variable%,%Times%
Gui, 5:Add, Button, x6 y40 w20 h20 gPlus, +
Gui, 5:Add, Button, x36 y40 w20 h20 gMinus, -
Gui, 5:Show, x9 y255  h70 w63, Edit Trips
}
Else
{
   MsgBox, 16, Error, Name not found.
   Return
}
Return

Plus:
Trips := Times++
IniWrite, %Trips%, Bathroom Pass.ini, %ID%, Trips
GuiControl,5:, %Variable%, %Trips%
Return

Minus:
Trips := Times--
IniWrite, %Trips%, Bathroom Pass.ini, %ID%, Trips
GuiControl,5:, %Variable%, %Trips%
Return


GuiClose:
ExitApp

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Wed Sep 05, 2007 3:47 am    Post subject: Reply with quote

Personally I prefere something like this. Although the look of the gui could use some work.

Code:
#SingleInstance Off
studentlist:=""
iniread,students,Bathroom Pass.ini,students,Students
loop,%students% {
  student_id:=A_index
  iniread,student_name%a_index%,Bathroom Pass.ini,%a_index%,Name
  iniread,student_trips%a_index%,Bathroom Pass.ini,%a_index%,Trips
  studentlist.=student_name%a_index% "|"
}


Gui,add,Listbox,w300 r20 vstudent gupdate Altsubmit,%studentlist%
gui,add,edit,readonly vtrips section,
Gui,Add, Button,ys w20 r1 gPlus vplus, +
Gui,Add, Button,ys w20 r1 gMinus vminus, -
Gui,Add, Button,ys r1 gadd ,Add Student
gui,show,,Bathroom Pass
Gui, 4:Add, Text, W100 +Center, Name of student
Gui, 4:Add, Edit, W100 vName +Center,
Gui, 4:Add, Button, W100 h20 gsubmit, Add this student
gui,4:+toolwindow
Return

Add:
gui,4:show,,Add Student
Return

Submit:
gui,4:submit
Students+=1
Iniwrite,%students%,Bathroom Pass.ini,students,Students
Iniwrite,%Name%,Bathroom Pass.ini,%students%,Name
IniWrite,0,Bathroom Pass.ini,%students%,Trips
student_trips%students%:=0
Guicontrol,1:,Student,%Name%
Return

update:
guicontrolget,selected_id,,Student
guicontrol,,trips,% student_trips%selected_id%
return

Plus:
guicontrolget,selected_id,,Student
if (selected_id){
  student_trips%selected_id%+=1
  guicontrol,,trips,% student_trips%selected_id%
  iniwrite,% student_trips%selected_id%,Bathroom Pass.ini,%selected_id%,Trips
}
Return

Minus:
guicontrolget,selected_id,,Student
if (selected_id){
  student_trips%selected_id%-=1
  guicontrol,,trips,% student_trips%selected_id%
  iniwrite,% student_trips%selected_id%,Bathroom Pass.ini,%selected_id%,Trips
}
Return

GuiClose:
ExitApp

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Wed Sep 05, 2007 11:38 pm    Post subject: Reply with quote

Even though you called my GUI wack, thanks Cool
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Thu Sep 06, 2007 12:47 am    Post subject: Reply with quote

I was referring to the second version i posted. I meant my gui could use some work, I just made a basic one, just to show.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Thu Sep 06, 2007 12:52 am    Post subject: Reply with quote

Hm..Is there a way you can perhaps make a delete student button next to the add (deletes highlighted student in lv)
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Thu Sep 06, 2007 1:01 am    Post subject: Reply with quote

Yeah it can be done, give me ten mins.

Which version you using ??
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Thu Sep 06, 2007 1:25 am    Post subject: Reply with quote

I always have the max.
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Thu Sep 06, 2007 1:45 am    Post subject: Reply with quote

Sorry I meant what version of the script are you using, the modified version of yours, or my new version ??
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Thu Sep 06, 2007 2:06 am    Post subject: Reply with quote

Basically, my answer applies to both.
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Thu Sep 06, 2007 2:15 am    Post subject: Reply with quote

Code:
#SingleInstance Off
gosub,setup

Gui,add,Listbox,w300 r20 vstudent gupdate Altsubmit,%studentlist%
gui,add,edit,readonly vtrips section,
Gui,Add, Button,ys w20 r1 gPlus vplus, +
Gui,Add, Button,ys w20 r1 gMinus vminus, -
Gui,Add, Button,ys r1 gadd ,Add Student
Gui,Add, Button,ys r1 gdelete,Delete Student
gui,show,,Bathroom Pass
Gui, 4:Add, Text, W100 +Center, Name of student
Gui, 4:Add, Edit, W100 vName +Center -WantReturn ,
Gui, 4:Add, Button, W100 h20 gsubmit Default, Add this student
gui,4:+toolwindow
Return

setup:
studentlist:=""
students:=0
iniread,students,Bathroom Pass.ini,students,Students
loop,%students% {
  student_id:=A_index
  iniread,student_name%a_index%,Bathroom Pass.ini,%a_index%,Name
  iniread,student_trips%a_index%,Bathroom Pass.ini,%a_index%,Trips
  studentlist.=student_name%a_index% "|"
}
return

Delete:
guicontrolget,selected_id,,Student
if (selected_id = students){
  inidelete,Bathroom Pass.ini,%selected_id%
  Students-=1
  Iniwrite,%students%,Bathroom Pass.ini,students,Students
}
Else {
  msgbox % student_name%selected_id% "-" student_name%students%
  student_name%selected_id%:=student_name%students%
  student_trips%selected_id%:=student_trips%students%
  Iniwrite,% student_name%selected_id%,Bathroom Pass.ini,%selected_id%,Name
  IniWrite,% student_trips%selected_id%,Bathroom Pass.ini,%selected_id%,Trips
  inidelete,Bathroom Pass.ini,%students%
  Students-=1
  Iniwrite,%students%,Bathroom Pass.ini,students,Students
  gosub,setup
  Guicontrol,1:,Student,|%studentlist%
}
Return

Add:
gui,4:show,,Add Student
Return

Submit:
gui,4:submit
Students+=1
Iniwrite,%students%,Bathroom Pass.ini,students,Students
Iniwrite,%Name%,Bathroom Pass.ini,%students%,Name
IniWrite,0,Bathroom Pass.ini,%students%,Trips
student_name%students%:=Name
student_trips%students%:=0
Guicontrol,1:,Student,%Name%
Return

update:
guicontrolget,selected_id,,Student
guicontrol,,trips,% student_trips%selected_id%
return

Plus:
guicontrolget,selected_id,,Student
if (selected_id){
  student_trips%selected_id%+=1
  guicontrol,,trips,% student_trips%selected_id%
  iniwrite,% student_trips%selected_id%,Bathroom Pass.ini,%selected_id%,Trips
}
Return

Minus:
guicontrolget,selected_id,,Student
if (selected_id){
  student_trips%selected_id%-=1
  guicontrol,,trips,% student_trips%selected_id%
  iniwrite,% student_trips%selected_id%,Bathroom Pass.ini,%selected_id%,Trips
}
Return

GuiClose:
ExitApp


That's my version with a delete button. Try that i'll look into one for yours.

Edit: It could be done for yours, but because of the way it works I would suggest not to use it.

Although the chances are slim there is a chance that you could get duplicate ID's for a start.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Thu Sep 06, 2007 2:26 am    Post subject: Reply with quote

Thanks; I made the GUI even by making the add/delete students to W50 and changing their names to ++ and --

Edit: Yeah, I was thinking of looking for a solution for that.

What the fact that you can add the same name more then once?
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group