mendrofa

string between

9 posts in this topic

why my string between is 0

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
 #include <String.au3>
 #include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 238, 66, 192, 124)
$Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57)
$Input1 = GUICtrlCreateInput("", 14, 21, 121, 21)
$Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nmsg = $button1
       cek()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd

func cek()
   Local $oie
    $url = "https://www.binary.com/trading?l=EN"
    If NOT WinExists("Binary.com") Then
        $oie = _IECreate($url, 2)
        Sleep(50)
    Else
        $oie = _IEAttach("Binary.com", "instance", 1)
        ;WinActivate("Binary.com")
        Sleep(50)
    EndIf
    Sleep(50)
   Do
        $o_akun = _iegetobjbyid($oie, "client_loginid")
     Until IsObj($o_akun)
    ConsoleWrite($o_akun.innerhtml & @CRLF)
    Sleep(50)
$array = _StringBetween($o_akun.innerhtml, '"value="', '">"')
guictrlsetdata($input1, $array)


   EndFunc

 

Share this post


Link to post
Share on other sites



30 minutes ago, mendrofa said:

why my string between is 0

Because an Array is returned when it finds the string, so you need to change that to $array[0] for the first found string.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

like this ?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
 #include <String.au3>
 #include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 238, 66, 192, 124)
$Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57)
$Input1 = GUICtrlCreateInput("", 14, 21, 121, 21)
$Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nmsg = $button1
       cek()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd

func cek()
   Local $oie
    $url = "https://www.binary.com/trading?l=EN"
    If NOT WinExists("Binary.com") Then
        $oie = _IECreate($url, 2)
        Sleep(50)
    Else
        $oie = _IEAttach("Binary.com", "instance", 1)
        ;WinActivate("Binary.com")
        Sleep(50)
    EndIf
    Sleep(50)
   Do
        $o_akun = _iegetobjbyid($oie, "client_loginid")
     Until IsObj($o_akun)
    ConsoleWrite($o_akun.innerhtml & @CRLF)
    Sleep(50)
$array = _StringBetween($o_akun.innerhtml, '"value="', '">"')[0]
guictrlsetdata($input1, $array)


   EndFunc

but error

Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_ENDISSTART, $bCase = False)
Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_E^ ERROR

Share this post


Link to post
Share on other sites

No did you check the helpfile?

It is like this: 

$array = _StringBetween($o_akun.innerhtml, '"value="', '">"')
guictrlsetdata($input1, $array[0])

Also ensure you do a test for @error to make sure the UDF found the string.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

still error sir

"F:\data2\cekprofit.au3" (46) : ==> Subscript used on non-accessible variable.:
guictrlsetdata($input1, $array[0])
guictrlsetdata($input1, $array^ ERROR

Share this post


Link to post
Share on other sites

Please re-read my post and try to understand it first before posting that it doesn't work:

5 minutes ago, Jos said:

Also ensure you do a test for @error to make sure the UDF found the string.

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

sorry i newbie here sir
how to test for @error

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I am sorry too but am not going to do all coding for you and you should be able to figure out how to do a if that will test the returned @error value.
There is also a ConsoleWrite in your script that returns NOTHING, which I guess makes clear to you that you are doing something wrong with the text retrieval from the IE page.

You wrote the script so what is it supposed to do?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
 #include <String.au3>
 #include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 238, 66, 192, 124)
$Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57)
$Input1 = GUICtrlCreateInput("", 14, 21, 121, 21)
$Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nmsg = $button1
       cek()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd

func cek()
   Local $oie
    $url = "https://www.binary.com/trading?l=EN"
    If NOT WinExists("Binary.com") Then
        $oie = _IECreate($url, 2)
        Sleep(50)
    Else
        $oie = _IEAttach("Binary.com", "instance", 1)
        ;WinActivate("Binary.com")
        Sleep(50)
    EndIf
    Sleep(50)
   Do
        $o_akun = _iegetobjbyid($oie, "client_loginid")
     Until IsObj($o_akun)
    ConsoleWrite($o_akun.innerhtml & @CRLF)
    Sleep(50)
    $array = _StringBetween($o_akun.innerhtml, '"value="', '">"')
    $error= @error
    if VarGetType($array)='Array' Then
       $data=$array[0]
    Else
       $data=$error
    EndIf
    MsgBox(0,0,($data==1?'No strings found':$data ))

;guictrlsetdata($input1, $array)


   EndFunc

Note that .... the innerHTML of the entry is null.

<select id="client_loginid" name="client_loginid">
</select>

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