I am creating 8 images using Cheat Engine Lua script and I want to add some pictures to the images from an array table.
the_famous = {
{photo = "AlbertEinstein.jpg", nickName = "einstein", actorName = "Albert Einstein", profession = "Physicist", creation = "Theory of relativity", nationality = "Germany", life = "14 March 1879 - 18 April 1955"},
{photo = "Mozart.jpg", nickName = "mozart", actorName = "Wolfgang Amadeus Mozart", profession = "Classical Music Composer", creation = "Symphony No.40", nationality = "Austria", life = "27 January 1756 – 5 December 1791"},
{photo = "Guevara.jpg", nickName = "guevara", actorName = "Ernesto 'Che' Guevara", profession = "Revolutionary", creation = "Cuban Revolution", nationality = "Cuba, Argentina ", life = "14 June 1928 - 9 October 1967"},
{photo = "BruceLee.jpg", nickName = "bruce lee", actorName = "Bruce Lee (Lee Jun Fan)", profession = "Martial Artist", creation = "Father of MMA", nationality = "Hongkong, America", life = "27 November 1940 - 20 July 1973"},
{photo = "Marilyn.jpg", nickName = "marilyn monroe", actorName = "Marilyn Monroe (Norma Jeane Mortenson)", profession = "Artist", creation = "The most famous sex symbol", nationality = "America", life = "1 June 1926 - 5 August 1962"}}
function start()
if #the_famous ~= 0 then
the_famous.ItemIndex = 0
local idx = the_famous.ItemIndex
for i = 1, 8 do
local idx = tableTemp.ItemIndex
local img = string.format('image1'..i) -- images name start with 'image11' till 'image18'
local pic = the_famous[i].photo
img.Picture.loadFromFile(path_to_images_stored..tostring(pic))
img.Hint = the_famous[i].nickname
idx = idx + 1
end
end
end
But the function above doesn't work. How I can do it properly?
Solved
I have change my script:
local cleft = 20
local ctop = 20
function getCategory(sender)
local cat = sender.Name
if cat == 'btnFamous' then
while #tableTemp ~= 0 do rawset(tableTemp, #tableTemp, nil) end
tableTemp = {}
for z=1, #the_famous do tableTemp[z] = the_famous[z] end
else
return nil
end
for i = 1, 24 do
local newImg = createImage(mPanel)
newImg.width = 90
newImg.height = 90
newImg.top = ctop
newImg.left = cleft
newImg.Stretch = true
newImg.Picture.loadFromFile(famous_img..tostring(tableTemp[i].photo))
newImg.showHint = true
newImg.Hint = tostring(tableTemp[i].nickName)
newImg.Name = 'pic00'..i
cleft = cleft + 100
if i == 8 or i == 16 then
cleft = 20
ctop = ctop + 100
end
newImg.OnMouseEnter = function()
hglight.visible=true
hglight.setPosition(newImg.Left-10, newImg.Top-10)
end
newImg.OnMouseLeave = function()
hglight.visible=false
hglight.setPosition(newImg.Left-10, newImg.Top-10)
end
end
end
All works properly
Related
// Inputs
var rsiLength = 14
var macdFastLength = 12
var macdSlowLength = 26
var macdSignalLength = 9
var atrLength = 14
var volumeFactor = 0.1
// Calculate indicators
var rsi = rsi(close, rsiLength)
var macd = macd(close, macdFastLength, macdSlowLength, macdSignalLength)
var atr = atr(atrLength)
var volume = volume * volumeFactor
// Define signals
var buySignal = rsi < 30 and macd.histogram > 0 and volume > atr
var sellSignal = rsi > 70 and macd.histogram < 0 and volume > atr
// Plot signals
plot(buySignal ? 50 : na, color=color.green, linewidth=3, style=plot.style_circles, title='Buy Signal')
plot(sellSignal ? 50 : na, color=color.red, linewidth=3, style=plot.style_circles, title='Sell Signal')
// Capital
strategy.risk = 0.01
strategy.entry("Long", strategy.long, when=buySignal, comment="Buy")
strategy.close("Long", when=sellSignal, comment="Sell")
Script could not be translated from: |B|var rsiLength = 14|E|
It tried to make a strategy which generates buy and sell signal but it showing this
My problem is that inserting data into the database is too slow. I have written a correct algorithm that loads the data properly however with this method it will take 700 hours to load the database. There are almost 30 million records in the csv file.
Here is my models.py
from django.db import models
class Region(models.Model):
region = models.CharField(max_length=20)
class Rank(models.Model):
rank = models.IntegerField()
class Chart(models.Model):
chart = models.CharField(max_length=8)
class Artist(models.Model):
artist = models.CharField(max_length=60)
class Title(models.Model):
title = models.CharField(max_length=60)
class ArtistTitle(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
title = models.ForeignKey(Title, on_delete=models.CASCADE)
class SpotifyData(models.Model):
title = models.ForeignKey(ArtistTitle, related_name='re_title', on_delete=models.CASCADE)
rank = models.ForeignKey(Rank, on_delete=models.CASCADE)
date = models.DateField()
artist = models.ForeignKey(ArtistTitle, related_name='re_artist', on_delete=models.CASCADE)
region = models.ForeignKey(Region, on_delete=models.CASCADE)
chart = models.ForeignKey(Chart, on_delete=models.CASCADE)
streams = models.IntegerField()
My upload script looks like this:
def load_to_db(self, df):
bad = 0
good = 0
start = datetime.datetime.now
for _, row in df.iterrows():
try:
region_obj, _ = Region.objects.get_or_create(
region=row["region"],
)
rank_obj, _ = Rank.objects.get_or_create(
rank=row["rank"],
)
chart_obj, _ = Chart.objects.get_or_create(
chart=row["chart"],
)
artist_obj, _ = Artist.objects.get_or_create(
artist=row["artist"],
)
title_obj, _ = Title.objects.get_or_create(
title=row["title"],
)
arttit_obj, _ = ArtistTitle.objects.update_or_create(
artist=artist_obj,
title=title_obj,
)
spotifydata_obj, _ = SpotifyData.objects.update_or_create(
title=arttit_obj,
rank=rank_obj,
date=row["date"],
artist=arttit_obj,
region=region_obj,
chart=chart_obj,
streams=row["streams"],
)
good += 1
now = datetime.datetime.now
print(f"goods: {good}, loading time: {start-now}", )
except Exception as e:
bad += 1
current_time = datetime.datetime.now()
with open("data_load_logging.txt", "w") as bad_row:
bad_row.write(
f"Error message: {e} \n"
+ f"time: {current_time}, \n"
+ f"title: {row['title']}, type: {row['title']} \n"
+ f"rank: {int(row['rank'])}, type: {int(row['rank'])} \n"
+ f"date: {row['date']}, type: {row['date']} \n"
+ f"artist: {row['artist']}, type: {row['artist']} \n"
+ f"region: {row['region']}, type: {row['region']} \n"
+ f"chart: {row['chart']}, type: {row['chart']} \n"
+ f"streams: {int(row['streams'])}, type: {int(row['streams'])} \n"
+ "-" * 30
+ "\n"
)
I know it could probably help to use bulk/bulk_create/bulk_update but I can't figure out how to write the correct script....
def load_to_db(self, path):
start_time = timezone.now()
try:
with open(path, "r") as csv_file:
data = csv.reader(csv_file)
next(data)
packet_region = []
packet_rank = []
packet_chart = []
packet_artist = []
packet_title = []
packet_artist_title = []
packet_spotify_data = []
bad = -1 # first row is a header
for row in data:
region = Region(
region = row[4]
)
rank = Rank(
rank = row[1]
)
chart = Chart(
chart = row[5]
)
artist = Artist(
artist = row[3]
)
title = Title(
title = row[0]
)
artist_title = ArtistTitle(
artist = artist,
title = title
)
spotify_data = SpotifyData(
title = artist_title,
rank = rank,
date = row[3],
artist = artist_title,
region = region,
chart = chart,
streams = int(row[6])
)
packet_region.append(region)
packet_rank.append(rank)
packet_chart.append(chart)
packet_artist.append(artist)
packet_title.append(title)
packet_artist_title.append(artist_title)
packet_spotify_data.append(spotify_data)
if len(packet_spotify_data) > 1000:
print(datetime.datetime.now())
Region.objects.bulk_create(packet_region)
Rank.objects.bulk_create(packet_rank)
Chart.objects.bulk_create(packet_chart)
Artist.objects.bulk_create(packet_artist)
Title.objects.bulk_create(packet_title)
ArtistTitle.objects.bulk_update(packet_artist_title)
SpotifyData.objects.bulk_update(packet_spotify_data)
packet_region = []
packet_rank = []
packet_chart = []
packet_artist = []
packet_title = []
packet_artist_title = []
packet_spotify_data = []
logging.info(f"Failure numbers: {bad}")
if packet_spotify_data:
Region.objects.bulk_create(packet_region)
Rank.objects.bulk_create(packet_rank)
Chart.objects.bulk_create(packet_chart)
Artist.objects.bulk_create(packet_artist)
Title.objects.bulk_create(packet_title)
ArtistTitle.objects.bulk_update(packet_artist_title)
SpotifyData.objects.bulk_update(packet_spotify_data)
except FileNotFoundError as e:
raise NoFilesException("No such file or directory") from e
end_time = timezone.now()
self.stdout.write(
self.style.SUCCESS(
f"Loading CSV took: {(end_time-start_time).total_seconds()} seconds."
)
)
I tried to use bulk this way but unfortunately it doesn't work
Making an autograde of sorts for an excel bracket with the guesses of each bracket in the ranges marked. Still clearly work in progress, finally have it running through, but the loop isn't working, it's returning pointSum of 0. Trying to sum += 10 when points is true.
Sub foo()
Dim Player(1 To 35) As String
Player(1) = Range("M2")
Player(2) = Range("M4")
Player(3) = Range("M10")
Player(4) = Range("M12")
Player(5) = Range("M22")
Player(6) = Range("M24")
Player(7) = Range("M32")
Player(8) = Range("M34")
Player(9) = Range("L1")
Player(10) = Range("L3")
Player(11) = Range("L5")
Player(12) = Range("L7")
Player(13) = Range("L9")
Player(14) = Range("L11")
Player(15) = Range("L13")
Player(16) = Range("L15")
Player(17) = Range("L20")
Player(18) = Range("L22")
Player(19) = Range("L24")
Player(20) = Range("L26")
Player(21) = Range("L28")
Player(22) = Range("L30")
Player(23) = Range("L32")
Player(24) = Range("L34")
Player(25) = Range("K2")
Player(26) = Range("K6")
Player(27) = Range("K10")
Player(28) = Range("K14")
Player(29) = Range("K21")
Player(30) = Range("K25")
Player(31) = Range("K29")
Player(32) = Range("J4")
Player(33) = Range("J12")
Player(34) = Range("J23")
Player(35) = Range("J31")
Dim Winner(1 To 18) As String
Winner(1) = "Mohler"
Winner(2) = "Scotter"
Winner(3) = "DKGAY"
Winner(4) = "Lassie"
Winner(5) = "Mohler"
Winner(6) = "Gunnar"
Winner(7) = "Gord'n"
Winner(8) = "Hellmers"
Winner(9) = "Evan Brown"
Winner(10) = "Jerru"
Winner(11) = "Case"
Winner(12) = "Lassie"
Winner(13) = "Mohler"
Winner(14) = ""
Winner(15) = ""
Winner(16) = "Mohler"
Winner(17) = "Mohler"
Winner(18) = ""
Dim Guess(1 To 18) As String
Guess(1) = Player(10)
Guess(2) = Player(14)
Guess(3) = Player(18)
Guess(4) = Player(23)
Guess(5) = Player(25)
Guess(6) = Player(26)
Guess(7) = Player(27)
Guess(8) = Player(28)
Guess(9) = Player(29)
Guess(10) = Player(30)
Guess(11) = Player(31)
Guess(12) = Player(32)
Guess(13) = ""
Guess(14) = ""
Guess(15) = ""
Guess(16) = ""
Guess(17) = ""
Guess(18) = ""
Dim points(1 To 18) As Boolean
points(1) = False
points(2) = False
points(3) = False
points(4) = False
points(5) = False
points(6) = False
points(7) = False
points(8) = False
points(9) = False
points(10) = False
points(11) = False
points(12) = False
points(13) = False
points(14) = False
points(15) = False
points(16) = False
points(17) = False
points(18) = False
Dim pointSum As Double
pointSum = 0
Dim pointValue(1 To 6) As Double
pointValue(1) = 10
pointValue(2) = 20
pointValue(3) = 30
pointValue(4) = 40
pointValue(5) = 50
pointValue(6) = 60
For i = 1 To 12 Step 1
If Guess(i) = Winner(i) Then
points(i) = True And pointSum = pointSum + 10
Else
points(i) = False
End If
Next
Range("O1") = pointSum
MsgBox "Done!"
End Sub
For i = 1 To 12 Step 1
If Guess(i) = Winner(i) Then
points(i) = True And pointSum = pointSum + 10
Else
points(i) = False
End If
Next
Ok, several things.
Step 1
That's the default; the Step part of the For loop definition is usually only included when its value is different than 1. But that won't cause any problems.
points(i) = True And pointSum = pointSum + 10
If I understand your question correctly...
the loop isn't working, it's returning pointSum of 0. Trying to sum += 10 when points is true.
You're not assigning pointSum anywhere. The above line of code is interpreted as follows:
points(i) = (True And (pointSum = pointSum + 10))
In other words:
points(i) = (True And False)
In other words:
points(i) = False
When you make an assignment, the variable being assigned to goes on the left side of the assignment operator (=):
foo = 42 'assigns value 42 to foo
The confusion seems to be that in VBA, the comparison operator is also a = token:
If foo = 42 Then 'true when the value of foo is 42
To increment pointSum by 10 when points(i) is True, you can do this:
If points(i) = True Then pointSum = pointSum + 10
Which can be simplified to:
If points(i) Then pointSum = pointSum + 10
Because the (boolean expression) in If (boolean expression) Then doesn't need to be compared to True or False when you're already working with a Boolean variable.
Hope it helps!
Before I begin, let me say that I know this probably isn't best done in excel and VBA, but my hands are tied in that regard.
I have a spreadsheet of 29 columns (always), and anywhere between 100 and 10,000 rows each day.
I need a way to automatically move rows from one sheet to another based on multiple criteria. The basic logic is that it needs to search the first sheet, and if C OR D equal a certain text value, AND Y contains a certain numeric value, it needs to be added to the second sheet and removed from the first.
The problem is that I've built a test version that only looks at ONE of the three criteria, and it is already very slow - If I had two more arrays and if/and/or logic, I don't think this is going to be usable on the 10,000 row days.
What can I do to speed this up? I feel like there has to be a better/faster way than arrays and for loops. I'm very much a novice, so I'm sure this is a very bad solution.
Option Explicit
Sub MacroSoFar()
Dim lColumnLength As Long
Dim intArrayCounter As Integer
Dim TestArray(165) As String
TestArray(0) = "4"
TestArray(1) = "5"
TestArray(2) = "6"
TestArray(3) = "7"
TestArray(4) = "8"
TestArray(5) = "9"
TestArray(6) = "10"
TestArray(7) = "11"
TestArray(8) = "12"
TestArray(9) = "14"
TestArray(10) = "19"
TestArray(11) = "20"
TestArray(12) = "21"
TestArray(13) = "25"
TestArray(14) = "30"
TestArray(15) = "35"
TestArray(16) = "36"
TestArray(17) = "37"
TestArray(18) = "41"
TestArray(19) = "42"
TestArray(20) = "43"
TestArray(21) = "46"
TestArray(22) = "47"
TestArray(23) = "48"
TestArray(24) = "51"
TestArray(25) = "52"
TestArray(26) = "53"
TestArray(27) = "60"
TestArray(28) = "63"
TestArray(29) = "65"
TestArray(30) = "66"
TestArray(31) = "67"
TestArray(32) = "68"
TestArray(33) = "69"
TestArray(34) = "70"
TestArray(35) = "71"
TestArray(36) = "72"
TestArray(37) = "73"
TestArray(38) = "74"
TestArray(39) = "75"
TestArray(40) = "76"
TestArray(41) = "77"
TestArray(42) = "78"
TestArray(43) = "79"
TestArray(44) = "80"
TestArray(45) = "81"
TestArray(46) = "82"
TestArray(47) = "83"
TestArray(48) = "84"
TestArray(49) = "85"
TestArray(50) = "86"
TestArray(51) = "87"
TestArray(52) = "88"
TestArray(53) = "89"
TestArray(54) = "90"
TestArray(55) = "91"
TestArray(56) = "92"
TestArray(57) = "93"
TestArray(58) = "94"
TestArray(59) = "96"
TestArray(60) = "97"
TestArray(61) = "98"
TestArray(62) = "99"
TestArray(63) = "101"
TestArray(64) = "102"
TestArray(65) = "103"
TestArray(66) = "106"
TestArray(67) = "107"
TestArray(68) = "108"
TestArray(69) = "109"
TestArray(70) = "111"
TestArray(71) = "112"
TestArray(72) = "113"
TestArray(73) = "115"
TestArray(74) = "116"
TestArray(75) = "117"
TestArray(76) = "118"
TestArray(77) = "121"
TestArray(78) = "122"
TestArray(79) = "125"
TestArray(80) = "129"
TestArray(81) = "130"
TestArray(82) = "131"
TestArray(83) = "132"
TestArray(84) = "133"
TestArray(85) = "134"
TestArray(86) = "137"
TestArray(87) = "138"
TestArray(88) = "142"
TestArray(89) = "143"
TestArray(90) = "144"
TestArray(91) = "145"
TestArray(92) = "146"
TestArray(93) = "147"
TestArray(94) = "155"
TestArray(95) = "156"
TestArray(96) = "157"
TestArray(97) = "158"
TestArray(98) = "159"
TestArray(99) = "161"
TestArray(100) = "162"
TestArray(101) = "169"
TestArray(102) = "170"
TestArray(103) = "173"
TestArray(104) = "174"
TestArray(105) = "175"
TestArray(106) = "176"
TestArray(107) = "180"
TestArray(108) = "181"
TestArray(109) = "182"
TestArray(110) = "183"
TestArray(111) = "184"
TestArray(112) = "185"
TestArray(113) = "186"
TestArray(114) = "187"
TestArray(115) = "188"
TestArray(116) = "189"
TestArray(117) = "190"
TestArray(118) = "192"
TestArray(119) = "193"
TestArray(120) = "194"
TestArray(121) = "195"
TestArray(122) = "196"
TestArray(123) = "201"
TestArray(124) = "202"
TestArray(125) = "205"
TestArray(126) = "206"
TestArray(127) = "207"
TestArray(128) = "208"
TestArray(129) = "211"
TestArray(130) = "212"
TestArray(131) = "214"
TestArray(132) = "215"
TestArray(133) = "217"
TestArray(134) = "218"
TestArray(135) = "220"
TestArray(136) = "221"
TestArray(137) = "222"
TestArray(138) = "223"
TestArray(139) = "224"
TestArray(140) = "225"
TestArray(141) = "226"
TestArray(142) = "228"
TestArray(143) = "229"
TestArray(144) = "230"
TestArray(145) = "235"
TestArray(146) = "236"
TestArray(147) = "237"
TestArray(148) = "240"
TestArray(149) = "241"
TestArray(150) = "242"
TestArray(151) = "244"
TestArray(152) = "249"
TestArray(153) = "250"
TestArray(154) = "251"
TestArray(155) = "255"
TestArray(156) = "256"
TestArray(157) = "259"
TestArray(158) = "260"
TestArray(159) = "262"
TestArray(160) = "263"
TestArray(161) = "264"
TestArray(162) = "265"
TestArray(163) = "266"
TestArray(164) = "267"
TestArray(165) = "269"
For intArrayCounter = 0 To 165 Step 1
For lColumnLength = Cells(Rows.Count, 25).End(xlUp).Row To 1 Step -1
If InStr(Cells(lColumnLength, 25), TestArray(intArrayCounter)) > 0 Then
Range("a" & lColumnLength & ":AC" & lColumnLength).Copy Sheet10.Cells(Rows.Count, 1).End(xlUp).Offset(1)
Cells(lColumnLength, 29).EntireRow.Delete
End If
Next
Next
End Sub
I haven't tested this, but I got to run.
But it may give you some food for thought.
Option Explicit
Sub MacroSoFar()
Dim lColumnLength As Long
Dim intArrayCounter As Integer
Dim TestArray(165) As String
TestArray(0) = "4"
TestArray(1) = "5"
TestArray(2) = "6"
TestArray(3) = "7"
TestArray(4) = "8"
TestArray(5) = "9"
TestArray(6) = "10"
TestArray(7) = "11"
TestArray(8) = "12"
TestArray(9) = "14"
TestArray(10) = "19"
TestArray(11) = "20"
TestArray(12) = "21"
TestArray(13) = "25"
TestArray(14) = "30"
TestArray(15) = "35"
TestArray(16) = "36"
TestArray(17) = "37"
TestArray(18) = "41"
TestArray(19) = "42"
TestArray(20) = "43"
TestArray(21) = "46"
TestArray(22) = "47"
TestArray(23) = "48"
TestArray(24) = "51"
TestArray(25) = "52"
TestArray(26) = "53"
TestArray(27) = "60"
TestArray(28) = "63"
TestArray(29) = "65"
TestArray(30) = "66"
TestArray(31) = "67"
TestArray(32) = "68"
TestArray(33) = "69"
TestArray(34) = "70"
TestArray(35) = "71"
TestArray(36) = "72"
TestArray(37) = "73"
TestArray(38) = "74"
TestArray(39) = "75"
TestArray(40) = "76"
TestArray(41) = "77"
TestArray(42) = "78"
TestArray(43) = "79"
TestArray(44) = "80"
TestArray(45) = "81"
TestArray(46) = "82"
TestArray(47) = "83"
TestArray(48) = "84"
TestArray(49) = "85"
TestArray(50) = "86"
TestArray(51) = "87"
TestArray(52) = "88"
TestArray(53) = "89"
TestArray(54) = "90"
TestArray(55) = "91"
TestArray(56) = "92"
TestArray(57) = "93"
TestArray(58) = "94"
TestArray(59) = "96"
TestArray(60) = "97"
TestArray(61) = "98"
TestArray(62) = "99"
TestArray(63) = "101"
TestArray(64) = "102"
TestArray(65) = "103"
TestArray(66) = "106"
TestArray(67) = "107"
TestArray(68) = "108"
TestArray(69) = "109"
TestArray(70) = "111"
TestArray(71) = "112"
TestArray(72) = "113"
TestArray(73) = "115"
TestArray(74) = "116"
TestArray(75) = "117"
TestArray(76) = "118"
TestArray(77) = "121"
TestArray(78) = "122"
TestArray(79) = "125"
TestArray(80) = "129"
TestArray(81) = "130"
TestArray(82) = "131"
TestArray(83) = "132"
TestArray(84) = "133"
TestArray(85) = "134"
TestArray(86) = "137"
TestArray(87) = "138"
TestArray(88) = "142"
TestArray(89) = "143"
TestArray(90) = "144"
TestArray(91) = "145"
TestArray(92) = "146"
TestArray(93) = "147"
TestArray(94) = "155"
TestArray(95) = "156"
TestArray(96) = "157"
TestArray(97) = "158"
TestArray(98) = "159"
TestArray(99) = "161"
TestArray(100) = "162"
TestArray(101) = "169"
TestArray(102) = "170"
TestArray(103) = "173"
TestArray(104) = "174"
TestArray(105) = "175"
TestArray(106) = "176"
TestArray(107) = "180"
TestArray(108) = "181"
TestArray(109) = "182"
TestArray(110) = "183"
TestArray(111) = "184"
TestArray(112) = "185"
TestArray(113) = "186"
TestArray(114) = "187"
TestArray(115) = "188"
TestArray(116) = "189"
TestArray(117) = "190"
TestArray(118) = "192"
TestArray(119) = "193"
TestArray(120) = "194"
TestArray(121) = "195"
TestArray(122) = "196"
TestArray(123) = "201"
TestArray(124) = "202"
TestArray(125) = "205"
TestArray(126) = "206"
TestArray(127) = "207"
TestArray(128) = "208"
TestArray(129) = "211"
TestArray(130) = "212"
TestArray(131) = "214"
TestArray(132) = "215"
TestArray(133) = "217"
TestArray(134) = "218"
TestArray(135) = "220"
TestArray(136) = "221"
TestArray(137) = "222"
TestArray(138) = "223"
TestArray(139) = "224"
TestArray(140) = "225"
TestArray(141) = "226"
TestArray(142) = "228"
TestArray(143) = "229"
TestArray(144) = "230"
TestArray(145) = "235"
TestArray(146) = "236"
TestArray(147) = "237"
TestArray(148) = "240"
TestArray(149) = "241"
TestArray(150) = "242"
TestArray(151) = "244"
TestArray(152) = "249"
TestArray(153) = "250"
TestArray(154) = "251"
TestArray(155) = "255"
TestArray(156) = "256"
TestArray(157) = "259"
TestArray(158) = "260"
TestArray(159) = "262"
TestArray(160) = "263"
TestArray(161) = "264"
TestArray(162) = "265"
TestArray(163) = "266"
TestArray(164) = "267"
TestArray(165) = "269"
Dim oSheet As Variant, nSheet As Variant, oList As New Collection, nList As New Collection
oSheet = Range("A1:AC" & Cells(Rows.Count, 25).End(xlUp).Row).Value
For intArrayCounter = 0 To 165 Step 1
For lColumnLength = Cells(Rows.Count, 25).End(xlUp).Row To 1 Step -1
If InStr(oSheet(lColumnLength, 25), TestArray(intArrayCounter)) > 0 Then
' Add to list in order
nList.Add Range("a" & lColumnLength & ":AC" & lColumnLength).Value
Else
' Add to list in reverse order
oList.Add Range("a" & lColumnLength & ":AC" & lColumnLength).Value
End If
Next
Next
For i = oList.Count To 1 Step -1
For j = 1 To 29
oSheet(i, j) = oList(i)(1, j)
Next j
Next i
Range("A1:AC" & Cells(Rows.Count, 25).End(xlUp).Row) = oSheet
Range("A" & oList.Count + 1 & ":A" & Cells(Rows.Count, 25).End(xlUp).Row).EntireRow.Delete Shift:=xlUp
nSheet = Sheet10.Range("A1:AC" & nList.Count).Offset(Sheet10.Range("A" & Sheet10.UsedRange.Rows.Count).End(xlUp).Row).Value
For i = nList.Count To 1
For j = 1 To 29
nSheet(i, j) = nList(i)(1, j)
Next j
Next i
Sheet10.Range("A1:AC" & nList.Count).Offset(Sheet10.Range("A" & Sheet10.UsedRange.Rows.Count).End(xlUp).Row) = nSheet
Set nList = Nothing: Set oList = Nothing:Set oSheet = Nothing: Set nSheet = Nothing
End Sub
am trying to devalope a lights out game with CORONA SDK
but am not able to figure out a way for looping it !!!
how many functions to create and the way to keep this going
here is my code (its dummy but a friend gave it to me as am trying to go on from there )
obj = nil
px = 35
py = 50
r = 22
xi = 60
yi = 60
x1y1 = display.newCircle(px+xi*0,py+yi*0,r) x1y1.id = "x1y1"
x2y1 = display.newCircle(px+xi*1,py+yi*0,r) x2y1.id = "x2y1"
x3y1 = display.newCircle(px+xi*2,py+yi*0,r) x3y1.id = "x3y1"
x4y1 = display.newCircle(px+xi*3,py+yi*0,r) x4y1.id = "x4y1"
x5y1 = display.newCircle(px+xi*4,py+yi*0,r) x5y1.id = "x5y1"
x1y2 = display.newCircle(px+xi*0,py+yi*1,r) x1y2.id = "x1y2"
x2y2 = display.newCircle(px+xi*1,py+yi*1,r) x2y2.id = "x2y2"
x3y2 = display.newCircle(px+xi*2,py+yi*1,r) x3y2.id = "x3y2"
x4y2 = display.newCircle(px+xi*3,py+yi*1,r) x4y2.id = "x4y2"
x5y2 = display.newCircle(px+xi*4,py+yi*1,r) x5y2.id = "x5y2"
x1y3 = display.newCircle(px+xi*0,py+yi*2,r) x1y3.id = "x1y3"
x2y3 = display.newCircle(px+xi*1,py+yi*2,r) x2y3.id = "x2y3"
x3y3 = display.newCircle(px+xi*2,py+yi*2,r) x3y3.id = "x3y3"
x4y3 = display.newCircle(px+xi*3,py+yi*2,r) x4y3.id = "x4y3"
x5y3 = display.newCircle(px+xi*4,py+yi*2,r) x5y3.id = "x5y3"
x1y4 = display.newCircle(px+xi*0,py+yi*3,r) x1y4.id = "x1y4"
x2y4 = display.newCircle(px+xi*1,py+yi*3,r) x2y4.id = "x2y4"
x3y4 = display.newCircle(px+xi*2,py+yi*3,r) x3y4.id = "x3y4"
x4y4 = display.newCircle(px+xi*3,py+yi*3,r) x4y4.id = "x4y4"
x5y4 = display.newCircle(px+xi*4,py+yi*3,r) x5y4.id = "x5y4"
x1y5 = display.newCircle(px+xi*0,py+yi*4,r) x1y5.id = "x1y5"
x2y5 = display.newCircle(px+xi*1,py+yi*4,r) x2y5.id = "x2y5"
x3y5 = display.newCircle(px+xi*2,py+yi*4,r) x3y5.id = "x3y5"
x4y5 = display.newCircle(px+xi*3,py+yi*4,r) x4y5.id = "x4y5"
x5y5 = display.newCircle(px+xi*4,py+yi*4,r) x5y5.id = "x5y5"
bb = {x1y1,x2y1,x3y1,x4y1,x5y1,x1y2,x2y2,x3y2,x4y2,x5y2,x1y3,x2y3,x3y3,x4y3,x5y3,x1y4,x2y4,x3y4,x4y4,x5y4,x1y5,x2y5,x3y5,x4y5,x5y5}
iClicked = 0
function click(e)
if(e.phase == "ended") then
--circleID = e.target.id
--whichCircle()
print(e.target.id)
obj = e.target
for u=1,25 do
if(obj==bb[u]) then
iClicked = u
end
end
if((iClicked-5) > 0 and (iClicked-5) < 26) then
bb[iClicked-5]:setFillColor(1,0,0)
end
if((iClicked-1) > 0 and (iClicked-1) < 26) then
bb[iClicked-1]:setFillColor(1,0,0)
end
obj:setFillColor(1,0,0)
if((iClicked+1) > 0 and (iClicked+1) < 26) then
bb[iClicked+1]:setFillColor(1,0,0)
end
if((iClicked+5) > 0 and (iClicked+5) < 26) then
bb[iClicked+5]:setFillColor(1,0,0)
end
end
end
for k=1,25 do
bb[k]:addEventListener("touch",click)
end
its all about having 25 circles and lighting them on and off but it doesnt seem to work for me
any good help will be great
Thanks
local myCircles = {}
for y = 1, 5 do
myCircles[y] = {}
for x = 1, 5 do
myCircles[y][x] = display.newCircle(px+xi*0,py+yi*4,r)
myCircles[y][x].id = .id = "x" .. x .. "y" .. y
end
end
or something like that.
Rob