From c2fc14e50b859d80cbbcabc3de39fae3dd7b99a7 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 28 Sep 2017 14:28:38 -0400 Subject: [PATCH] reference main library instead of duplicating code --- FL.bas | 80 ++++++++++++---------------------------------------------- 1 file changed, 16 insertions(+), 64 deletions(-) diff --git a/FL.bas b/FL.bas index 6189ac1..e41864f 100644 --- a/FL.bas +++ b/FL.bas @@ -582,50 +582,15 @@ Sub LoadChan() End Sub - - -Sub markdown_from_selection() +Sub markdown_from_table() - Dim wapi As New Windows_API Dim x As New TheBigOne - + Dim wapi As New Windows_API Dim tbl() As Variant - + tbl = Selection - - Dim msl() As Integer - Dim md As String - Dim r As Integer - Dim c As Integer - - ReDim msl(UBound(tbl, 2)) - - '---determine max string length per column---- - For c = 1 To UBound(tbl, 2) - For r = 1 To UBound(tbl, 1) - If Len(tbl(r, c)) > msl(c) Then msl(c) = Len(tbl(r, c)) - Next r - Next c - - '---build markdown table----------- - For r = 1 To UBound(tbl, 1) - If r = 2 Then - md = md & "|" - For c = 1 To UBound(tbl, 2) - md = md & "---" & String(x.MISCe_MaxInt(msl(c), 3) - 3, "-") & "|" - Next c - md = md & vbCrLf - End If - md = md & "|" - For c = 1 To UBound(tbl, 2) - md = md & tbl(r, c) & String(x.MISCe_MaxInt(3, msl(c) - Len(tbl(r, c))), " ") & "|" - Next c - md = md & vbCrLf - Next r - - - Call wapi.ClipBoard_SetData(md) + Call wapi.ClipBoard_SetData(x.markdown_from_table(tbl)) End Sub @@ -634,30 +599,17 @@ Sub json_multirange() Dim wapi As New Windows_API Dim x As New TheBigOne - Dim r As range - Dim ar As range - Dim r1() As Variant - Dim r2() As Variant - Dim rslt As String - Dim d() As String - Dim i As Integer - Dim dest As String - - Set r = Selection - - i = 1 - For Each ar In r.Areas - - r1 = ar - If i > 1 Then - rslt = rslt & "," & x.json_from_table(r1, CStr(r1(1, 1)), True) - Else - rslt = x.json_from_table(r1, CStr(r1(1, 1)), True) - End If - i = i + 1 - Next ar - rslt = "{" & rslt & "}" + Call wapi.ClipBoard_SetData(x.json_multirange(Selection)) - Call wapi.ClipBoard_SetData(rslt) +End Sub + + +Sub markdown_whole_sheet() + + Dim x As New TheBigOne + Dim wapi As New Windows_API -End Sub \ No newline at end of file + Call wapi.ClipBoard_SetData(x.markdown_whole_sheet(ActiveSheet)) + + +End Sub