Jump to content
Macro Express Forums

Question On Use Of 'switch" & 'case'


efc93

Recommended Posts

Hi All,

 

Like all of us here, very appreciative firstly of the ME program and secondly this great forum ! - so many great tips - it is great to have resources available like this to make ALL of our lives easier !

 

My question relates to the 'switch/case' commands - only did a bit of 'C' programming at school, but a lot of VB, am stuck on the best use of the switch / case commands in my scenario :

 

Need to extract data from a text tab delimited file - 15 lines, 5 fields in each. Then need to wash this data through a program, generate a result and come back for 2nd line's data. My problem is how to do this without duplicating. At the moment, am extracting data from ASCII Delimted file and recording all the data, but leaving aside five variables ( T45-T49 ) for 'working' data ie. at the start of each function, copying the next 5 variables to T45-T49, so it can be worked on. My problem is how to do this, without duplicating 15 times, all of the program workings. I have been advise the 'switch / case' set of commands should do this, but am at a loss on how to set it up. As I would need to 'call' a certain group of commands 15 times.

 

Would appreciate any assistance anyone can give - haven't purchased the PGM Functions Library yet, but if this will assist me to complete the above problem, then i will gladly purchase it.

 

Appreciate your help in advance !

 

TG

Link to comment
Share on other sites

Welcome to the group!

 

The Switch / End Switch construct does not loop. It is just a big If / Else / End If tree.

 

The Ascii File Begin Process and Ascii File End Process command construct will loop through records in a delimited file one record at a time. Each delimited field in the current record is placed in its own variable beginning with the variable that you specify, say T45. All of the processing that you want to do to these variables are placed within the loop (i.e. between the Ascii File Begin Process and Ascii File End Process commands). The default setting for the construct is to begin at the first record in the delimited file and process all records.

 

If this does not help, then it might be advantageous to post a sample of the macro(s) you have created for this task.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...