Jump to content

Recommended Posts

Posted

Hello i have some troubles

if i declare array

Local $cut1[1]
   $cut1[0] = $string1
Local $cut2[1]
   $cut2[0] = $string2

$string1 = '012'
$string2 = '345'

;and if i put 
MsgBox(0,'', $cut1[0] & '   ' & $cut2[0])     
; then i will see the message with text = 012   345

but if i will add:

$cut1 = _StringBetween($string1, '0', '2', -1)
$cut2 = _StringBetween($string2, '3', '5', -1)
;and:
MsgBox(0,'', $cut1[0], & '   ' & $cut2[0]
;then i will see the message with text = 1   4

But if $string1 or $string2 don't contain the corect $start or $end string, that will give error that this is non-Array variable,

ok, if i add:

$cut1 = _StringBetween($string1, '0', '2', -1)
   If @error then $cut1[0] = 'none1'
$cut2 = _StringBetween($string2, '3', '5', -1)
   If @error then $cut2[0] = 'none2'

I will have the same error, that here is non-Array variable, how i can Repair this bug?

Thank you so mutch.

Toader.

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Posted (edited)

you had a bonus comma in your message box, seems to work fine and certainly replaces the value in the array and displays fine.

This might work better:

#Include <String.au3>
#Include <Array.au3>


Local $string1 = '012'
Local $string2 = '345'


Global $cut1[1]
   $cut1[0] = $string1
Global $cut2[1]
   $cut2[0] = $string2

MsgBox(0,'', $cut1[0] & '---' & $cut2[0])



$snip1 = _StringBetween($string1, '0', '2', -1)

   If @Error = 1 then
       Local $snip1[1]
   _ArrayInsert ($snip1 , 0 , "none1")
   Endif



$snip2 = _StringBetween($string2, '3', '5', -1)

  If @Error = 1 then
       Local $snip2[1]
   _ArrayInsert ($snip2 , 0 , "none2")
   Endif


Msgbox (0, '' , $snip1[0] & '---' & $snip2[0])
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

1D Array solution

#Include <String.au3>
#Include <Array.au3>

Global $cut[5]

$cut[0] = '07772'
$cut[1] = '34445'
$cut[2] = '38905'
$cut[3] = '02467'
$cut[4] = '305'

For $i = 0 to ubound($cut) - 1

$snip = _StringBetween($cut[0], '3', '5')

   If @Error = 1 OR $snip = 0 then
   _ArrayDelete ($cut , 0)
   _ArrayAdd ($cut , "none")
   Else
       _ArrayDelete ($cut, 0)
       _Arrayadd ($cut , $snip[0])
   Endif
   
Next



Msgbox (0, '' , $cut[0] & '---' & $cut[1] & '---' & $cut[2] & '---' & $cut[3] & '---' & $cut[4])

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...