Jump to content

calculation with loop


Recommended Posts

I Don`t understand how I can create a loop or something like GOTO beginning of script.

First I wil put some value`s in an excel table who do the calculations for me en then declare the variables to use in the rest of the script.

After the questions I wil ask if the calculated value`s are acceptable. and if not restart the script from the beginning.

and finally if it is oke then use the value`s in my cad-software.

I have two problems with the script: it is not redeclaring the variables en it the second time it is using the function "waarden" it skips the msgbox question.

What do I wrong with this loop?

#include <ExcelCOM_UDF.au3>

$functie = "hellingbaan"
$sFilePath = ('C:\temp\helling.xls')

Local $oExcel = _ExcelBookOpen($sFilePath, 0)

If FileExists('C:\temp\helling.xls') then _waarden()

func _waarden()
If Not IsDeclared("$sValue") Then Local $sValue
$sValue = InputBox($functie,"Vul de verdiepingshoogte in,""," 4","300","150","400","400")
Select
    Case @Error = 0;OK - The string returned is valid
        _ExcelWriteCell($oExcel, $sValue, "C21")
    Case @Error = 1;The Cancel button was pushed
    Case @Error = 3;The InputBox failed to open
EndSelect
If Not IsDeclared("$sValue1") Then Local $sValue1
$sValue1 = InputBox($functie,"Vul de gewenste lengte in,""," 5","300","150","400","400")
Select
    Case @Error = 0;OK - The string returned is valid
        _ExcelWriteCell($oExcel, $sValue1, "C30")
    Case @Error = 1;The Cancel button was pushed
    Case @Error = 3;The InputBox failed to open
EndSelect
endfunc

global $0 = _ExcelReadCell($oExcel, "U26")
global $hoek = _ExcelReadCell($oExcel, "C24")
global $graden = _ExcelReadCell($oExcel, "D24")

$MB = MsgBox(4,$functie,$hoek & $graden  &"yes?")
while $MB = 7 
    _waarden ()
Wend

ShellExecute("C:\Temp\helling.DRW")
WinWait("RKEY - C:\Temp\helling.DRW")
If Not WinActive("RKEY - c:\temp\helling.DRW") Then WinActivate("RKEY - C:\Temp\helling.DRW")
WinWaitActive("RKEY - C:\Temp\helling.DRW")
Sleep (100)
Send($0)

_ExcelBookClose($oExcel)
Exit
Link to comment
Share on other sites

I Don`t understand how I can create a loop or something like GOTO beginning of script.

First I wil put some value`s in an excel table who do the calculations for me en then declare the variables to use in the rest of the script.

After the questions I wil ask if the calculated value`s are acceptable. and if not restart the script from the beginning.

and finally if it is oke then use the value`s in my cad-software.

I have two problems with the script: it is not redeclaring the variables en it the second time it is using the function "waarden" it skips the msgbox question.

What do I wrong with this loop?

#include <ExcelCOM_UDF.au3>

$functie = "hellingbaan"
$sFilePath = ('C:\temp\helling.xls')

Local $oExcel = _ExcelBookOpen($sFilePath, 0)

If FileExists('C:\temp\helling.xls') then _waarden()

func _waarden()
If Not IsDeclared("$sValue") Then Local $sValue
$sValue = InputBox($functie,"Vul de verdiepingshoogte in,""," 4","300","150","400","400")
Select
    Case @Error = 0;OK - The string returned is valid
        _ExcelWriteCell($oExcel, $sValue, "C21")
    Case @Error = 1;The Cancel button was pushed
    Case @Error = 3;The InputBox failed to open
EndSelect
If Not IsDeclared("$sValue1") Then Local $sValue1
$sValue1 = InputBox($functie,"Vul de gewenste lengte in,""," 5","300","150","400","400")
Select
    Case @Error = 0;OK - The string returned is valid
        _ExcelWriteCell($oExcel, $sValue1, "C30")
    Case @Error = 1;The Cancel button was pushed
    Case @Error = 3;The InputBox failed to open
EndSelect
endfunc

global $0 = _ExcelReadCell($oExcel, "U26")
global $hoek = _ExcelReadCell($oExcel, "C24")
global $graden = _ExcelReadCell($oExcel, "D24")

$MB = MsgBox(4,$functie,$hoek & $graden  &"yes?")
while $MB = 7 
    _waarden ()
Wend

ShellExecute("C:\Temp\helling.DRW")
WinWait("RKEY - C:\Temp\helling.DRW")
If Not WinActive("RKEY - c:\temp\helling.DRW") Then WinActivate("RKEY - C:\Temp\helling.DRW")
WinWaitActive("RKEY - C:\Temp\helling.DRW")
Sleep (100)
Send($0)

_ExcelBookClose($oExcel)
Exit

Put what you want repeated INSIDE the loop:

Local $oExcel = _ExcelBookOpen($sFilePath, 0)

If FileExists('C:\temp\helling.xls') Then _waarden()

While 1
    Global $0 = _ExcelReadCell($oExcel, "U26")
    Global $hoek = _ExcelReadCell($oExcel, "C24")
    Global $graden = _ExcelReadCell($oExcel, "D24")

    If MsgBox(4, $functie, $hoek & $graden & "yes?") = 7 Then
        _waarden()
    Else
        ExitLoop
    EndIf
WEnd

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...