Jump to content

Recommended Posts

Posted

hello again,

it has been a long time since i have been here and a long time since i last used autoit. ever so often when the time allows me to, then i follow up on an idea that i had a long time ago. i have done all the work on paper but now it is up to writing it in autoit and i keep stumbling over many little issues here and there. sometimes after a few days i will try again and get a step further but sometimes it just will not help no matter how long i try and think about a solution. for most of you it will be the basics but for me it is not all that easy, but at least i give it a try.

right, down to business:

here is my code:

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <String.au3>

;
; PART 1: define replacements and check with msgbox
;

    Global $y, $z
    $y = "Yes"
    $z = "No"
    MsgBox(0,"replacements", $y & @CRLF & $z) ;the replacements in a message box

;
; PART 2: set the texts and check via console and msgbox
;

    Global $my1string = "abab" ;the first specified text
    MsgBox(0,"my1string", $my1string) ;the message box to output the first specified text

    Global $my2string = "icic" ;the second specified text
    MsgBox(0,"my2string", $my2string) ;the message box to output the second specified text

;
; PART 3: transform the strings to individual arrays
;

    $my1array = StringSplit($my1string, "")
    $my1array[0] = ""
    _ArrayDelete($my1array, 0)
    _ArrayDisplay($my1array, "my1array") ;the display of the first specified array

    $my2array = StringSplit($my2string, "")
    $my2array[0] = ""
    _ArrayDelete($my2array, 0)
    _ArrayDisplay($my2array, "my2array") ;the display of the first specified array

;
; PART 4: create an empty array for filling
;

    Global $OutputArray[4]
    $OutputArray[0] = ""
    _ArrayDisplay($OutputArray, "OutputArray") ;the display of the first specified array

;
; PART 5: compare & fill empty OutputArray with data after evaluation
;

    Global $i, $j, $k

    For $i = 0 to UBound($my1array) -1
        For $j = 0 to UBound($my2array) -1
            For $k = 0 to UBound($OutputArray) -1
                If $my1array[$i] = "a" And $my2array[$j] = "i" Then
                $OutputArray[$k] = $y
                Else
                $OutputArray[$k] = $z
                EndIf
            Next
        Next
    Next

_ArrayDisplay($OutputArray, "OutputArray") ;the display of the Newly filled Array

In "Part 2" i make a string that is converted to an array in "Part 3" ... Now, I know that "a" and "i" are always in the exact same spot in both arrays and so i wanted to compare this and make a further array to document my findings by saying "yes" or "no" ... however my new array keeps saying just "no" allthough i can clearly see and know that it should say:

yes
no
yes
no

my guess is that there is something wrong within my for-loops and that the counting is somehow "off" i guess that when the first for-loop is finished it reaches the second whilst the second for-loop is checking the first which would explain why it always says "no" instead of seeing the obvious.

so my question would be: what is wrong with my for-loop? or where am i making an error that ultimately gives me the wrong results?

help is much appreciated.

kind regards

roeselpi

 

 

PS: sorry for my not so great english spelling ... stupid german sitting here trying out intermediate english skills.

Posted (edited)

Hi roeselpi,

if your arrays are always the same size (and as you say the strings are in the same index position, I consider this as given):

Global $i
For $i = 0 To UBound($my1array) - 1
    If $my1array[$i] = "a" And $my2array[$i] = "i" Then
        $OutputArray[$i] = $y
    Else
        $OutputArray[$i] = $z
    EndIf
Next

Your nested loops were running to all 3 arrays asychnronous - at first k walks from 0 to ubound while i+j are 0, then k again while j=1 and i=0 etc.

Edited by Marc
typo

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Posted

FYI, there is no need to declare variables used as index in a For...Next loop.  AutoIt will auto-declare it Local.  As it is usually the case, those variables should not have a Global scope.

Posted (edited)

Hi Nine,
I once had an issue with this behavior, i.e. "the variable used as index in a For...Next loop will be created automatically with Local scope"

Here are the parts of the script concerned with this (minor) issue. First what didn't work :

Global $aListe_img, $iNum_img = 0 ; declared outside of functions
...

Func Treatment() ; called from main GUI several times (depending on user actions)
    AdlibRegister("AdlibProgressBar", 1000) ; each second
    For $iNum_img = 1 To $aListe_img[0]
        ...
    Next
    AdlibStop()
EndFunc 

Func AdlibProgressBar()
    ; Issue because $iNum_img will always be equal to 0
    ProgressSet($iNum_img / $aListe_img[0] * 100, _
        $iNum_img & " / " & $aListe_img[0])
EndFunc

Func AdlibStop()
    AdlibUnRegister("AdlibProgressBar")
    ProgressOff()
EndFunc

Now what's working :

Global $aListe_img, $iNum_img = 0 ; declared outside of functions
...

Func Treatment() ; called from main GUI several times (depending on user actions)
    AdlibRegister("AdlibProgressBar", 1000) ; each second
    For $iNum_img_local = 1 To $aListe_img[0]
        $iNum_img = $iNum_img_local ; <==========================
        ...
    Next
    AdlibStop()
EndFunc 

Func AdlibProgressBar()
    ; Ok because $iNum_img will be incremented correctly
    ProgressSet($iNum_img / $aListe_img[0] * 100, _
        $iNum_img & " / " & $aListe_img[0])
EndFunc

Func AdlibStop()
    AdlibUnRegister("AdlibProgressBar")
    ProgressOff()
EndFunc

I don't know if It could have been scripted differently but at least it works. Maybe it could help anyone having the same issue :)

Edited by pixelsearch
changes in old code, variable was initially named $iNum_img (iirc)
Posted
Posted

hello,

ok, first of all thanks @Marc for the simple solution and explaination. works beautifully. and is perfect for my needs. 

second of all thanks @Nine for a explaination where i was at loss for knowledge. i thought global must be used if data needs to be processed or used everywhere within the file and not just in a locally based area like the for-loop. that is why i always tend to use global when in doubt. probably not the best idea but sofar no conflicts within my little experiments.

i think i can now get onto another problem that needs to be addressed after using the search and trying to find a solution first. 

thanks a lot for the help.

kind regards

roeselpi

Posted
3 hours ago, pixelsearch said:

once had an issue with this behavior, i.e. "the variable used as index in a For...Next loop will be created automatically with Local scope"

Also, the opposite can happen, no variable created when you think it has:

For $n=1 To 100
;then somewhere way below nested 
;;;;;;;
;;;;;;;

   Local $n
   For $n=1 To 100
   Next
Next

 

Code hard, but don’t hard code...

Posted

Another two cents:

You dont need to clear an array element before deleting the element... or you could eliminate the two lines of code

completely by using the 3rd parameter ($STR_NOCOUNT) in StringSplit.

Posted

hello again,

now ther is an issue here. ... there must be some way to simplify this somehow, because as my example will show only five different things will result in 25 entries. imagine i had 100 different entries then it would result in 10000 if ... then tasks in one single for-loop. ... example:

Global $01, $02, $03, $04, $05
$01 = "Cable01"
$02 = "Cable02"
$03 = "Cable03"
$04 = "Cable04"
$05 = "Cable05"

Global $my1array[5] = ["Set1", "Set2", "Set3", "Set4", "Set5"]
Global $my2array[5] = ["Mod1", "Mod2", "Mod3", "Mod4", "Mod5"]
Global $OutputArray[5] = ["#", "#", "#", "#", "#"]

For $i = 0 To UBound($my1array) - 1
        If $my1array[$i] = "Set1" And $my2array[$i] = "Mod1" Then $OutputArray[$i] = $01
        If $my1array[$i] = "Set1" And $my2array[$i] = "Mod2" Then $OutputArray[$i] = $02
        If $my1array[$i] = "Set1" And $my2array[$i] = "Mod3" Then $OutputArray[$i] = $03
        If $my1array[$i] = "Set1" And $my2array[$i] = "Mod4" Then $OutputArray[$i] = $04
        If $my1array[$i] = "Set1" And $my2array[$i] = "Mod5" Then $OutputArray[$i] = $05
        
        If $my1array[$i] = "Set2" And $my2array[$i] = "Mod1" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set2" And $my2array[$i] = "Mod2" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set2" And $my2array[$i] = "Mod3" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set2" And $my2array[$i] = "Mod4" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set2" And $my2array[$i] = "Mod5" Then $OutputArray[$i] = $...
        
        If $my1array[$i] = "Set3" And $my2array[$i] = "Mod1" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set3" And $my2array[$i] = "Mod2" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set3" And $my2array[$i] = "Mod3" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set3" And $my2array[$i] = "Mod4" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set3" And $my2array[$i] = "Mod5" Then $OutputArray[$i] = $...
        
        If $my1array[$i] = "Set4" And $my2array[$i] = "Mod1" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set4" And $my2array[$i] = "Mod2" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set4" And $my2array[$i] = "Mod3" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set4" And $my2array[$i] = "Mod4" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set4" And $my2array[$i] = "Mod5" Then $OutputArray[$i] = $...
        
        If $my1array[$i] = "Set5" And $my2array[$i] = "Mod1" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set5" And $my2array[$i] = "Mod2" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set5" And $my2array[$i] = "Mod3" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set5" And $my2array[$i] = "Mod4" Then $OutputArray[$i] = $...
        If $my1array[$i] = "Set5" And $my2array[$i] = "Mod5" Then $OutputArray[$i] = $...
    Next

if that is only 5 then it would be 5x5 ... 25 possible comibnations

and if you factor in the 5 $01-$05 then it boils down to 5x5x5 ... 125 possible comibnations in one for loop. i have aprox 100 entries of each parameter.

that means the for-loop would be 100x100x100 entries long ... 1 million if ... and ... then terms in a just one for loop. is that possible at all? i guess that would take forever?

would it be possible to make the for loop into a fuction and outsource it to a secondary file?

 

i think my plan just went from easy and small to impossible and large.

 

i would need to know if i should continue or give up. if the programm can not handle 1.000.000 'ifs' in a for-loop at least once in an adequate amount of time, then there is no use in continuing the process.

 

any thoughts?

Posted

From a purely functional point of view, something like this could collapse the logic as you requested.

Global $01, $02, $03, $04, $05
$01 = "Cable01"
$02 = "Cable02"
$03 = "Cable03"
$04 = "Cable04"
$05 = "Cable05"

Global $my1array[5] = ["Set1", "Set2", "Set3", "Set4", "Set5"]
Global $my2array[5] = ["Mod1", "Mod2", "Mod3", "Mod4", "Mod5"]
Global $OutputArray[5] = ["#", "#", "#", "#", "#"]

For $i = 0 To UBound($my1array) - 1
   For $j = 0 To UBound($my2array) - 1
        If $my1array[$i] = "Set" & ($i + 1) And $my2array[$i] = "Mod" & ($j + 1) Then $OutputArray[$i] = Eval("0" & $j)
   Next
Next

To be honest though, although I can’t say what you are trying to do, I think you are trying to do it the wrong way.  

Your data structures are suspect at least.  Have you described what you are trying to do in an earlier post?

If not, it would certainly help :)

Code hard, but don’t hard code...

Posted (edited)

Hello,

as @JockoDundee stated also I cannot guess what your goal is, at all.

 

But what you are sketching looks to me as a "2D" array task. 2D arrays are still very comfortable to work with, as e.g. _DebugArrayDisplay() works perfectly to take a look at their content.

 

It's also very easy to add array content using the function _ArrayAdd(). _ArrayAdd() has the very nice effect, that you do not need to know and to take care of the final array dimensions (final number of rows) in advance.

 

#include <Array.au3>
#include <Debug.au3>


dim $Arr2D[1][3]=[["Cable","Mod","Set"]]

_DebugArrayDisplay($Arr2D)

$Str2Split=""

$Counter=1
for $Set = 1 to 10
    for $Mod = 1 to 10
        $Str2Split&="Cable" & StringFormat("%02i",$Counter) & "|Mod" & StringFormat("%02i",$Mod) & "|Set" & StringFormat("%02i",$Set) & @CRLF
        $Counter+=1
    Next
Next

$Str2Split=StringTrimRight($Str2Split,2) ; cut off last @CRLF

_ArrayAdd($Arr2D,$Str2Split)
_DebugArrayDisplay($Arr2D)

<edit>

somewhat larger array:

#include <Array.au3>
#include <Debug.au3>


dim $Arr2D[1][5]=[["Cable","Mod","Set","Length","Plug"]]

_DebugArrayDisplay($Arr2D)

$StrPlugTypes="CEE16|CEE32|CEE64"
$aPlugs=StringSplit($StrPlugTypes,"|",2)

Dim $Str2Split=""

$Counter=1
for $Set = 1 to 10
    for $Mod = 1 to 10
        for $Lenth = 1 to 10
            for $plug in $aPlugs
                $Str2Split&="Type-" & StringFormat("%03i",$Counter) & "|" & "Mod" & StringFormat("%02i",$Mod) & "|Set" & StringFormat("%02i",$Set) & "|" & StringFormat("%02i",$Lenth) & " ft|" & $plug & @CRLF
                $Counter+=1
            Next
        Next
    Next
Next

$Str2Split=StringTrimRight($Str2Split,2) ; cut off last @CRLF

_ArrayAdd($Arr2D,$Str2Split)
_DebugArrayDisplay($Arr2D)

</edit>

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted

hi,

Quote

Have you described what you are trying to do in an earlier post?

i will make a miniture working model so you can understand what i want to do and why i doubt that i can use 2D arrays. might take a while but i will post simplified version within a few hours (i hope) then you can see that only 1D arrays will work even though the task i want to do, would normally be predestined for a 2D array. give me a chance to show you what i am up to, thanks.

Posted

hi, 

fully functioning working version (very very simplyfied)

now, just try to imagine 100 entries instead of 8. until every possible solution would have been worked through, it would take at least 10000 if cases to ensure that everything is right. ... now take into consideration that maybe it is not linear (like in this small example) but randomized, then you would have 100x100x100 cases which would lead to 1 million if cases

here is the example:

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <String.au3>

; ----------------------------------------------------------------
; PART A: GUI
; ----------------------------------------------------------------

; not needed here for demonstration (is not built yet anyway)

; ----------------------------------------------------------------
; PART B: declare all variables that are for the basic functioning
; ----------------------------------------------------------------

; ---------- for testing: $a will be alphabetical chars
    Global $a11, $a12, $a13, $a14
    Global $a21, $a22, $a23, $a24
; ---------- for testing: $n will be numerical chars
    Global $n11, $n12, $n13, $n14
    Global $n21, $n22, $n23, $n24
; ---------- for testing: $a will be alphabetical chars
    $a11 = chr(65) ;A
    $a12 = chr(66) ;B
    $a13 = chr(67) ;C
    $a14 = chr(68) ;D
    $a21 = chr(69) ;E
    $a22 = chr(70) ;F
    $a23 = chr(71) ;G
    $a24 = chr(72) ;H
; ---------- for testing: $n will be numerical chars
    $n11 = "11"
    $n12 = "12"
    $n13 = "13"
    $n14 = "14"
    $n21 = "21"
    $n22 = "22"
    $n23 = "23"
    $n24 = "24"
; ------------------------------------------------------------------
; Forum-Information:
; For Simplification: A=11, B=12, C=13, D=14, E=21, F=22, G=23, H=24
; ------------------------------------------------------------------

; ----------------------------------------------------------------
; PART C: create work-arrays and fill with replacable data
; ----------------------------------------------------------------

    Global $maxsize
    $maxsize = "8"

    ; The following would be defined as a Function ... so: begin function here
    Global $workarray01[4] = ["#", "#", "#", "#"]
    Global $workarray02[4] = ["#", "#", "#", "#"]
    Global $workarray03[4] = ["#", "#", "#", "#"]
    Global $workarray04[4] = ["#", "#", "#", "#"]
            For $i = 0 To 4
            _ArrayConcatenate ($workarray01, $workarray01)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray02, $workarray02)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray03, $workarray03)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray04, $workarray04)
            Next
    ReDim $workarray01[$maxsize]
    ReDim $workarray02[$maxsize]
    ReDim $workarray03[$maxsize]
    ReDim $workarray04[$maxsize]
    ; ............................................end function here


; ----------------------------------------------------------------
; PART D: here comes the userdata ... the data the user has typed
; ----------------------------------------------------------------

Local $userdatastring01 = "abefh"
$userdataupcasestring01 = StringUpper($userdatastring01)
$userdataarray01 = StringSplit($userdataupcasestring01, "",$STR_NOCOUNT)
For $i = 0 To 3
    _ArrayConcatenate ($userdataarray01, $userdataarray01)
Next
ReDim $userdataarray01[$maxsize]


_ArrayDisplay($userdataarray01, "userdata 1")


Local $userdatastring02 = "cdg"
$userdataupcasestring02 = StringUpper($userdatastring02)
$userdataarray02 = StringSplit($userdataupcasestring02, "",$STR_NOCOUNT)
For $i = 0 To 3
    _ArrayConcatenate ($userdataarray02, $userdataarray02)
Next
ReDim $userdataarray02[$maxsize]


_ArrayDisplay($userdataarray02, "userdata 2")


; --------- ALL Arrays are now exactly the same size. each 8 digits long


; ----------------------------------------------------------------
; PART E: filling the workarrays with the correct numeric values
; ----------------------------------------------------------------

    ; The following would be defined as a Function ... so: begin function here
        For $i = 0 To UBound($userdataarray01) - 1
            If $userdataarray01[$i] = $a11 Then $workarray01[$i] = $n11
            If $userdataarray01[$i] = $a12 Then $workarray01[$i] = $n12
            If $userdataarray01[$i] = $a13 Then $workarray01[$i] = $n13
            If $userdataarray01[$i] = $a14 Then $workarray01[$i] = $n14
            If $userdataarray01[$i] = $a21 Then $workarray01[$i] = $n21
            If $userdataarray01[$i] = $a22 Then $workarray01[$i] = $n22
            If $userdataarray01[$i] = $a23 Then $workarray01[$i] = $n23
            If $userdataarray01[$i] = $a24 Then $workarray01[$i] = $n24
        Next
    ; .......................................................end function here


_ArrayDisplay($workarray01, "Transform 1")


    ; The following would be defined as a Function ... so: begin function here
        For $i = 0 To UBound($userdataarray02) - 1
            If $userdataarray02[$i] = $a11 Then $workarray02[$i] = $n11
            If $userdataarray02[$i] = $a12 Then $workarray02[$i] = $n12
            If $userdataarray02[$i] = $a13 Then $workarray02[$i] = $n13
            If $userdataarray02[$i] = $a14 Then $workarray02[$i] = $n14
            If $userdataarray02[$i] = $a21 Then $workarray02[$i] = $n21
            If $userdataarray02[$i] = $a22 Then $workarray02[$i] = $n22
            If $userdataarray02[$i] = $a23 Then $workarray02[$i] = $n23
            If $userdataarray02[$i] = $a24 Then $workarray02[$i] = $n24
        Next
    ; ......................................................end function here


_ArrayDisplay($workarray02, "Transform 2")


; ----------------------------------------------------------------
; Forum Information: This is the Part Where I am stuck at the moment:
;
; PART F: combining and resetting the values
;
; ----------------------------------------------------------------

        For $i = 0 To UBound($workarray01) - 1
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n11

            If $workarray01[$i] = $n12 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n12

            If $workarray01[$i] = $n13 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n13

            If $workarray01[$i] = $n14 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n14

            If $workarray01[$i] = $n21 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n21

            If $workarray01[$i] = $n22 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n22

            If $workarray01[$i] = $n23 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n23

            If $workarray01[$i] = $n24 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n24
        Next

; ------------------------------------------------------------------
; Forum-Information:
; Result Should Be
;14=D
;22=F
;14=D
;11=A
;14=D
;24=H
;21=E
;11=A
; ------------------------------------------------------------------


_ArrayDisplay($workarray03, "Combined")

; ----------------------------------------------------------------
; PART F: convert the numerals back to alphabetical values
; ----------------------------------------------------------------

    ; The following would be defined as a Function ... so: begin function here
        For $i = 0 To UBound($workarray03) - 1
            If $workarray03[$i] = $n11 Then $workarray04[$i] = $a11
            If $workarray03[$i] = $n12 Then $workarray04[$i] = $a12
            If $workarray03[$i] = $n13 Then $workarray04[$i] = $a13
            If $workarray03[$i] = $n14 Then $workarray04[$i] = $a14
            If $workarray03[$i] = $n21 Then $workarray04[$i] = $a21
            If $workarray03[$i] = $n22 Then $workarray04[$i] = $a22
            If $workarray03[$i] = $n23 Then $workarray04[$i] = $a23
            If $workarray03[$i] = $n24 Then $workarray04[$i] = $a24
        Next
    ; ......................................................end function here

; -------------- now let us look at our reslut (convert array back to string)

$result = _ArrayToString($workarray04, "")
MsgBox(0, "Result", $result)

; ------------------------------------------------------------------
; Forum-Information:
; Result Should Be
;
;DFDADHEA
;
; ------------------------------------------------------------------

now i do not want to compare two different lines from two different arrays. it must remain linear 1=1=1 ; 2=2=2 ; 3=3=3 ; etc.

i know some will ask: why bother converting the alpabetical entry to a numeric entry? this is an example and in the finished thing there will be something like "Settings" or "Modes" and "Cables" ... Imagine an Errorcode on a computer, it is more or less like that with the difference you know exactly where to look for the error because you get two codes (Settings and Modes) that will then tell you which cable is the one that is producing the error.

that is why my initial question is: is there some way to not write 10000 or even 1000000 lines of code but somehow simplify this procedure? 

kind regards to all

 

Posted
3 hours ago, roeselpi said:

i will make a miniture working model so you can understand what i want to do and why i doubt that i can use 2D arrays.

roselapi, 2D arrays may or may not be necessary, but there is little doubt that you are the master of the 0D array :)

Code hard, but don’t hard code...

  • Moderators
Posted (edited)

roeselpi,

As the substitution algorithm for the value to insert into $workarray03 based on the values in $workarray01/02 is extremely simple you can shorten the code quite a lot - just look for my comments in the <<<<<<<<<<< lines:

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <String.au3>

Global $maxsize = 8 ; Declare this here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; ----------------------------------------------------------------
; PART A: GUI
; ----------------------------------------------------------------

; not needed here for demonstration (is not built yet anyway)

; ----------------------------------------------------------------
; PART B: declare all variables that are for the basic functioning
; ----------------------------------------------------------------

; Covert these individual values to arrays <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; ---------- for testing: $a will be alphabetical chars
Global $arrayletter[$maxsize] = ["A", "B", "C", "D", "E", "F", "G", "H"]
; ---------- for testing: $n will be numerical chars
Global $arraynumber[$maxsize] = [11, 12, 13, 14, 21, 22, 23, 24]
; ------------------------------------------------------------------

; Forum-Information:
; For Simplification: A=11, B=12, C=13, D=14, E=21, F=22, G=23, H=24
; ------------------------------------------------------------------

; ----------------------------------------------------------------
; PART C: create work-arrays and fill with replacable data
; ----------------------------------------------------------------



#cs

    ; The following would be defined as a Function ... so: begin function here
    Global $workarray01[4] = ["#", "#", "#", "#"]
    Global $workarray02[4] = ["#", "#", "#", "#"]
    Global $workarray03[4] = ["#", "#", "#", "#"]
    Global $workarray04[4] = ["#", "#", "#", "#"]
            For $i = 0 To 4
            _ArrayConcatenate ($workarray01, $workarray01)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray02, $workarray02)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray03, $workarray03)
            Next
            For $i = 0 To 4
            _ArrayConcatenate ($workarray04, $workarray04)
            Next
    ReDim $workarray01[$maxsize]
    ReDim $workarray02[$maxsize]
    ReDim $workarray03[$maxsize]
    ReDim $workarray04[$maxsize]
#ce


; Just declare these arrays at full size, no need to fill them <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Global $workarray01[$maxsize]
    Global $workarray02[$maxsize]
    Global $workarray03[$maxsize]
    Global $workarray04[$maxsize]
    ; ............................................end function here


; ----------------------------------------------------------------
; PART D: here comes the userdata ... the data the user has typed
; ----------------------------------------------------------------

Local $userdatastring01 = "abefh"
$userdataupcasestring01 = StringUpper($userdatastring01)
$userdataarray01 = StringSplit($userdataupcasestring01, "", $STR_NOCOUNT)
; Only concatenate enough times to get just a little over $maxsize... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For $i = 1 To Ceiling($maxsize / StringLen($userdatastring01))
    _ArrayConcatenate ($userdataarray01, $userdataarray01)
Next
; ...and then trim as required
ReDim $userdataarray01[$maxsize]


_ArrayDisplay($userdataarray01, "userdata 1")


Local $userdatastring02 = "cdg"
$userdataupcasestring02 = StringUpper($userdatastring02)
$userdataarray02 = StringSplit($userdataupcasestring02, "", $STR_NOCOUNT)
; Same here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For $i = 1 To Ceiling($maxsize / StringLen($userdatastring02))
    _ArrayConcatenate ($userdataarray02, $userdataarray02)
Next
ReDim $userdataarray02[$maxsize]


_ArrayDisplay($userdataarray02, "userdata 2")


; --------- ALL Arrays are now exactly the same size. each 8 digits long


; ----------------------------------------------------------------
; PART E: filling the workarrays with the correct numeric values
; ----------------------------------------------------------------
#cs
; The following would be defined as a Function ... so: begin function here
        For $i = 0 To UBound($userdataarray01) - 1
            If $userdataarray01[$i] = $a11 Then $workarray01[$i] = $n11
            If $userdataarray01[$i] = $a12 Then $workarray01[$i] = $n12
            If $userdataarray01[$i] = $a13 Then $workarray01[$i] = $n13
            If $userdataarray01[$i] = $a14 Then $workarray01[$i] = $n14
            If $userdataarray01[$i] = $a21 Then $workarray01[$i] = $n21
            If $userdataarray01[$i] = $a22 Then $workarray01[$i] = $n22
            If $userdataarray01[$i] = $a23 Then $workarray01[$i] = $n23
            If $userdataarray01[$i] = $a24 Then $workarray01[$i] = $n24
        Next
    ; .......................................................end function here
#ce
    ; As you have the values in arrays, you can easily loop through them <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        For $i = 0 To $maxsize - 1
            For $j = 0 To $maxsize - 1
                If $userdataarray01[$i] = $arrayletter[$j] Then
                    $workarray01[$i] = $arraynumber[$j]
                    ExitLoop
                EndIf
            Next
        Next
    ; .......................................................end function here


_ArrayDisplay($workarray01, "Transform 1")


    ; And again here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        For $i = 0 To $maxsize - 1
            For $j = 0 To $maxsize - 1
                If $userdataarray02[$i] = $arrayletter[$j] Then
                    $workarray02[$i] = $arraynumber[$j]
                    ExitLoop
                EndIf
            Next
        Next
    ; ......................................................end function here


_ArrayDisplay($workarray02, "Transform 2")


; ----------------------------------------------------------------
; Forum Information: This is the Part Where I am stuck at the moment:
;
; PART F: combining and resetting the values
;
; ----------------------------------------------------------------

; And here is the sexy bit!!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        ; Work through $workarray01
        For $i = 0 To UBound($workarray01) - 1

            ; And then look at the possible $workarray01 values <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            For $j = 0 To $maxsize - 1

                ; Until we find the correct one <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                If $workarray01[$i] = $arraynumber[$j] Then

                    ; Now we look for the corresponding $workarray02 value <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    For $k = 0 To $maxsize
                        ; And when we find it...
                        If $workarray02[$i] = $arraynumber[$k] Then

                            ; ...we calculate the correct value to insert into $workarray03
                            $workarray03[$i] = $arraynumber[Mod($k + $j + 1, $maxsize)]

                            ; And as we have finished with this element of $workarray01 we can move onto the next <<<<<<<<<<
                            ExitLoop 2

                        EndIf
                    Next
                EndIf
            Next
        Next
#cs



            If $workarray01[$i] = $n11 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n11 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n11

            If $workarray01[$i] = $n12 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n12 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n12

            If $workarray01[$i] = $n13 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n13 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n13

            If $workarray01[$i] = $n14 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n14 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n14

            If $workarray01[$i] = $n21 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n21 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n21

            If $workarray01[$i] = $n22 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n22 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n22

            If $workarray01[$i] = $n23 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n24
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n23 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n23

            If $workarray01[$i] = $n24 And $workarray02[$i] = $n11 Then $workarray03[$i] = $n11
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n12 Then $workarray03[$i] = $n12
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n13 Then $workarray03[$i] = $n13
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n14 Then $workarray03[$i] = $n14
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n21 Then $workarray03[$i] = $n21
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n22 Then $workarray03[$i] = $n22
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n23 Then $workarray03[$i] = $n23
            If $workarray01[$i] = $n24 And $workarray02[$i] = $n24 Then $workarray03[$i] = $n24
        Next
#ce

; ------------------------------------------------------------------
; Forum-Information:
; Result Should Be
;14=D
;22=F
;14=D
;11=A
;14=D
;24=H
;21=E
;11=A
; ------------------------------------------------------------------


_ArrayDisplay($workarray03, "Combined")

; ----------------------------------------------------------------
; PART F: convert the numerals back to alphabetical values
; ----------------------------------------------------------------

    ; Again work through the elements of $workarray03 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    For $i = 0 To $maxsize - 1
        ; And look at each possibility for its content <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        For $j = 0 To $maxsize - 1
            ; And then change it if necessary <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            If $workarray03[$i] = $arraynumber[$j] Then
                $workarray04[$i] = $arrayletter[$j]
                ExitLoop
            EndIf
        Next
    Next

#cs
    ; The following would be defined as a Function ... so: begin function here
        For $i = 0 To UBound($workarray03) - 1
            If $workarray03[$i] = $n11 Then $workarray04[$i] = $a11
            If $workarray03[$i] = $n12 Then $workarray04[$i] = $a12
            If $workarray03[$i] = $n13 Then $workarray04[$i] = $a13
            If $workarray03[$i] = $n14 Then $workarray04[$i] = $a14
            If $workarray03[$i] = $n21 Then $workarray04[$i] = $a21
            If $workarray03[$i] = $n22 Then $workarray04[$i] = $a22
            If $workarray03[$i] = $n23 Then $workarray04[$i] = $a23
            If $workarray03[$i] = $n24 Then $workarray04[$i] = $a24
        Next
    ; ......................................................end function here

; -------------- now let us look at our reslut (convert array back to string)
#ce

$result = _ArrayToString($workarray04, "")
MsgBox(0, "Result", $result)

; ------------------------------------------------------------------
; Forum-Information:
; Result Should Be
;
;DFDADHEA
;
; ------------------------------------------------------------------

I have no idea what you are doing with this script, but my version gives you the same result as your rather less elegant code - and in my opinion is scalable to deal with a very much bigger $maxsize value without changing a line.

And if $maxsize is very large, you can get rid of $workarray04 and just directly replace the numeric values in $workarray03 with the letters - that would save a fair bit of memory.

Please ask if you have any questions.

M23

Edited by Melba23
Made it scalable after saying it was!

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

@Melba23, great work, but @roeselpi, again what problem are you trying to solve??

And I don’t mean from a programming point of view, but only in the general sense.


I have no doubt that if you share that with this group your ultimate code needed will be vastly reduced, even from the code that’s been posted so far.

Code hard, but don’t hard code...

Posted

@Melba23: fantastic. i wish that i could come up with these kind of elegant solutions. with me it never turns out that nice, but hey i at least got the job done with my code as well. it will take a few days to implement and rewrite everything accordingly. thanks a lot for the help so far, that has been really great.

  • Moderators
Posted

roeselpi,

Delighted I could help. But I would echo the comments above - if you could explain just what it is you are trying to do in the "real world" rather than just posting a programming conundrum, we might be able to offer even more elegant solutions.

A good example is a thread from some time ago where in this post the OP explained exactly what he was trying to do:

In this case once we understood the exact requirement we were able to come up with some really good solutions far removed from the original code framework.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted
1 hour ago, Melba23 said:

if you could explain just what it is you are trying to do in the "real world" rather than just posting a programming conundrum, we might be able to offer even more elegant solutions.

last time i did that here, ( see: my (still not quite finished) word scrambler ) i got a reply like this: 

Quote

In that kind of case you should remake a new thread. 

 

Becose you're asking much different things. and people probably wont read this until here. 

i got a lot of help from caramen and have more or less completed my programme from back then ... (one issue remains, but i am a lot further then i was back then)  ... mmh, maybe i should look into finishing that as well as it is only a minor thing that must be implemented to make it work the way i had envisioned it.

anyway, i was led to believe that there is no point in writing down what you want to do, but rather more to post individual problems and get solutions for those things, rather than making one thread with all related problems. so i try to stick to that.

half the time i have an idea of what i want to do but encounter something else that would make it better and then just try to do exactly that.

at the end of the day it all boils down to cryptology (cypher-software) based on the shifting of alphabetic and numeric characters with the help of a one-time-pad. only difference in my design is: you will need not just one one-time-pad but rather more two and therefor you would have to encrypt the one-time-pad(s) to decrypt the data. ... in one direction it works beautifully but i have hit a rather big problem within the reverse engineering: something my eye can do which software can not do: since i do not want to end up with encrypted data looking like this "§3eert&vb[;as" but rather more like encrypted data looking like "abcdefg" i have devised a hypothesis that 3 different digits are displayed by one alphabetic symbol. .... in the direction of encryption it is all easy, but in the other direction i have hit a task that seems impossible: i know the values (in numerals or in characters) of the two combined one-time-pad(s) so i have an undisputable fixed set of values that are always there. then on the other hand i have the encrypted data consisting of only alphabetical digits. now i know that an "A" could be one of three different signs, and even if i decode all three versions i will get three differnt outputs and my eye can see a way to get the message out of that, but a software would not be able to determine which letter from which decription would be the right one because it can not determine that two of the three possible decryptions is wrong.

i have been thinking a lot about my problem and at first i thought, well it is no problem if i double the number of letters (characters) because i have numeric values as well. but that would make a longer message than i would hope for. "hello world" would not be "acfgh mnopq" but rather more "aaccffgghh mmnnooppqq" and that is no good at all. a bit of a bummer, so it looks like a dead end for the time being. 

i will look further into the encryption for now and get the system running to the way i envision it, then it all comes down to the reverse engineering and that will probably ultimatly be the end of the line because there will be no way to accomplish that without flaw. but i will press on until i reach that point.

i might have another question here or there but probably deal with that in a different thread.

kind regards

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
×
×
  • Create New...