# Help with shortening code? :)

## Recommended Posts

Alright, so I have this website with radio dramas that are updated weekly, where one is added and one is removed. So, I know the number of episodes there will be.

I created a script to pull the links, but my problem is I can tell how long the script is going to be the way I am going to do it.

Here's what I have:

```#include <IE.au3>

Global \$Count

\$Count += 1
If \$Count = 23 Then
EndIf
If \$Count = 24 Then
EndIf
Next```

So, the way I know how to do it I am going to need to write 52 If statements. And that is going to take a lot of space and I'm sure theres a better/cleaner way to do this.

I am going to look into atm, but I was wondering if anyone could lend a hand to make it go quicker!

Thanks!

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

##### Share on other sites

I'm not sure exactly what you mean, but it looks like these 2 lines are exactly the same:

If \$Count = 23 Then

EndIf

If \$Count = 24 Then

EndIf

If these are the lines you are going to repeat, just incrimenting (24, 25, 26 etc.) 52 times, then why not a single line that says

If \$Count > 22 Then

EndIf

*edit to include 23 in the if statement*

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game

We're gonna need another Timmy!

##### Share on other sites

Would this work?

```#include <IE.au3>

Global \$Count

\$id = 23
\$cout = 0
\$Count += 1
Do
\$cout += 1
Until \$cout = 52
Next```

##### Share on other sites

Is this short enough for you?

```#include <file.au3>

Couldn't resist. This would have been usefull in the other topic btw. It allows you to properly get the titles.

Edit:

This will add any links that are not in the file yet to the existing file:

```#include <array.au3>
#include <file.au3>
Global \$sFilePath, \$sSource
Exit
EndIf
If IsArray(\$aFile) Then ;check if anything is loaded
For \$i = 0 To UBound(\$aLinks) -1 ;loop through each link in the array
EndIf
Next
_FileWriteFromArray(\$sFilePath,\$aLinks,1) ;write the new array back to the file
Else
_FileWriteFromArray(\$sFilePath,\$aLinks) ;if there is no file array, create the file with the links we found
EndIf```
Edited by Tvern

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...