Sign in to follow this  
Followers 0
GodForsakenSoul

trouble reading and including [Partially solved]

6 posts in this topic

#1 ·  Posted (edited)

i would like to work with more then one file.

#include "GuiInclude\GUIConstants.au3"
#include "GuiInclude\GUIPracticeConjucagtion.au3"
#include "GuiInclude\GUIPracticeKana.au3"
#include "GuiInclude\GUIOptions.au3"

GUICreate("Basic Japanese Training", 550,200)                   ;Master gui control
Opt("GuiCoordMode", 0)                                          ;right left corner + relative to last controll created
$button1=GUICtrlCreateButton("Practice Conjugation",20,30,250,20)
$button2=GUICtrlCreateButton("Practice Kana", 0,30,250,20)
$button3=GUICtrlCreateButton("Options", 0,30, 250,20)
$button4=GUICtrlCreateButton("Exit", 0,70,250,20)
$logo=GUICtrlCreatePic("GuiInclude\Graphic\LOGO.BMP", 300, -150, 200, 150)
GUISetState()                                                   ;Actually shows the GUI

while 1=1
     $msg = GUIGetMsg()
    Select
        Case $msg=$GUI_EVENT_CLOSE
            ExitLoop
        Case $msg=$button1
            Call("Practice1")
;       Case $msg=$button2
;           Call("P2")
;       Case $msg=$button3
;           Call("Options")
        Case $msg=$button4
            ExitLoop
    EndSelect
Wend

however, this doesn't seem to work. it refuses to accept the call, despite the fact the other file, which is GUIPracticeConjucagtion.au3. IT FRIGGIN EXISTS!

i put a Func and everything.

now here's another nifty thing i'm trying to pull off here.

$RFileName=Random(1,2,1)
    $RFileLine=Random(1,2,1)
    $file=FileOpen("Verbs\"&$RFileName, 4)
    $line=FileReadLine($file,$RFileLine)
    MsgBox(1,"",$line)

i want it to pick one out of two files and one out of two lines in said file. it shows an empty msgbox instead. help?

edit: thanks to m32's genius-ness i figured out i had an extremely retarded problem. The first problem, however, remains....

edit2: as soon as i try to put the random file/line reader thing into a function, it refuses to work. what the heck?

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites



GodForsakenSoul,

Q1. Why use Call? If the file is included and Practice1 is a function within it, then a simple function_name command will suffice.

Q2. What are the 2 files called (at the moment you are looking for files named 1 and 2, with no extension, in the Verbs folder within @ScriptDir), where are they (in relation to your script), and have you done any errorchecking on the file handle you get back?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

GodForsakenSoul,

Q1. Why use Call? If the file is included and Practice1 is a function within it, then a simple function_name command will suffice.

Q2. What are the 2 files called (at the moment you are looking for files named 1 and 2, with no extension, in the Verbs folder within @ScriptDir), where are they (in relation to your script), and have you done any errorchecking on the file handle you get back?

M23

A1: According to the help file, first you write the function (Func), and afterwards you call it (Call). The problem here is that the main file refuses to accept the fact the function it's looking for is in a different file. I just F5'd both of those files to be sure, and still, despite removing the Call, it still claims that Practice1() is undefined. Practice1 is VERY MUCH DEFINED in a different file, and despite the inconvenience of keeping it in two files, i'd prefer having it that way. this proggy is going to be frigging huge.

A2: the two files are 1.txt and 2.txt. a small modification was made to that line, yet still same result.

$file=FileOpen("Verbs\"&$RFileName&".txt", 4)

Share this post


Link to post
Share on other sites

GodForsakenSoul,

Q1. There is no need to use Call unless the function name is in a string variable. I have many scripts which call functions in #include files and I have yet to use Call to make it work. ;)

Could you please post the file which you are #includeing and which contains the function Practice1 - strip the content if you would prefer not to show it, but please leave the Func and EndFunc lines in!

Q2. What about the rest of the info: "where are they (in relation to your script), and have you done any errorchecking on the file handle you get back?".

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

here's a more defined version of my problem. i ;'ed all the unused things.

;Main file
#include "GuiInclude\GUIConstants.au3"
#include "GuiInclude\GUIPracticeConjucagtion.au3"
;#include "GuiInclude\GUIPracticeKana.au3"
;#include "GuiInclude\GUIOptions.au3"

GUICreate("Basic Japanese Training", 550,200)                   ;Master gui control
Opt("GuiCoordMode", 0)                                          ;right left corner + relative to last controll created
$button1=GUICtrlCreateButton("Practice Conjugation",20,30,250,20)
;$button2=GUICtrlCreateButton("Practice Kana", 0,30,250,20)
;$button3=GUICtrlCreateButton("Options", 0,30, 250,20)
;$button4=GUICtrlCreateButton("Exit", 0,70,250,20)
;$logo=GUICtrlCreatePic("GuiInclude\Graphic\LOGO.BMP", 300, -150, 200, 150)
GUISetState()                                                   ;Actually shows the GUI

while 1=1
     $msg = GUIGetMsg()
    Select
        Case $msg=$GUI_EVENT_CLOSE
            ExitLoop
        Case $msg=$button1
            Practice1()
;       Case $msg=$button2
;           Call("P2")
;       Case $msg=$button3
;           Call("Options")
;       Case $msg=$button4
            ExitLoop
    EndSelect
Wend

;========

;GUIPracticeConjugation
;#include "GuiInclude\GUIVar.au3"
Global $RFileName=0
Global $RFileLine=0

Func Practice1
    $RFileName=Random(1,2,1)
    $RFileLine=Random(1,2,1)
;   $file=FileOpen("Verbs\1.txt", 4)
    $line=FileReadLine("Verbs\"&$RFileName&".txt",$RFileLine)
    MsgBox(1,"",$line)
EndFunc

IDEALLY i would also use GUIVar.au3 to store all the variables i'll ever use in the proggy. XD

Right now i managed to successfully link the two files without autoit yelling SYNTAX ERROR!!!!1 at me.

but now i'm back at the problem where i'm getting an empty msgbox when i run the thing.

this time, however, s*** gets complicated: when i run it from MainGui, i get an empty msgbox, however, when i run PracticeConjugation BY ITSELF, it works fairly well.

i'm out of ideas o.o

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

GodForsakenSoul,

Does it work if you add () after the Func Practise1 declaration? It does for me! ;)

M23

Edit: speeling

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0