Sign in to follow this  
Followers 0
Sypher

How to make this code less static

5 posts in this topic

Hi,

I have some code, but it is not dynamic at all! I have tried several things but i couldn't find a easy and good way to do this. I am doing it this way:

_getPoort($extwhose, "FE1")
    $1_des = $extdescr
    $1_typ = $exttype
    _getPoort($extwhose, "FE2")
    $2_des = $extdescr
    $2_typ = $exttype
    _getPoort($extwhose, "FE3")
    $3_des = $extdescr
    $3_typ = $exttype
_getPoort($extwhose, "FE4")
$4_des = $extdescr
$4_typ = $exttype
_getPoort($extwhose, "FE5")
$5_des = $extdescr
$5_typ = $exttype
_getPoort($extwhose, "FE6")
$6_des = $extdescr
$6_typ = $exttype
_getPoort($extwhose, "FE7")
$7_des = $extdescr
$7_typ = $exttype
_getPoort($extwhose, "FE8")
$8_des = $extdescr
$8_typ = $exttype
_getPoort($extwhose, "FE9")
$9_des = $extdescr
$9_typ = $exttype
_getPoort($extwhose, "FE10")
$10_des = $extdescr
$10_typ = $exttype

<Snip>
Dim Const $temports[10][2] = [ ["{FE1}", _buildFE($1_typ, $1_des) ], ["{FE2}", _buildFE($2_typ, $2_des) ], ["{FE3}", _buildFE($3_typ, $3_des) ],["{FE4}", _buildFE($4_typ, $4_des) ],["{FE5}", _buildFE($5_typ, $5_des) ],["{FE6}", _buildFE($6_typ, $6_des) ],["{FE7}", _buildFE($7_typ, $7_des) ],["{FE8}", _buildFE($8_typ, $8_des) ],["{FE9}", _buildFE($9_typ, $9_des) ],["{FE10}", _buildFE($10_typ, $10_des) ] ]

This is a very sloppy way, and i hope someone can help me out in improving this. In the example i use 10 array entries, the final version will use 48 entries.

How can i do this the best way? Arrays?

Share this post


Link to post
Share on other sites



I could really use some input :whistle:

Share this post


Link to post
Share on other sites

I don't get what you try to achieve. Maybe make a simple sample with usage?

And don't forget IniRead and RegRead..:whistle:

Share this post


Link to post
Share on other sites

Untested, but may give you a pointer:

; Dont know what these variables are but you would have to define them first.
Dim $des[10], $typ[10]

; Cant make const as we are adding to it later
Dim $temports[10][2]

; Use loop to get port information and store in array
For $i = 1 To 10
    _getpoort($extwhose, 'FE' & $i)
    $temports[$i,1] = '{FE' & $i & '}'
    $temports[$i,2] = _buildFE($typ[$i], $des[$i])
Next

----[ SandyD ]---

Share this post


Link to post
Share on other sites

Thanks, i'll have a look at it

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0