[Gambas-user] COBOL and how great it was!

gian bagoneo at libero.it
Sat Nov 19 13:55:41 CET 2022


Il 19/11/22 04:44, BB ha scritto:
> 
> On 19/11/22 1:41 pm, Jussi Lahtinen wrote:
>> Looks good!
>> You just need an additional argument for the alignment (perhaps by 
>> changing integer[] to string[] or variant[]), if you want to add it, 
>> or you will narrow the function's use cases.
>>
>> Jussi
>>
> I'm actually thinking now of using a negative position to right align 
> the item. Decimal point alignment is probably too hard ATM as it would 
> need to know too much about stuff.
> 
> b
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

Hi,

my penny (do they say that?), you need to check gb.util

'-------------------------------------------------------
Public Sub Main()

   Dim aRight As Boolean[] = [True, True, False, False]
   Dim aSpace As Integer[] = [6, 30, 10, 15]
   Dim aField1 As String[] = ["312", "Mary K Jones", Format(350, 
"$,#.00"), "0423-614-012"]
   Dim aField2 As String[] = ["472", "Jim Bo", Format(75.5, "$,#.00"), 
"0416-763-274"]
   Dim aField3 As String[] = ["666", "The Devil Incarnate Himself", 
Format(9999.99, "$,#.00"), "0413-100-200"]
   Dim aField4 As String[] = ["2", "Bozo Dog", Format(1.23, "$,#.00"), 
"0413-627-123"]

   PrintVarPad(aRight, aSpace, aField1)
   PrintVarPad(aRight, aSpace, aField2)
   PrintVarPad(aRight, aSpace, aField3)
   PrintVarPad(aRight, aSpace, aField4)

End

Private Sub PrintVarPad(aRight As Boolean[], aSpace As Integer[], aField 
As String[])

   For i As Integer = 0 To aField.Max
     If aRight[i] = True Then
       Print String.PadRight(aField[i], aSpace[i]);
     Else
       Print String.PadLeft(aField[i], aSpace[i]);
     Endif
   Next
   Print

End
'---------------------------------------

Regards

Gianluigi


More information about the User mailing list