Sign in to follow this  
Followers 0
gil900

Need Help with a bug in some tool I built

1 post in this topic

#1 ·  Posted (edited)

Hello,

I built a little program that looks like this:

Posted Image

The program aims to write the same thing many times (according to the number that I set on "loops") but with little change.

Each row contains the letter "$" will be written as usual but instead of letter "$" write a number that every loop the number increases.

The problem is that if I choose to have 50 loops so it does not make 50 loops .. This makes about 27 loops .. If I choose 100 loops, this makes about 56 loops.

If I choose 1000 loops, it makes about 587 loops.

The code is based on an algorithm I did from 0 (I wrote the algorithm that performs it) but I did not expect it to work like that ..

Is the text I tried:

WAIT SECONDS=2

TAG POS=1 TYPE=SPAN ATTR=ID:qbi

TAG POS=1 TYPE=A ATTR=TXT:Upload<SP>an<SP>image

TAG POS=1 D:Search$.png

TAB OPEN

I attached the file au3 built.

The file code content:

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Local $y
$f = false
$c = 1
$file_write = "text.txt"
$letter = "$"
$t = "_"

$Form1_1 = GUICreate("tool", 508, 254, 286, 161)
$Edit1 = GUICtrlCreateEdit("", 24, 16, 353, 217)
GUICtrlSetData(-1, "")
$c_file_write = GUICtrlCreateButton("Select Name", 392, 128, 97, 41)
$c_file = GUICtrlCreateButton("Write File", 392, 184, 97, 41)
$Nloops_data = GUICtrlCreateCombo("", 392, 80, 41, 25)
GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|_", "2")
$Label1 = GUICtrlCreateLabel(":Loops", 440, 80, 52, 17)
GUISetState(@SW_SHOW)


Func algorithm()
$Nloops = GUICtrlRead($Nloops_data)
$nl = _GUICtrlEdit_GetLineCount($Edit1)
for $x0 = 1 to $Nloops step 1
$t = $x0
for $x = 1 to $nl step 1
$nx = $x-1
for $i = 1 to 300 step 1
$line = _GUICtrlEdit_GetLine($Edit1, $nx)
$line = StringTrimRight($line, $i-1)
if $line = "" Then
$n = $i-1
$line = _GUICtrlEdit_GetLine($Edit1, $nx)
ExitLoop
EndIf
Next
for $l = 1 to $n step 1
$nx2 = $nx + 1
$v = StringTrimRight($line, $n-$l)
$v = StringTrimLeft($v, -1+$l)
If $v = $letter Then
$f = true
$c = $nx2
$p1 = StringTrimRight($line, $n-$l+1)
$p2 = StringTrimLeft($line, -1+$l+1)
FileWriteLine($file_write,$p1 & $t & $p2)
EndIf
if $nx2 > $c Then
$f = false
EndIf
if $l = $n and $f = false then
FileWriteLine($file_write,$line)
EndIf
Next
Next
Next
EndFunc

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $c_file
Call("algorithm")
Case $c_file_write
$file_write = FileSaveDialog( "Select a file name", @DesktopDir, "Text files (*.txt)", 2, $file_write)
If StringRight($file_write,4) <> ".txt" Then $file_write = $file_write & ".txt"
EndSwitch
WEnd

Thank for helpers

EDIT:

Ok now I see that there is no bug.

It just performs the action a little more time than I thought.

(10 seconds)

Edited by gil900

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