Ruby: Why Does Puts Call To_Ary

rails routes and custom routing for nested resource

Using your example, you probably should constrain it. Either using the Edition.all.map(&:slug) array you included or cache it in some way depending on how big the list is. This way it will be limited and wouldn't necessarily need to be at the bottom of the routes file.

resources :editions, path: '', :constraints => proc { |req| ['london', 'other_cities'].include?(req.params[:edition_id]) } do
get 'set_session', on: :member
resources :events
resources :quiz_masters
resources :venues
end

How to Format VBA String Split Output Correctly?

The problem that you are having is one of logic. The first "For" loop will run 6 times, each time overwriting "WrdArray()" so that at the end of the loop it is equal to the final value.

The second "For" loop is pasting this final value into 6 different cells.

To fix this, reorder the code:

Sub Break_String()
Dim WrdArray() As String
Dim text_string As String
Dim intCount As Integer, intCounter As Integer
Dim o As Object

Set o = CreateObject("excel.application")
o.Visible = True
o.Workbooks.Open ("NER FTP UPLOADER.xlsm")


For intCount = 1 To 6

text_string = sheets("mySheet").Cells(intCount, 2)
WrdArray() = Split(text_string, "EQ # : ")
o.Sheets("sheet1").Range("B" & (18 + intCount) & ":F" & (18+intCount)).Value = WrdArray()

Next intCount


End Sub

Notice that you also need to change the cells you are pasting to in the loop, otherwise the data will just overwrite.

Alternatively, you could use an array of arrays:

Sub Break_String()
Dim arArrays() As Variant
Dim WrdArray() As String
Dim text_string As String
Dim intCount As Integer, intCounter As Integer
Dim o As Object

ReDim arArrays(1 To 6)

For intCount = 1 To 6

text_string = sheets("mySheet").Cells(intCount, 2)
WrdArray() = Split(text_string, "EQ # : ")
arArrays(intCount) = WrdArray()

Next intCount

Set o = CreateObject("excel.application")
o.Visible = True
o.Workbooks.Open ("NER FTP UPLOADER.xlsm")

For intCount = 1 To 6

o.Sheets("sheet1").Range("B" & (18 + intCount) & ":F" & (18+intCount)).Value = arArrays(intCount)

Next intCount

End Sub

EDIT*** Fixed error in line assigning values from array to the cell. Needed to add ":" to the range. Also changed "24" to "18" as the results should all be on the same row.

While fixing this, noticed that "Cells(intCount, 2)" was not referencing a worksheet. Updated to reference a worksheet, but the correct worksheet name should be added here, not "mySheet."

EDIT2***

Sub Break_String()
Dim WrdArray() As String
Dim text_string As String
Dim intCount As Integer, intCounter As Integer
Dim o As Object
Dim pasteRow As Integer
Dim i As Integer

pasteRow = 19

Set o = CreateObject("excel.application")
o.Visible = True
o.Workbooks.Open ("NER FTP UPLOADER.xlsm")


For intCount = 1 To 6

text_string = sheets("mySheet").Cells(intCount, 2)
WrdArray() = Split(text_string, "EQ # : ")
For i = LBound(WrdArray) to UBound(WrdArray)
o.Sheets("sheet1").Range("B" & (pasteRow)).Value = WrdArray[i]
pasteRow = pasteRow + 1
Next i
Next intCount


End Sub

This will do as asked in the comments.

How to manually switch between more than 2 signals in Simulink

One way to approach this would be to use a Multiport Switch.
This allows you to switch between several outputs based on the value of the first input (which you can tie to a constant block).

This way, when you start a simulation, you can choose the desired input by changing the value of the constant block in your model.

Mathworks Multiport Switch Help



Related Topics



Leave a reply



Submit