vb.net need help figuring out this logic in code - vb.net

i made a app the connects to facebook and pulls off a group of links leading to each post on a group page and i want to check each link ever 30 seconds to see of the link has changed position in the array which would ether mean a new post has been posted or a new post has been pinned or a post has been updated. i have some psudo code of what i think i need to make but i need help figuring out how to do the logic at the bottom were it checks if the data of the array has changed then check if it just moved down one spot in the array
set var1 = "void1"
set var2 = "void2"
set var3 = "void3"
set array = ("Data1","Data2","Data3")
check if var1 = array(0) // "void1" = "Data1" = new_data
check if var2 = array(1) // "void2" = "Data2" = new_data
check if var3 = array(2) // "void3" = "Data3" = new_data
set var1 = array(0) // "Data1"
set var2 = array(1) // "data2"
set var3 = array(2) // "data3"
check if var1 = array(0) // "Data1" = "Data1" = old_data
check if var2 = array(1) // "Data2" = "Data2" = old_data
check if var3 = array(2) // "Data3" = "Data3" = old_data
array = ("Data0","Data1","Data2")
set var1 = array(0) // "Data0"
set var2 = array(1) // "data1"
set var3 = array(2) // "data2"
check if var1 = array(0) // "Data1" = "Data0" = new_data
check if var2 = array(1) // "Data2" = "Data1" = new_data does array(1) = var1 "Data1" = "Data1" change to old_data
check if var3 = array(2) // "Data3" = "Data2" = new_data does array(2) = var2 "Data2" = "Data2" change to old_data

If I understand you correctly, what you'll need to do is, per iteration, have an original list of links, then a new one, which you'll compare on an item to item basis (though we need to know whether new links will go to the beginning of the list when you grab them). If the items are not the same, update the 'initial' list with the new list's contents. Some pseudo-code:
InitialList = grabLinks()
Every 30 seconds:
NewList = grabLinks()
If Not InitialList(0) = NewList(0) Then
InitialList = NewList
End If
You will probably need to use a built-in timing function for polling every thirty seconds.

Related

Force single line of string in VObject

I am trying to create vCards (Email contacts) unsing the vobject library and pandas for python.
When serializing the values I get new lines in the "notes" of my output(no new lines in source). In every new line, created by ".serialize()", there is also a space in the beginning. I would need to get rid of both.
Example of output:
BEGIN:VCARD
VERSION:3.0
EMAIL;TYPE=INTERNET:test#example.at
FN:Valentina test
N:Valentina;test;;;
NOTE:PelletiererIn Mitglieder 2 Preiserhebung Aussendung 2 Pressespiegelver
sand 2 GeschäftsführerIn PPA_PelletiererInnen GeschäftsführerIn_Pellet
iererIn
ORG:Test Company
TEL;TYPE=CELL:
TEL;TYPE=CELL:
TEL;TYPE=CELL:
END:VCARD
Is there a way that I can force the output in a single line?
output = ""
for _,row in df.iterrows():
j = vobject.vCard()
j.add('n')
j.n.value = vobject.vcard.Name(row["First Name"],row["Last Name"])
j.add('fn')
j.fn.value = (str(row["First Name"]) + " " + row["Last Name"])
o = j.add("email")
o.value = str((row["E-mail Address"]))
o.type_param = "INTERNET"
#o = j.add("email")
#o.value = str((row["E-mail 2 Address"]))
#o.type_param = "INTERNET"
j.add('org')
j.org.value = [row["Organization"]]
k = j.add("tel")
k.value = str(row["Home Phone"])
k.type_param = "CELL"
k = j.add("tel")
k.value = str(row["Business Phone"])
k.type_param = "CELL"
k = j.add("tel")
k.value = str(row["Mobile Phone"])
k.type_param = "CELL"
j.add("note")
j.note.value = row["Notiz für Kontaktexport"]
output += j.serialize()
print(output)

Status Bar in for loop

I was trying to create a status bar in my for loop, but the status remains at 0%. I'm not sure what the issue could be.
n <- length(unique(mu_ut$AnimalID))
pb <- txtProgressBar(min = 0, max = n, style = 3)
for(i in unique(mu_ut$AnimalID)){
AnID <- paste("AnID", i, sep = ".")
assign(AnID, mu_ut[mu_ut$AnimalID == i,])
dbWriteTable(conn = db, name = AnID, value = mu_ut[mu_ut$AnimalID == i,],
field.types = c(DateAndTime = "DATETIME",
AnimalID = "CHAR",
Species = "CHAR",
Sex = "CHAR",
CurrentCohort = "CHAR",
BirthYear = "DATE",
CaptureUnit = "CHAR",
CaptureSubunit = "CHAR",
CaptureArea = "CHAR"), overwrite = TRUE)
Sys.sleep(1)
setTxtProgressBar(pb, i)
}
Is it a problem with the "i" argument in the setTxtProgressBar function?
Thank you in advance.
The issue is that setTxtProgressBar needs its value to be in the sequence min=0 to max=n, as set in your txtProgressBar. Since i is really one of the unique values within mu_ut$AnimalID, even if it is an integer, it is not clear that it is also in the range 0:n.
Try this.
ids <- unique(mu_ut$AnimalID)
pb <- txtProgressBar(min = 0, max = length(ids), style = 3)
for (ind in seq_along(ids)) {
id <- ids[ind]
AnID <- paste("AnID", id, sep = ".")
assign(AnID, mu_ut[mu_ut$AnimalID == id,])
dbWriteTable(conn = db, name = AnID, value = mu_ut[mu_ut$AnimalID == id,],
field.types = c(DateAndTime = "DATETIME",
AnimalID = "CHAR",
Species = "CHAR",
Sex = "CHAR",
CurrentCohort = "CHAR",
BirthYear = "DATE",
CaptureUnit = "CHAR",
CaptureSubunit = "CHAR",
CaptureArea = "CHAR"), overwrite = TRUE)
Sys.sleep(1)
setTxtProgressBar(pb, ind)
}
(This is very similar to #CareyCaginalp's comment.)

How to assign notification to work order through BAPI?

I would like to assign a notification to a work order. The following does not work:
* Fill method structure
ls_methods-refnumber = 1.
ls_methods-method = 'SAVE'.
APPEND ls_methods TO lt_methods.
ls_methods-refnumber = 1.
ls_methods-objecttype = 'OBJECTLIST'.
ls_methods-method = 'CHANGE'.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
ls_methods-refnumber = 1.
ls_methods-objecttype = 'HEADER'.
ls_methods-method = 'CHANGE'.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
* Fill header structure
ls_header-orderid = '000480000020'.
ls_header-notif_no = '100000356980'.
APPEND ls_header TO lt_header.
* Fill header up structure
ls_header_up-orderid = '000480000020'.
ls_header_up-notif_no = '100000356980' .
APPEND ls_header_up TO lt_header_up.
* Fill object list structure
ls_object_list-notif_no = '100000356980'.
APPEND ls_object_list TO lt_object_list.
* Fill object list up structure
ls_object_list_up-processing_ind = 'X'.
APPEND ls_object_list_up TO lt_object_list_up.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
it_objectlist = lt_object_list
it_objectlist_up = lt_object_list_up
return = lt_return .
For OBJECTLIST I would actually need something like an 'ADD' method. Any ideas are appreciated.
The following works for me:
ls_methods-refnumber = 1.
ls_methods-objecttype = 'OBJECTLIST'.
ls_methods-method = 'CREATE'.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
* Fill method structure
ls_methods-refnumber = 1.
ls_methods-method = 'SAVE'.
ls_methods-objecttype = ''.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
* Fill object list structure
ls_object_list-notif_no = '100000356980'.
APPEND ls_object_list TO lt_object_list.
* Fill object list up structure
ls_object_list_up-processing_ind = 'X'.
APPEND ls_object_list_up TO lt_object_list_up.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_objectlist = lt_object_list
it_objectlist_up = lt_object_list_up
return = lt_return.

How to change string value label

Suppose I have a string variable that takes on several string values:
gen rand = runiform()
sort rand
gen var1 = ""
replace var1 = "A" if rand < .3
replace var1 = "B" if rand>=.3 & rand < .7
replace var1 = "C" if var1==""
How would I change the values of var1? For example, A to be Aaa, B to be Bbb, and C to be Ccc?
I want to do something like the following (but rather replace the variables), which I know is incorrect:
label define var1L "A" "Aa" B "Bbb" C "Ccc"
label values var1 var1L
String variables can't have value labels. You can interpret this as if labels for string variables are meant to be the content of the variable itself. But you can replace:
clear
set more off
input ///
str1 var1
A
B
C
end
list
replace var1 = "Aaa" if var1 == "A"
replace var1 = "Bbb" if var1 == "B"
replace var1 = "Ccc" if var1 == "C"
list
You need to say more about your data and objectives for a more useful answer.

How to increment a variable name by 1 in Lua, and then set that as the variable name?

My current code is:
obj1 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
obj2 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
obj3 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
And so on. Since they are all the same thing, I'd like to be able to generate a variable that I can increment the name by one, and then use a for loop to create a lot of them. Is there a way I can do that in Lua? Thanks!
You can use a table to hold the objects and add them using a for loop.
local objects = {}
--> This will create 20 objects
for i=1, 20 do
objects[i] = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
end