SOFiSTiK Forum

It is currently Tue Nov 19, 2019 1:11 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Text Loop
PostPosted: Tue Apr 18, 2017 3:50 pm 
Offline

Joined: Fri May 20, 2016 6:34 pm
Posts: 6
Hallo,

Is it possible to combine text with Variable number (Like "Concatenate" function in excel) ?


For example:
I would like to make a loop to include different text files in Teddy.
So First I defined the location of the folder containing the files "In"
Second I want to make a loop to get all different files in this folder.
( I have Generated all this file with the same name but in the end variable number, e.g. Input1, Input2, Input3,....etc)


$Input Location
#define In=D:\Work\Sim\Input\

$Combine different text In+Input1+.dat
#include $(In)Input1.dat
#include $(In)Input2.dat
#include $(In)Input2.dat
.
.
.

My question is would it be possible to make a loop to change the last number?

Loop#i 10000
#include $(In)Input(#i).dat
Endloop

But this is not working it's only writing #i not the variable 1,2,3,.....


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 7:23 am 
Offline

Joined: Tue Mar 30, 2010 5:40 pm
Posts: 180
It seems to work without the brackets.
Code:
+prog template
#define In=D:\Work\Sim\Input\
let#a 1,2,3  ;    txa - $(In)Input1.dat
loop#1 a
                  txa * $(In)Input#(a+#1).dat     This way won't work.
 let#tt #(a+#1);  txa + $(In)Input#tt.dat         This way works.
endloop
ende


The result is:
Code:
      - D:\Work\Sim\Input\Input1.dat
      * D:\Work\Sim\Input\Input(a+#1).dat     This way wont work.
      + D:\Work\Sim\Input\Input1.dat         This way works.
      * D:\Work\Sim\Input\Input(a+#1).dat     This way wont work.
      + D:\Work\Sim\Input\Input2.dat         This way works.
      * D:\Work\Sim\Input\Input(a+#1).dat     This way wont work.
      + D:\Work\Sim\Input\Input3.dat         This way works.


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 8:00 am 
Offline

Joined: Fri May 20, 2016 6:34 pm
Posts: 6
ragl Thank your for your reply.
But my problem when i use incude it doesn't work?!

And for printing the text it also work with the brackets try this:

Code:
-Prog template urs:6
Head
$Input Location
STO#NO (1 5 1)
#define In=D:\Work\
Loop#i 5
txe  $(In)MCM_Input#(#NO(#i)).dat
ENDLoop
END


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 10:56 am 
Offline

Joined: Tue Mar 30, 2010 5:40 pm
Posts: 180
In my view #include as a loop-instruction can't work.
A #include-section will only one-time calculated / or rather applied in wps, at the moment of the precompile-time.
A loop in a prog-section will be calculated after the precompiling.
This is visible, when you force while the runtime a wps-break (or make a long-standing calculation) and search for the temporary inputfiles (match "filename.#??") in your working directory.

[One possibilty may be a loop over many "prog" (look for "http://www.sofistik.com/forum/viewtopic.php?f=3&t=6369&hilit=Schleife+prog" or "http://www.sofistik.com/forum/viewtopic.php?f=3&t=2852&hilit=+prog+ase+ITER+30+Iteration+%C3%BCber+PROG").]


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 12:01 pm 
Offline

Joined: Fri May 20, 2016 6:34 pm
Posts: 6
I couldn't fully understand what you said. In this case its would be easier for me to write a macro in excel and generate this data then copy paste it in teddy.
Thanks agian for the help.


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 2:06 pm 
Offline

Joined: Tue Mar 30, 2010 5:40 pm
Posts: 180
The description was not so good, the better word is preprocessor (instead precompiler), here from Wikipedia:
"In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and macro expansions, while others have the power of full-fledged programming languages."

#include-terms will be replaced (static) by the Sofistik-preprocessor before the further calculation begins.
If the content (and the name) of the #include-files are static at begin of the runtime, then you can bind all the files (a list of files, when is necessary). If not static, then it isn't possible in this way.


Top
 Profile  
 
 Post subject: Re: Text Loop
PostPosted: Wed Apr 19, 2017 2:47 pm 
Offline

Joined: Fri May 20, 2016 6:34 pm
Posts: 6
Thank you for the elobration. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group