Jump to content

Use of variables


Grof
 Share

Recommended Posts

I know, it's simple, but I've made a mistake...

The code:

 

Local $vVariable = "MyApp"

DirCreate ("@AppDataDir\" & MyApp)

 

I Wanna create a variable, assign the value "MyApp" and create in AppData a folder named "MyApp"

The error is Unknown funtion name.

 

What's wrong?

 

Thanks.

Link to comment
Share on other sites

if you even bothered to look up DirCreate in the help file and run the sample code, you would have your answer.

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the directory.
    Local Const $sFilePath = @TempDir & "\DirCreateFolder"

    ; If the directory exists the don't continue.
    If FileExists($sFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The directory already exists.")
        Return False
    EndIf

    ; Open the temporary directory.
    ShellExecute(@TempDir)

    ; Create the directory.
    DirCreate($sFilePath)

    ; Display a message of the directory creation.
    MsgBox($MB_SYSTEMMODAL, "", "The directory has been created.")

    ; Remove the directory and all sub-directories.
    DirRemove($sFilePath, $DIR_REMOVE)

    ; Display a message of the directory removal.
    MsgBox($MB_SYSTEMMODAL, "", "The sub folder: Folder2 has been deleted.")
EndFunc   ;==>Example

you want code to learn from? use the help file and the example code provided please

you define a variable named $vVariable  so use that instead of MyApp in the dircreate, as is shown in the example. Please start to use the help file to learn, as it was meant to be, then when you are stuck, ask for help AND provide your code, or an example of your code that others can test and help you debug

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

  • Developers
35 minutes ago, Grof said:

DirCreate ("@AppDataDir\" & MyApp)

should be

DirCreate (@AppDataDir & "\" & MyApp)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Now I'm trying to pass a variable to another variable with environment variable:

 

Local $vVariable = "MyApp"

Local $sFilePath = @AppDataDir & "\" & MyApp

MsgBox ($sFilePath)

 

Doesn't exit MsgBox (same error)!

Edited by Grof
Link to comment
Share on other sites

  • Developers

Just look at your script again and think about what could be wrong there with the variable you try to concatenate at the end. ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
15 minutes ago, Grof said:

I suppose the name of variable is $vVariable (and not Myapp), and msgbox were missing parameters...

You still "suppose" or did you try and did it work? :) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
1 minute ago, Grof said:

How many are the include? Where can I download them? And where must they placed?

Many and no need to download as they are part of the standard installer found in the Autoit/Include directory.

1 hour ago, Grof said:

Doesn't exit MsgBox (same error)!

You really need to learn to open the helpfile and check the appropriate syntax of commands as the msgbox() is also wrong in that code.

 One other helpfull tool is to install the full SciTE4AutoIt3 installer as that will always run au3check for you when doing run, which will give you more clear syntax error/warning messages.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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