Sign in to follow this  
Followers 0
copyleft

How to tranaslate GOTO command

11 posts in this topic

I am a newbie. I want to make an autoit script out of the batch file below but I'm struggling with the goto label. Also how do I get the location of the ramdrv whe I don't know it. Windows recognized %ramdrv% a the correct variable even though the registry desginates the ramdrive at %temp%.

if NOT exist %ramdrv% goto ERROR

:CHECK

md %ramdrv%\New >nul

if not errorlevel 0 goto ERROR

copy %systemdrive%\test\. %ramdrv%\new >nul

goto end

:ERROR

Echo There was an error.

pause

goto end

:End

Exit

Share this post


Link to post
Share on other sites



translate them make the goto into a function call _End() or _Error()

Func _End()

Exit

EndFunc

Func _Error()

MsgBox(0,'','Error has occured')

_End()

EndFunc


Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

You can use a dummy loop :lmao: .. see the Wiki for an example.

Share this post


Link to post
Share on other sites

You can use a dummy loop  :lmao:  .. see the Wiki for an example.

<{POST_SNAPBACK}>

OK. I've come up with this, which seems ok until the end where the endif statment generates an error

$var1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderPath", "XXX")

DirCreate ( "$var1\New" )

IfExists("$var1\New") Then

FileCopy("@SystemDir\Test\*.*", "var1\new\*.*"

Else

MsgBox(0,"", "There was an error")

EndIf

Share this post


Link to post
Share on other sites

i think this is wrong..

IfExists($var1 & "\New") Then

FileCopy(@SystemDir & "\Test\*.*", $var1 & "\new\*.*"

try that?

Share this post


Link to post
Share on other sites

The missing closing brace, on the FileCopy function, would be generating the error.

:lmao:

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Click on the portion of MHz's sig that says "Scite4AutoIt" and use that to write your code in. It's simply marvelous. It makes writing code much easier (not just AU3 either.) And it contains functions and tools that would have notified you of that error before you would have compiled the script.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Seems like the trailing enclosing parenthesis isn't the problem either. Put it in, AutoIt still flags the "Else" statement in line five. I don't understand because my scrip is almost virtually the same thing as this example in the docs:

If FileExists("D:\") Then

MsgBox(4096, "", "D: exists.")

Else

MsgBox(4096,"", "D: does not exist.")

EndIf

I give up.

Edited by copyleft

Share this post


Link to post
Share on other sites

Seems like the trailing enclosing parenthesis isn't the problem either. Put it in, AutoIt still flags the "Else" statement in line five. I don't understand because my scrip is almost virtually the same thing as this example in the docs:

If FileExists("D:\") Then

    MsgBox(4096, "", "D: exists.")

Else

    MsgBox(4096,"", "D: does not exist.")

EndIf

I give up.

<{POST_SNAPBACK}>

You're using FileExists for a drive, not a file.

Try looking at "DriveGetDrive"


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Seems like the trailing enclosing parenthesis isn't the problem either. Put it in, AutoIt still flags the "Else" statement in line five.

[..]

I give up.

<{POST_SNAPBACK}>

It's probably complaining about the Else cos you don't have an If

:lmao:

Edit: it's interpreting your IfExists as a UDF

Edited by trids

Share this post


Link to post
Share on other sites

hey! i was gonna create a Copyleft thing like Copyright... too late :lmao: it was in one of my consoles i made for autoit too (still working on) sorry for the off topic post...


FootbaG

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