Jump to content
Sign in to follow this  
autoitxp

Func _log($read) how to $read with differnt methods

Recommended Posts

autoitxp

hi this showing data 1 by 1 how to get them like 123 using string method in _log() func

_data()

Func _data()

_log("1")

_log("2")

_log("3")

EndFunc

Func _log($read)

MsgBox(64, "" , $read)

EndFunc

Share this post


Link to post
Share on other sites
Skruge

_data()
Func _data()
    _log("1" & "2" & "3")
EndFunc

Func _log($read)
    MsgBox(64, "", $read)
EndFunc


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
autoitxp

123 using string method in _log() func

/?

Share this post


Link to post
Share on other sites
Skruge

/?

Do you want _log() to take three different strings and combine them?

Or do you want _log to be called three different times, combine the values as you go, and display them at the end? If so, it will need logic to determine when to display the MsgBox.

You're going to need to be more specific.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
autoitxp

do you want _log to be called three different times, combine the values as you go, and display them at the end?

exactly Edited by autoitxp

Share this post


Link to post
Share on other sites
Skruge

exactly

You skipped an important part: "If so, it will need to determine when to display the MsgBox."

This will display and reset every third call:

_data()

Func _data()
    _log("1")
    _log("2")
    _log("3")
EndFunc

Func _log($read)
    Global $s_Text, $i_Count

    $s_Text &= $read
    $i_Count += 1

    If $i_Count >= 3 Then
        MsgBox(64, "", $s_Text)
        $i_Count = 0
        $s_Text = ""
    EndIf
EndFunc

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
Skruge

Func _log($read)
    Do
        $r= ConsoleWrite($read)
    Until $r = 1
EndFunc
@DCCD: That code will cause an infinite loop if the string is longer or shorter than one character.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
Authenticity

_data()

Func _data()
    _log("1")
    _log("2")
    _log("3")
    _log("")
    _log("45")
    _log("6")
    _log("")
EndFunc

Func _log($read)
    Global $s_Text

    If $read Then
        $s_Text &= $read
    Else
        MsgBox(0x40, 'Title', $s_Text)
        $s_Text = ''
    EndIf
EndFunc

Share this post


Link to post
Share on other sites
PsaltyDS

Or maybe use an existing Global:

Global $s_Text

_data()

Func _data()
    _log("1")
    _log("2")
    _log("3")
    _log("45")
    _log("6")
    _log("", True); Display and clear
    _log("7")
    _log(); Just display
EndFunc

Func _log($read = "", $f_Clear = False)
    If $read <> "" Then
        $s_Text &= $read & @CRLF
    Else
        MsgBox(0x40, 'Title', $s_Text)
    EndIf
    If $f_Clear Then $s_Text = ""
EndFunc

You could also add time stamps to make it a really useful log, but that gets close to just reinventing _FileWriteLog(), which I use extensively in all my maintenance scripts.

:D


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

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  

×