cmd-Terminal menu: How to iterate a number of spaces given in a variable into another variable?
Posted: 06 Jun 2023 06:30
Hello together,
I am working on a new updating-menu in cmd-Terminal and don't know how to get my blocks "installed version", "server version" and "update-suggestion" into a semi-variable position on screen, so that it is screen-printed like it would be set in tabbed-fixed columns. The length of the version numbers differs, so it needs to be variable. Here is a preview how it should look alike (just as example, not in the right dimensions):
All programs, different versions and the status of the "update?" are determined and set into variables before the menu opens. It's a CHOICE-menu.
My idea is the following:
Fix are only the total amount of possible characters in the inner menu (possible characters within the *) and the total lenght of the desired "columns". Lets say the first column is 4 characters long (no), the second column (program) to the last column (update?) all have a size of 30 characters. --> 4 columns * 30 characters = 120 characters + 4 characters ("no" column) = 124 characters + 4 characters ("* "-preceeding sequence and " *"-trailing sequence) = 128 characters in total (and 124 to use).
So firstly I need to check the "length in characters" of the variables "program1", "vers_inst1", "vers_serv1" and "update_flag1". Then I need to calculate the "fixed total lengh of one column" = 30 characters minus "length in characters" of one variable and write it into a new variable. Until here I'll be able to get it working.
In the second step I need to itarate the result (30 characters minus "length in characters") as space-characters into another variable. How can I do this?
When the result is 16 I need to set a new variable holding exact 16 space-characters.
In the end the menu-line looks like: * 1. %program1%%space1prog1%%vers_inst1%%space2prog1%%vers_serv1%%space3prog1%%update_flag1%%space4prog1% *
Any ideas how to manage it or is there a more comfortable way to archieve the same result?
I am working on a new updating-menu in cmd-Terminal and don't know how to get my blocks "installed version", "server version" and "update-suggestion" into a semi-variable position on screen, so that it is screen-printed like it would be set in tabbed-fixed columns. The length of the version numbers differs, so it needs to be variable. Here is a preview how it should look alike (just as example, not in the right dimensions):
Code: Select all
***************************************************************************************************************************
* no program installed version server version update? *
***************************************************************************************************************************
* *
* 1. GitforWin Portable xxx.xxx.xxx_pre-windows.1 yyy.yyy.yyy X *
* 2. Program B x.xxx.x y.yyy.y-prewiev1 X *
* 3. Program C x.xx x.xx - *
* 4. Program D xx.xxx.xxx ERROR *
* ... *
* *
***************************************************************************************************************************
My idea is the following:
Fix are only the total amount of possible characters in the inner menu (possible characters within the *) and the total lenght of the desired "columns". Lets say the first column is 4 characters long (no), the second column (program) to the last column (update?) all have a size of 30 characters. --> 4 columns * 30 characters = 120 characters + 4 characters ("no" column) = 124 characters + 4 characters ("* "-preceeding sequence and " *"-trailing sequence) = 128 characters in total (and 124 to use).
So firstly I need to check the "length in characters" of the variables "program1", "vers_inst1", "vers_serv1" and "update_flag1". Then I need to calculate the "fixed total lengh of one column" = 30 characters minus "length in characters" of one variable and write it into a new variable. Until here I'll be able to get it working.
In the second step I need to itarate the result (30 characters minus "length in characters") as space-characters into another variable. How can I do this?
When the result is 16 I need to set a new variable holding exact 16 space-characters.
In the end the menu-line looks like: * 1. %program1%%space1prog1%%vers_inst1%%space2prog1%%vers_serv1%%space3prog1%%update_flag1%%space4prog1% *
Any ideas how to manage it or is there a more comfortable way to archieve the same result?