Sorting the data in a loop using ASP Classic? - asp-classic

I want to sort the data by the SuppCodeArry in a loop. This is my code:
<%
SuppCodeArry="SA^SA^SB^SA^SC^SB^SA^"
ITEMArry="A^B^C^D^E^F^G^"
str_SuppCode = Split(SuppCodeArry,"^")
str_ItemCode = Split(ITEMArry,"^")
SUPPCODE = ""
str_SuppCode_NEW = ""
str_ItemCode_NEW = ""
For a=0 To UBound(str_SuppCode)-1
Response.Write str_SuppCode(a) & " ["&str_ItemCode(a)&"] <br>"
str_SuppCode_NEW = str_SuppCode_NEW & str_SuppCode(a) &"^"
str_ItemCode_NEW = str_ItemCode_NEW & str_ItemCode(a) &"^"
Next
%>
The result I get with this code is:
SA [A]
SA [B]
SB [C]
SA [D]
SC [E]
SB [F]
SA [G]
I would like to have the result by grouping by the SuppCodeArry as below. How do I do this?
SA [A]
SA [B]
SA [D]
SA [G]
SB [C]
SB [F]
SC [E]
Thanks for any info on this.

Related

Transposition Cipher: How to solve

I have a ciphertext as follows, of which I do not know the keylength:
wlna evesy ehudre thnma upbum w onaw-dino olsile tf hndcseoorl foouA. bnsst uho,et r,vweeirh teorf efer tsw lae tsutas sfeccsan,ul eytd hduu sbhe edtmel faut s,b bo nte oefrroeth ad ofhlea fl, in nthdan olwe hacpe lenbe euce rdo edt acsuhutobslinre ut,h tae a sv tmsoeedswitiny cl ardesro ndipipn ino,ng trat reeac edimanthf o chme ay einrh iwhccodha ur stoorn uftentuauac aqnctina dse oy.realgea Lrsea ms nos fl kiceofdan wi tndieer eroscvto edsindre oun a usht-out e,bcoo n wesin o retou befwh,nd mahic vehy alax ep teindre hepe nsecho oftul sebox kybhi eswav chhenbe eeal aref dyrd rereHo.to r ow uaudhyrencli erngie ba hdconee edenvym r fogaeth terdne to h wospt hrheecore ed rveeseshi menss hhigtreeav edimanevo fr m erarytysee e wrot itn to frof hesulmt ohi d,wol cht aud sy e vrn apli. ltaead Hehdev ei blntycanee d irre bwdono ty wonrpesne s,owhf o ad omhare rmy bkall asml aefethe ndtert ohsun uu llaly ogare Osne.e tn he,owhlwat i stms obar pothebl he atteni slglEt nanhisminb, eg le
How would I be able to decipher this transposed ciphertext in a non-manual way like on https://tholman.com/other/transposition/ ?
I believe that the punctuation and spaces matter as well in this ciphertext.

VBScript to compare each line of string to each line of text file and make replacements

I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it should be easy, but I'm struggling with the iteration.
Here's my code:
Set IE = CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\captions.srt"
OutputCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\NEW_captions.srt"
on error resume next
langURL_es = "https://translate.google.com/#view=home&op=translate&sl=en&tl=es"
'============================================================
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
Do until objFile.AtEndOfStream
if instr(objFile.Readline,">") then
capText = capText & objFile.ReadLine & vbcrlf
end if
loop
objFile.Close
'============================================================
'Navigate to translator and get translations
IE.Visible = true
IE.Navigate langURL_es
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
wscript.sleep 1000
capline = split(capText,vbcrlf)
for i = 0 to ubound(capline)
ie.document.getelementbyid("source").innertext = capline(i)
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
for each div in ie.document.getelementsbytagname("div")
if div.getAttribute("class") = "result-shield-container tlid-copy-target" then
captrans = captrans & capline(i-1) & "," & div.innertext & vbcrlf
end if
next
next
'============================================================
'**************THIS IS THE SECTION THAT'S NOT WORKING RIGHT**************
'compare translations against captions.srt file and make replacements
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
splitfile = split(objfile.readall,vbcrlf)
for each a in splitfile
arrCaptrans = split(captrans,",")
for i = 0 to ubound(arrCaptrans)
if a = arrCaptrans(i) then
newline = newline & arrCaptrans(i+1) & vbcrlf
else
newline = newline & a & vbcrlf
end if
next
next
objFile.Close
wscript.echo newline
'============================================================
'Write translated file
Set objTransFile = objFSO.OpenTextFile(OutputCaptionFile, 2, true) 'for writing
objTransFile.write newline
objTransFile.Close
'============================================================
wscript.echo "Done"
Here is the output I'm expecting:
1
00: 00: 06,800 -> 00: 00: 11,040
-¡Tenemos que averiguar cómo abrir esto!
2
00: 00: 11,080 -> 00: 00: 13,040
-¿Qué haces con ese nickel?
3
00: 00: 13,160 -> 00: 00: 20,440
-Por eso necesitamos sacar el dinero del chocolate de aquí.
4
00: 00: 20,440 -> 00: 00: 22,080
-No hay chocolate dentro de eso.
5
00: 00: 22,580 -> 00: 00: 23,960
-Sí hay
Here is the contents of my source "captions.srt" file:
1
00:00:06,800 --> 00:00:11,040
-We have to figure out how to open this!
2
00:00:11,080 --> 00:00:13,040
-What are you doing with that nickel?
3
00:00:13,160 --> 00:00:20,440
-That's why we need to get the chocolate money out of here
4
00:00:20,440 --> 00:00:22,080
-There's no chocolate inside that.
5
00:00:22,580 --> 00:00:23,960
-Yes there is
*EDIT:
I'm trying to compare each line of the source .srt file with the string I named "captrans". "captrans" contains rows of "sourcetext,translatedtext". I'm splitting on commas, reading each line of source file and if source file line matches (before comma) captrans then replace with (after comma) captrans. Hope this makes sense...
Thank you for any help you can provide!

grViz diagrammeR: justifying rows of nodes

I am using diagrammeR with grViz to generate a flow chart with multiple rows. The rows are grouped together properly, and the vertical order works well. Is there a way to specify justification of full rows (ranks)? I would like them to be centered. Below is code and an image of the example I am working with. I would like rows 3 and 4 to be centered.
Any input would be greatly appreciated.
Thanks.
library("DiagrammeR")
grViz("
digraph CFA {
# Multiple level nodes
node [shape = rectangle, color=CornflowerBlue]
a [label = <<FONT COLOR='blue' POINT-SIZE='18'><b>Surveillance 2017 </b> <br/>Urban Mixtures</FONT>> ];
# http://www.graphviz.org/doc/info/shapes.html#html
#Tiers
node [shape = ellipse, color=CornflowerBlue]
T1 [label = <<u><b><font color = 'forestgreen' point-size = '16'>Tier 1</font></b></u><br/>Water Quality <br/> 16 Watersheds <br/> Quarterly sampling>];
T2 [label = <<u><b><font color = 'forestgreen' point-size = '16'>Tier 2</font></b></u> <br/> Sediment and Passive sampling <br/> 72 Sites>];
#Media assays and ancillary
chem [label = 'Water \\nChemistry'];
bio [label = 'Bio-effects'];
Anc [label = 'Ancillary \\ndata']
sed [label = 'Sediment \\nChemistry'];
pass [label = 'Passive Sampler \\nChemistry'];
# Analyses
node [shape = box, color = Crimson]
owc [label = 'Waste Indicators'];
PFAS [label = 'PFAS: 30 sites']
PAH [label = 'PAHs'];
Att [label = 'Attagene'];
Met [label = 'Metabolomics'];
Tr [label = 'Transcriptomics'];
Hyd [label = 'Hydrology'];
WA [label = 'Watershed \\nAttributes']
# Synthesis
node [shape = 'egg',color = ' forestgreen']
Syn [label = 'Synthesis'];
Tx [label = 'ToxEval\\nHTS/AOP analysis']
{rank = same; T1 T2}
{rank = same; chem bio pass sed Anc}
# {rank = same; PFAS; PAH; WA; Hyd; owc;Att;Met;Tr}
{rank = same; PFAS; PAH; Hyd; owc;WA; Hyd}
{rank = same; Att;Met;Tr}
{rank = same; Tx; Syn}
# Connect nodes with edges and labels
T1 -> a[dir=back]
a -> T2#[dir=back]
T1 -> {bio chem Anc}
T2 -> {bio sed Anc pass chem}
Anc -> {Hyd WA}
chem -> {owc}
chem -> PFAS [label = 'Tier 2']
sed -> {owc PAH}
pass -> PAH
bio -> {Met Tr} [label = 'Tier 1']
bio -> {Att} [label = 'Tier 2']
{owc Att Met Tr Hyd WA PAH PFAS} -> Syn
{owc PAH PFAS} -> Tx
Tx -> Syn
}
")
example flow chart

How to get r to read 'date taken' of a JPG file

I could use some help performing a database correction, in regards to date and time of pictures were taken.
Essentially, the research we perform entails taking many pictures and entering the picture information into a database (we automated this with Microsoft Access). However, I performed a random check of our database and found that several dates and times of the photos were incorrect, and I am attempting to correct this via R as I was unable to correct it via Access.
What I need to do is to is write a script that reads these data, and compiles a list of the date taken information for all photos (there are several thousand). So far the best thing that I've found is
file.info(list.files(
"E:/Whatcom Creek Project/Data/Seal photos/Discovery/Catalog/Phoca vitulina",
recursive = T))
However this returns a list of NA NA for all information. Also, if I manually select one image to run file.info on, it doesn't return date taken (see the picture for the data I am attempting to retrieve)
If anyone has any suggestions I am all ears. Thanks in advance!!
-Ian
enter image description here
maybe still of any use?
i saw this message. I solved this a long time ago (2011) with a very basic VB6 code. The job is still working, but it is not applicable to all '.jpg files'. It depends with what camera the picture has been taken, but mostly pictures taken from a smartphone and classic camera's are returning the date the picture has been taken (not usable for whatsapp images or edited images).
The code is here below, and it is very basic code (but i hope it still can help or give idea's, and ... any new idea's are welcome too) :
'Reading of "Date Picture Taken" from .jpg file
'-----------------------------------------------
Debug.Print ">>>>>==== Start Read of .jpg-file ===== "; Date; " ===== "; Time; " ====<<<<<"
X = 0
DatePictureTaken = ""
TimePictureTaken = ""
FOUNDdatum = False
SWdatum = False
TELdatum = 0
Foto = FOLDER & "\" & tabFileName(FotoNr)
Open Foto For Binary Access Read As #1
'get startposition of the field "date picture taken"
Do
X = X + 1
Get #1, X, MyByte ': Debug.Print Chr(MyByte);
DoEvents
If Chr(MyByte) = ":" Then
'Debug.Print
SWdatum = True
Get #1, X + 3, MyByte
'Debug.Print "x+03="; Chr(MyByte)
If Chr(MyByte) <> ":" Then SWdatum = False 'Debug.Print "x+03="; Chr(MyByte)
Get #1, X + 9, MyByte
'Debug.Print "x+09="; Chr(MyByte)
If Chr(MyByte) <> ":" Then SWdatum = False 'Debug.Print "x+09="; Chr(MyByte)
Get #1, X + 12, MyByte
'Debug.Print "x+12="; Chr(MyByte)
If Chr(MyByte) <> ":" Then SWdatum = False 'Debug.Print "x+12="; Chr(MyByte)
'if a ':' is on the 3 locations (found above) then it is a date!
If SWdatum _
Then
TELdatum = TELdatum + 1
End If
'the 3e date is the date the picture has been taken
If TELdatum = 3 _
Then
FOUNDdatum = True
X = X - 4
Exit Do
End If
X = X + 12
End If
Loop Until EOF(1) 'Or X = 32765
If FOUNDdatum = False Then Close 1: End
BPdatum = X
EPdatum = X + 9
BPuur = X + 11
EPuur = X + 15
For X = BPdatum To EPdatum
Get #1, X, MyByte
'Debug.Print Chr(MyByte)
If Chr(MyByte) <> ":" _
Then
' DatePictureTaken = DatePictureTaken & "/"
'Else
DatePictureTaken = DatePictureTaken & Chr(MyByte)
End If
Next X
For X = BPuur To EPuur
Get #1, X, MyByte
'Debug.Print Chr(MyByte)
If Chr(MyByte) <> ":" _
Then
' DatePictureTaken = DatePictureTaken & "/"
'Else
TimePictureTaken = TimePictureTaken & Chr(MyByte)
End If
Next X
'Debug.Print "Date Picture Taken = "; DATUM
tbxDatum.Text = DatePictureTaken
tbxUur.Text = TimePictureTaken
Close 1
End Sub

Generating complete SKUs in Classic ASP

Hi I have products that are made up of a couple of options. Each Option has a SKU Code. You can only select one option from each SKU Group and the options have to be concatenated in the order of the SKUGroup.
So for example i would have a list of options in a table in the DB that looked like
OptID PID SKU Price SKUGroup
156727 93941 C 171.00 1
156728 93941 BN 171.00 1
156729 93941 PN 171.00 1
156718 93940 W 115.20 2
156719 93940 CA 115.20 2
156720 93940 BA 115.20 2
156721 93940 BNA 115.20 2
156722 93940 BN 115.20 2
156723 93940 BS 115.20 2
156716 93939 CHR 121.50 3
156717 93939 NK 138.00 3
And a few finished product SKUs would look something like:
C-W-CHR 407.70
C-W-NK 424.20
C-CA-CHR 407.20
C-CA-NK 424.20
I am trying to make a script that will create a listing of every possible combination of SKU and the price of the combined options.
I need this done in Classic ASP (vbscript) and I'm not that familiar with it. So I'm looking for all the help I can get.
Thanks!
I would start by connecting to the database and creating three recordsets.
Set connection = CreateObject("ADODB.Connection")
connection.Open ConnectionString
Set rsOption1 = CreateObject("ADODB.recordset")
Set rsOption2 = CreateObject("ADODB.recordset")
Set rsOption3 = CreateObject("ADODB.recordset")
rsOption1.Open "SELECT * FROM TableName WHERE SKUGroup = 1", connection, 3,3
rsOption2.Open "SELECT * FROM TableName WHERE SKUGroup = 2", connection, 3,3
rsOption3.Open "SELECT * FROM TableName WHERE SKUGroup = 3", connection, 3,3
Then you can use nested loops to get the combinations. Something like this (Untested, this probably will not work as is, but it gives you an idea of how to do this) (Also this assumes that you have to select at least one option from each group)
for i = 0 to rsOption1.RecordCount
rsOption1.Move i, 1
for j = 0 to rsOption2.RecordCount
rsOption2.Move j, 1
for k = 0 to rsOption3.RecordCount
rsOption3.Move k, 1
'Write rsOption1.Fields(2).Value & "-" & rsOption2.Fields(2).Value & _
'"-" & rsOption3.Fields(2).Value & " " & _
'FormatCurrency((rsOption1.Fields(3).Value + rsOption2.Fields(3).Value + rsOption3.Fields(3).Value))
Next
Next
Next

Resources