Sign in to follow this  
Followers 0
jftuga

need generic way to run this program

4 posts in this topic

I am reading in data from another system which can have varying dimensional sizes given the different data set & sizes. It worked great for a few months, but now the number of dimensions can dynamically change between 3 and 11. My code is hard-coded to work with a dimension size of 3. I use variables $x, $y, $z. I don't know how to change the code to work for a varying length. I have tried to isolate the code to the smallest section possible so that some one can help me.

In the code, I use 3 for loops, $x, $y, $z, for 3 dimensions. For each run, $a and $b are constant, but can have different values each day. Is there any way to make this one loop (maybe recursion) or something else so that on any given day, it can handle between 3 and 11? I would hate to nest 11 for loops. Surely there is a more clever way. Any help would be greatly appreciated.

Thanks,

-John

for $x = $a to $b
    for $y = $a to $b
        for $z = $a to $b
        ; from_inet_port is defined in another file
            $data = from_inet_port($x) & from_inet_port($y) & from_inet_port($z)
            FileWriteLine($f, $data)
        next
    next
next

Share this post


Link to post
Share on other sites



I am reading in data from another system which can have varying dimensional sizes given the different data set & sizes. It worked great for a few months, but now the number of dimensions can dynamically change between 3 and 11. My code is hard-coded to work with a dimension size of 3. I use variables $x, $y, $z. I don't know how to change the code to work for a varying length. I have tried to isolate the code to the smallest section possible so that some one can help me.

In the code, I use 3 for loops, $x, $y, $z, for 3 dimensions. For each run, $a and $b are constant, but can have different values each day. Is there any way to make this one loop (maybe recursion) or something else so that on any given day, it can handle between 3 and 11? I would hate to nest 11 for loops. Surely there is a more clever way. Any help would be greatly appreciated.

Thanks,

-John

for $x = $a to $b
    for $y = $a to $b
        for $z = $a to $b
    ; from_inet_port is defined in another file
            $data = from_inet_port($x) & from_inet_port($y) & from_inet_port($z)
            FileWriteLine($f, $data)
        next
    next
next

Have a look at ReDim in the help file, this might be what you need.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Can you determine the number of iterations required from "from_inet_port"?

$b = 0
While 1
    $line = FileReadLine($file)
    $b += 1
    If @error = -1 Then ExitLoop
WendoÝ÷ Ù8Z·lü¨¹ªÞ­æx"µúè§ââÊ¡j÷¢µ©euçâçZ±©Ú®¶²¶.Ê¢}ý·*.¦ºi¹rr¥w*.².ÖÞi¹^¶¬y@hºwZºÚ"µÍÜ    ÌÍÞH ÌÍØHÈPÝ[
    ÌÍÙÛWÚ[]ÜÜ   ÌÍÙ[LJBÜ    ÌÍÞHH    ÌÍØHÈPÝ[
    ÌÍÙÛWÚ[]ÜÜ   ÌÍÙ[LBÜ ÌÍÞH ÌÍØHÈPÝ[
    ÌÍÙÛWÚ[]ÜÜ   ÌÍÙ[LÊBÈÛWÚ[]ÜÜÈY[Y[[Ý[B ÌÍÙ]HHÛWÚ[]ÜÜ
    ÌÍÞ
H   [ÈÛWÚ[]ÜÜ
    ÌÍÞJH    [ÈÛWÚ[]ÜÜ
    ÌÍÞB[]S[J ÌÍÙ  ÌÍÙ]JB^^^

Hopefully that gives you some ideas if nothing else.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Not enough info for us to really help you...

Just palying here..

example

#include <file.au3>
Dim $aRecords, $fRead = "C:\Test.txt"
If Not _FileReadToArray($fRead, $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array     error:" & @error)
    Exit
EndIf

Dim $Data[UBound($aRecords) ]
Dim $display, $max
Dim $bRecords


For $x = 1 To $aRecords[0]
    $bRecords = StringSplit($aRecords[$x], ",")
    If UBound($bRecords) > $max Then $max = UBound($bRecords)
    For $i = 1 To $bRecords[0]
        $Data[$x] &= $bRecords[$i]
    Next
    $display &= $Data[$x] & @CRLF & @CRLF
Next

MsgBox(64, "Files = " & UBound($aRecords) & " Depth = " & $max , $display, 5)

Dim $Data2[UBound($aRecords) ]
$display = ""

For $x = 1 To $aRecords[0]
    $bRecords = StringSplit($aRecords[$x], ",")
    For $i = 1 To $bRecords[0]
        $Data2[$i] &= $bRecords[$i]
        ToolTip( "Sorting #" & $x & "   #" & $i & "   " & $Data2[$i], 20, 20)
        Sleep(300) ; to see the tool tip
    Next
Next

For $n = 1 to $aRecords[0]
    $display &= $Data2[$n] & @CRLF & @CRLF
Next

ToolTip("")
MsgBox(64, "Data sorted" , $display)

and the "C:\Test.txt" file

data1,data2,data3,data4,data5,data6,data7,data8,data9,data10,data11
info1,info2,info3,info4
text1,text2,text3,text4,text5,text6,text7
link1,link2,link3,link4
one1,one2,one3
max1,max2,max3,max4
line1,line2,line3
part1,part2,part3,part4,part5
do1,do2,do3,do4,do5,do6,do7
not1,not2,not3,not4,not5
place1,place2,place3,place4
end1,end2,end3,end4,end5,end6,end7,end8,end9,end10,end11

8)


NEWHeader1.png

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  
Followers 0