Jump to content

program file calling


corey822
 Share

Recommended Posts

hi

ok i have a code and at the top when ur un it u may notice a main menu or nav like bar

what im trying to do is make wat evers in that nav bar link up with the file specified

have a look at my code and tell me if im doing it right as when ever i try to open the file i keep getting the error i set up

CODE
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++

; creator corey822 from the autoit forum +

; +

; title = RESISTOR DECODER +

; +

; this program is used to decode resistors by putting the colors in the boxes +

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include <GUIConstants.au3>

$Form1_1 = GUICreate("resistor decoding", 452, 231, 245, 118)

$color1 = GUICtrlCreateInput("color1", 56, 32, 65, 21)

$color2 = GUICtrlCreateInput("color2", 136, 32, 65, 21)

$color3 = GUICtrlCreateInput("color3", 216, 32, 65, 21)

$color4 = GUICtrlCreateInput("color4", 288, 32, 65, 21)

$Label1 = GUICtrlCreateLabel("resistor colors", 168, 8, 68, 17)

$Button1 = GUICtrlCreateButton("decode", 136, 64, 121, 25, 0)

$Label2 = GUICtrlCreateLabel("resistor code", 168, 104, 64, 17)

$Label3 = GUICtrlCreateLabel("0", 104, 144, 10, 17)

$Label4 = GUICtrlCreateLabel("0", 120, 144, 10, 17)

$Label5 = GUICtrlCreateLabel("0", 136, 144, 106, 17)

$Label6 = GUICtrlCreateLabel("resistance ==>>", 24, 184, 79, 17)

$Label7 = GUICtrlCreateLabel("0", 104, 184, 66, 25)

$Label8 = GUICtrlCreateLabel("color code ===>>", 16, 144, 87, 17)

$MenuItem1 = GUICtrlCreateMenu("help")

$MenuItem2 = GUICtrlCreateMenuItem("how to", $MenuItem1)

$MenuItem3 = GUICtrlCreateMenuItem("created by", $MenuItem1)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

If GUICtrlRead($color1) = "black" Then

GUICtrlSetData($Label3, "0")

ElseIf GUICtrlRead($color1) = "brown" Then

GUICtrlSetData($Label3, "1")

ElseIf GUICtrlRead($color1) = "red" Then

GUICtrlSetData($Label3, "2")

ElseIf GUICtrlRead($color1) = "orange" Then

GUICtrlSetData($Label3, "3")

ElseIf GUICtrlRead($color1) = "yellow" Then

GUICtrlSetData($Label3, "4")

ElseIf GUICtrlRead($color1) = "green" Then

GUICtrlSetData($Label3, "5")

ElseIf GUICtrlRead($color1) = "blue" Then

GUICtrlSetData($Label3, "6")

ElseIf GUICtrlRead($color1) = "purple" Then

GUICtrlSetData($Label3, "7")

ElseIf GUICtrlRead($color1) = "grey" Then

GUICtrlSetData($Label3, "8")

ElseIf GUICtrlRead($color1) = "white" Then

GUICtrlSetData($Label3, "9")

ElseIf GUICtrlRead($color1) = "" Then

GUICtrlSetData($Label3, "No color entered !")

EndIf

If GUICtrlRead($color2) = "black" Then

GUICtrlSetData($Label4, "0")

ElseIf GUICtrlRead($color2) = "brown" Then

GUICtrlSetData($Label4, "1")

ElseIf GUICtrlRead($color2) = "red" Then

GUICtrlSetData($Label4, "2")

ElseIf GUICtrlRead($color2) = "orange" Then

GUICtrlSetData($Label4, "3")

ElseIf GUICtrlRead($color2) = "yellow" Then

GUICtrlSetData($Label4, "4")

ElseIf GUICtrlRead($color2) = "green" Then

GUICtrlSetData($Label4, "5")

ElseIf GUICtrlRead($color2) = "blue" Then

GUICtrlSetData($Label4, "6")

ElseIf GUICtrlRead($color2) = "purple" Then

GUICtrlSetData($Label4, "7")

ElseIf GUICtrlRead($color2) = "grey" Then

GUICtrlSetData($Label4, "8")

ElseIf GUICtrlRead($color2) = "white" Then

GUICtrlSetData($Label4, "9")

ElseIf GUICtrlRead($color2) = "" Then

GUICtrlSetData($Label4, "No text")

EndIf

If GUICtrlRead($color3) = "black" Then

GUICtrlSetData($color3, "")

ElseIf GUICtrlRead($color3) = "brown" Then

GUICtrlSetData($Label5, "0")

ElseIf GUICtrlRead($color3) = "red" Then

GUICtrlSetData($Label5, "00")

ElseIf GUICtrlRead($color3) = "orange" Then

GUICtrlSetData($Label5, "000")

ElseIf GUICtrlRead($color3) = "yellow" Then

GUICtrlSetData($Label5, "0000")

ElseIf GUICtrlRead($color3) = "green" Then

GUICtrlSetData($Label5, "0000")

ElseIf GUICtrlRead($color3) = "blue" Then

GUICtrlSetData($Label5, "00000")

ElseIf GUICtrlRead($color3) = "purple" Then

GUICtrlSetData($Label5, "000000")

ElseIf GUICtrlRead($color3) = "grey" Then

GUICtrlSetData($Label5, "00000000")

ElseIf GUICtrlRead($color3) = "white" Then

GUICtrlSetData($Label5, "000000000")

ElseIf GUICtrlRead($color3) = "" Then

GUICtrlSetData($Label5, "No text")

EndIf

If GUICtrlRead($color4) = "silver" Then

GUICtrlSetData($Label7, "10%")

ElseIf GUICtrlRead($color4) = "brown" Then

GUICtrlSetData($Label7, "1%")

ElseIf GUICtrlRead($color4) = "red" Then

GUICtrlSetData($Label7, "2%")

ElseIf GUICtrlRead($color4) = "gold" Then

GUICtrlSetData($Label7, "5%")

ElseIf GUICtrlRead($color4) = "none" Then

GUICtrlSetData($Label7, "20%")

ElseIf GUICtrlRead($color4) = "white" Then

GUICtrlSetData($Label7, "20%")

ElseIf GUICtrlRead($color4) = "" Then

GUICtrlSetData($Label7, "20%")

EndIf

;>>>>>>>>>>>>>>>here is what im having trouble with>>>>>>>>>>>>>>>>

Case $MenuItem2

$file = FileOpen("help.txt", 0)

if $file = 1 Then

MsgBox(0 ,"error", "error unable to open file")

Exit

endif

EndSwitch

WEnd

cheeers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

hi

ok i have a code and at the top when ur un it u may notice a main menu or nav like bar

what im trying to do is make wat evers in that nav bar link up with the file specified

have a look at my code and tell me if im doing it right as when ever i try to open the file i keep getting the error i set up

CODE
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++

; creator corey822 from the autoit forum +

; +

; title = RESISTOR DECODER +

; +

; this program is used to decode resistors by putting the colors in the boxes +

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include <GUIConstants.au3>

$Form1_1 = GUICreate("resistor decoding", 452, 231, 245, 118)

$color1 = GUICtrlCreateInput("color1", 56, 32, 65, 21)

$color2 = GUICtrlCreateInput("color2", 136, 32, 65, 21)

$color3 = GUICtrlCreateInput("color3", 216, 32, 65, 21)

$color4 = GUICtrlCreateInput("color4", 288, 32, 65, 21)

$Label1 = GUICtrlCreateLabel("resistor colors", 168, 8, 68, 17)

$Button1 = GUICtrlCreateButton("decode", 136, 64, 121, 25, 0)

$Label2 = GUICtrlCreateLabel("resistor code", 168, 104, 64, 17)

$Label3 = GUICtrlCreateLabel("0", 104, 144, 10, 17)

$Label4 = GUICtrlCreateLabel("0", 120, 144, 10, 17)

$Label5 = GUICtrlCreateLabel("0", 136, 144, 106, 17)

$Label6 = GUICtrlCreateLabel("resistance ==>>", 24, 184, 79, 17)

$Label7 = GUICtrlCreateLabel("0", 104, 184, 66, 25)

$Label8 = GUICtrlCreateLabel("color code ===>>", 16, 144, 87, 17)

$MenuItem1 = GUICtrlCreateMenu("help")

$MenuItem2 = GUICtrlCreateMenuItem("how to", $MenuItem1)

$MenuItem3 = GUICtrlCreateMenuItem("created by", $MenuItem1)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

If GUICtrlRead($color1) = "black" Then

GUICtrlSetData($Label3, "0")

ElseIf GUICtrlRead($color1) = "brown" Then

GUICtrlSetData($Label3, "1")

ElseIf GUICtrlRead($color1) = "red" Then

GUICtrlSetData($Label3, "2")

ElseIf GUICtrlRead($color1) = "orange" Then

GUICtrlSetData($Label3, "3")

ElseIf GUICtrlRead($color1) = "yellow" Then

GUICtrlSetData($Label3, "4")

ElseIf GUICtrlRead($color1) = "green" Then

GUICtrlSetData($Label3, "5")

ElseIf GUICtrlRead($color1) = "blue" Then

GUICtrlSetData($Label3, "6")

ElseIf GUICtrlRead($color1) = "purple" Then

GUICtrlSetData($Label3, "7")

ElseIf GUICtrlRead($color1) = "grey" Then

GUICtrlSetData($Label3, "8")

ElseIf GUICtrlRead($color1) = "white" Then

GUICtrlSetData($Label3, "9")

ElseIf GUICtrlRead($color1) = "" Then

GUICtrlSetData($Label3, "No color entered !")

EndIf

If GUICtrlRead($color2) = "black" Then

GUICtrlSetData($Label4, "0")

ElseIf GUICtrlRead($color2) = "brown" Then

GUICtrlSetData($Label4, "1")

ElseIf GUICtrlRead($color2) = "red" Then

GUICtrlSetData($Label4, "2")

ElseIf GUICtrlRead($color2) = "orange" Then

GUICtrlSetData($Label4, "3")

ElseIf GUICtrlRead($color2) = "yellow" Then

GUICtrlSetData($Label4, "4")

ElseIf GUICtrlRead($color2) = "green" Then

GUICtrlSetData($Label4, "5")

ElseIf GUICtrlRead($color2) = "blue" Then

GUICtrlSetData($Label4, "6")

ElseIf GUICtrlRead($color2) = "purple" Then

GUICtrlSetData($Label4, "7")

ElseIf GUICtrlRead($color2) = "grey" Then

GUICtrlSetData($Label4, "8")

ElseIf GUICtrlRead($color2) = "white" Then

GUICtrlSetData($Label4, "9")

ElseIf GUICtrlRead($color2) = "" Then

GUICtrlSetData($Label4, "No text")

EndIf

If GUICtrlRead($color3) = "black" Then

GUICtrlSetData($color3, "")

ElseIf GUICtrlRead($color3) = "brown" Then

GUICtrlSetData($Label5, "0")

ElseIf GUICtrlRead($color3) = "red" Then

GUICtrlSetData($Label5, "00")

ElseIf GUICtrlRead($color3) = "orange" Then

GUICtrlSetData($Label5, "000")

ElseIf GUICtrlRead($color3) = "yellow" Then

GUICtrlSetData($Label5, "0000")

ElseIf GUICtrlRead($color3) = "green" Then

GUICtrlSetData($Label5, "0000")

ElseIf GUICtrlRead($color3) = "blue" Then

GUICtrlSetData($Label5, "00000")

ElseIf GUICtrlRead($color3) = "purple" Then

GUICtrlSetData($Label5, "000000")

ElseIf GUICtrlRead($color3) = "grey" Then

GUICtrlSetData($Label5, "00000000")

ElseIf GUICtrlRead($color3) = "white" Then

GUICtrlSetData($Label5, "000000000")

ElseIf GUICtrlRead($color3) = "" Then

GUICtrlSetData($Label5, "No text")

EndIf

If GUICtrlRead($color4) = "silver" Then

GUICtrlSetData($Label7, "10%")

ElseIf GUICtrlRead($color4) = "brown" Then

GUICtrlSetData($Label7, "1%")

ElseIf GUICtrlRead($color4) = "red" Then

GUICtrlSetData($Label7, "2%")

ElseIf GUICtrlRead($color4) = "gold" Then

GUICtrlSetData($Label7, "5%")

ElseIf GUICtrlRead($color4) = "none" Then

GUICtrlSetData($Label7, "20%")

ElseIf GUICtrlRead($color4) = "white" Then

GUICtrlSetData($Label7, "20%")

ElseIf GUICtrlRead($color4) = "" Then

GUICtrlSetData($Label7, "20%")

EndIf

;>>>>>>>>>>>>>>>here is what im having trouble with>>>>>>>>>>>>>>>>

Case $MenuItem2

$file = FileOpen("help.txt", 0)

if $file = 1 Then

MsgBox(0 ,"error", "error unable to open file")

Exit

endif

EndSwitch

WEnd

cheeers C.W

Might be that you should have

If $File = -1 then;<----- minus 1 not 1

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

Might be that you should have

If $File = -1 then;<----- minus 1 not 1

hmmm ive tried it both ways before posting anything else?

ive also tried removing it but to no avail

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

Hay Dude I Fixed Your Program... And Added An Option Menu... I Also Made It Prettier :]

#Include <GUIConstants.au3>
#NoTrayIcon
Opt('GUIOnEventMode',1)

If Not FileExists ( "Help.txt" ) Then
MsgBox (16, "Error", "Cannot Find 'Help.txt' Please Re-Download The Program And Try Again",0)
Exit 
ElseIf Not FileExists ( "Credits.txt" ) Then 
MsgBox (16, "Error", "Cannot Find 'Credits.txt' Please Re-Download The Program And Try Again",0)
Exit
EndIf

GUICreate(" Resistor Decoding v1.0", 415, 230)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
$Color_1 = GUICtrlCreateInput("Color One", 25, 32, 65, 20)
$Color_2 = GUICtrlCreateInput("Color Two", 125, 32, 65, 20)
$Color_3 = GUICtrlCreateInput("Color Three", 225, 32, 65, 20)
$Color_4 = GUICtrlCreateInput("Color Four", 325, 32, 65, 20)
$Button_1 = GUICtrlCreateButton("Decode", 150, 68, 120, 25)
GUICtrlSetOnEvent ($Button_1, "_Decode" )
$Menu = GUICtrlCreateMenu ( "Options" )
$Item_1 = GUICtrlCreateMenuItem ( "Help", $Menu )
GUICtrlSetOnEvent ($Item_1, "_Help" )
$Item_2 = GUICtrlCreateMenuItem ( "Credits", $Menu )
GUICtrlSetOnEvent ($Item_2, "_Credits" )
$Item_3 = GUICtrlCreateMenuItem ( "Exit", $Menu )
GUICtrlSetOnEvent ($Item_3, "_Exit" )
$Label_1 = GUICtrlCreateLabel ( "Color Code  |", 25,125)
$Label_2 = GUICtrlCreateLabel ( "------------------------------------------------------------------------------------------------------------------------------------------", 0,100)
$Label_3 = GUICtrlCreateLabel ( "Resistance  |", 25,160)
$Input_1 = GUICtrlCreateInput ( "0", 100,123,60,20)
$Input_2 = GUICtrlCreateInput ( "0", 170,123,60,20)
$Input_3 = GUICtrlCreateInput ( "0", 240,123,60,20)
$Input_4 = GUICtrlCreateInput ( "0", 100,158,60,20)
GUISetState(@SW_SHOW)

While 1
Sleep (250)
WEnd

Func _Decode ()
If GUICtrlRead($Color_1) = "Black" Then
GUICtrlSetData($Input_1, "0")
ElseIf GUICtrlRead($Color_1) = "Brown" Then
GUICtrlSetData($Input_1, "1")
ElseIf GUICtrlRead($Color_1) = "Red" Then
GUICtrlSetData($Input_1, "2")
ElseIf GUICtrlRead($Color_1) = "Orange" Then
GUICtrlSetData($Input_1, "3")
ElseIf GUICtrlRead($Color_1) = "Yellow" Then
GUICtrlSetData($Input_1, "4")
ElseIf GUICtrlRead($Color_1) = "Green" Then
GUICtrlSetData($Input_1, "5")
ElseIf GUICtrlRead($Color_1) = "Blue" Then
GUICtrlSetData($Input_1, "6")
ElseIf GUICtrlRead($Color_1) = "Purple" Then
GUICtrlSetData($Input_1, "7")
ElseIf GUICtrlRead($Color_1) = "Grey" Then
GUICtrlSetData($Input_1, "8")
ElseIf GUICtrlRead($Color_1) = "White" Then
GUICtrlSetData($Input_1, "9")
ElseIf GUICtrlRead($Color_1) = "" Then
GUICtrlSetData($Input_1, "0")
EndIf

If GUICtrlRead($Color_2) = "Black" Then
GUICtrlSetData($Input_2, "0")
ElseIf GUICtrlRead($Color_2) = "Brown" Then
GUICtrlSetData($Input_2, "1")
ElseIf GUICtrlRead($Color_2) = "Red" Then
GUICtrlSetData($Input_2, "2")
ElseIf GUICtrlRead($Color_2) = "Orange" Then
GUICtrlSetData($Input_2, "3")
ElseIf GUICtrlRead($Color_2) = "Yellow" Then
GUICtrlSetData($Input_2, "4")
ElseIf GUICtrlRead($Color_2) = "Green" Then
GUICtrlSetData($Input_2, "5")
ElseIf GUICtrlRead($Color_2) = "Blue" Then
GUICtrlSetData($Input_2, "6")
ElseIf GUICtrlRead($Color_2) = "Purple" Then
GUICtrlSetData($Input_2, "7")
ElseIf GUICtrlRead($Color_2) = "Grey" Then
GUICtrlSetData($Input_2, "8")
ElseIf GUICtrlRead($Color_2) = "White" Then
GUICtrlSetData($Input_2, "9")
ElseIf GUICtrlRead($Color_2) = "" Then
GUICtrlSetData($Input_2, "0")
EndIf

If GUICtrlRead($Color_3) = "Black" Then
GUICtrlSetData($Input_3, "")
ElseIf GUICtrlRead($Color_3) = "Brown" Then
GUICtrlSetData($Input_3, "0")
ElseIf GUICtrlRead($Color_3) = "Red" Then
GUICtrlSetData($Input_3, "00")
ElseIf GUICtrlRead($Color_3) = "Orange" Then
GUICtrlSetData($Input_3, "000")
ElseIf GUICtrlRead($Color_3) = "Yellow" Then
GUICtrlSetData($Input_3, "0000")
ElseIf GUICtrlRead($Color_3) = "Green" Then
GUICtrlSetData($Input_3, "0000")
ElseIf GUICtrlRead($Color_3) = "Blue" Then
GUICtrlSetData($Input_3, "00000")
ElseIf GUICtrlRead($Color_3) = "Purple" Then
GUICtrlSetData($Input_3, "000000")
ElseIf GUICtrlRead($Color_3) = "Grey" Then
GUICtrlSetData($Input_3, "00000000")
ElseIf GUICtrlRead($Color_3) = "White" Then
GUICtrlSetData($Input_3, "000000000")
ElseIf GUICtrlRead($Color_3) = "" Then
GUICtrlSetData($Input_3, "0")
EndIf

If GUICtrlRead($Color_4) = "Silver" Then
GUICtrlSetData($Input_4, "10 %")
ElseIf GUICtrlRead($Color_4) = "Brown" Then
GUICtrlSetData($Input_4, "1 %")
ElseIf GUICtrlRead($Color_4) = "Red" Then
GUICtrlSetData($Input_4, "2 %")
ElseIf GUICtrlRead($Color_4) = "Gold" Then
GUICtrlSetData($Input_4, "5 %")
ElseIf GUICtrlRead($Color_4) = "None" Then
GUICtrlSetData($Input_4, "20 %")
ElseIf GUICtrlRead($Color_4) = "White" Then
GUICtrlSetData($Input_4, "20 %")
ElseIf GUICtrlRead($Color_4) = "" Then
GUICtrlSetData($Input_4, "20 %")
EndIf
EndFunc

Func _Help ()
ShellExecute ( "Help.txt" )
EndFunc

Func _Credits ()
ShellExecute ( "Credits.txt" )
EndFunc

Func _Exit ()
Exit
EndFunc
Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

O Yea Forgot Credits.txt And Help.txt ^^

Help.txt

CODE

Credits.txt

CODE
Original Ideal By : Corey822 From AutoIt Forums

Edited And Modified By : John O. Aka John2006 AutoIt Forums

45646974656420416E64204D6F646966696564204279203A204A6F686E204F2E20416B61204A6F686E32303036204175746F

497420466F72756D73

------------------------------------------------------------------------------------------------------------------------------------------

Resistor Decoding v1.0 Copyright © 2007-2009

Notice : DO NOT DELETE OR EDIT THIS FILE.

Resistor_Decoding_v1.0.zip

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

O Yea Forgot Credits.txt And Help.txt ^^

Help.txt

CODE

hahah nice m8 one thing the top box didnt have anything XD

cheers C.W

love it m8

Credits.txt

CODE
Original Ideal By : Corey822 From AutoIt Forums

Edited And Modified By : John O. Aka John2006 AutoIt Forums

45646974656420416E64204D6F646966696564204279203A204A6F686E204F2E20416B61204A6F686E32303036204175746F

497420466F72756D73

------------------------------------------------------------------------------------------------------------------------------------------

Resistor Decoding v1.0 Copyright © 2007-2009

Notice : DO NOT DELETE OR EDIT THIS FILE.

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

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