Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Restart in a Loop
Hi guys,

i guess i am thinking too complicated... Please help me out... 
This is part of a macro where i am working with a csv.
In the relevant part here I am looking for a specific Text ("kartenzahlungen" = german for card payment) and if this text matches then i run in this for-loop a rep depending on how many different card types are used (MasterCard, VisaCard, and so on). If there are more than i card type than i have to split the amount of "kartenbetrag" onto these cards, therefore i create new rows. That all works.
But if do something wrong, let's say a typo in this input:

inp- kartenBetrag F"Sum of {workingOn}. Card Payment on {csvPullDate}?" "Sum of Card Payment" Restbetrag

I wanna "restart" this `rep anzahlKartenzahlungen`.

How can i restart then without throwing all the work i did before away and do only this part again?

Many thanks and a happy new year to you all!


Macro CSVWorker
Copy      Help
;Here we go...
i = 0
int anzahlKartenzahlungen newRow 
int workingOn
str activateKartenzahlungen csvPullDate kartenBetrag
double dblkartenBetragkonvert RestBetrag

inp- activateKartenzahlungen  F" {kartenzahlungsCounter} Days found with card payments. Do it?" "Card Payments" "Nope"
if activateKartenzahlungen != "Nö"
,OnScreenDisplay "Kartenzahlungen verarbeiten..." -1 0 -1 "Arial" 0 0x00000f 1|8 "csvworker" 0x00ffff
,for i 0 x.RowCount
,,csvToStringConverter.from(x.Cell(i 1))
,,if csvToStringConverter = "kartenzahlung"
,,,workingOn = 0
,,,csvPullDate = x.Cell(i 0)
,,,kartenBetrag = x.Cell(i 4)
,,,RestBetrag = val(kartenBetrag 2) ;; total amount out of rep
,,,inp- anzahlKartenzahlungen F"How much different cards? {csvPullDate} - total: {kartenBetrag}?" "Anzahl angeben"
,,,rep anzahlKartenzahlungen
,,,,workingOn = workingOn + 1
,,,,if(anzahlKartenzahlungen > 1)
,,,,,inp- kartenBetrag F"Sum of {workingOn}. Card Payment on {csvPullDate}?" "Sum of Card Payment" RestBetrag
,,,,if workingOn > 1
,,,,,newRow=x.AddRowMS(-1);; if at least two different cards, create new row
,,,,,newRow = i;; else overwrite only current row
,,,,dblkartenBetragkonvert = val(kartenBetrag 2)
,,,,RestBetrag = RestBetrag - dblkartenBetragkonvert
,,,,x.Cell(newRow 0)= csvPullDate
,,,,x.Cell(newRow 3)= "160000"
,,,,x.Cell(newRow 4)= kartenBetrag
,,,,x.Cell(newRow 5)= "H"
,,,,sel(ListDialog("1 Visa-Card[]2 MasterCard[]&3 EC-Karte[]4 Rechnung"))
,,,,,case 1
,,,,,x.Cell(newRow 1) = "Visa-Card"
,,,,,x.Cell(newRow 2) = "363010"
,,,,,case 2
,,,,,x.Cell(newRow 1) = "MasterCard"
,,,,,x.Cell(newRow 2) = "363010"
,,,,,case 3
,,,,,x.Cell(newRow 1) = "EC-Karte"
,,,,,x.Cell(newRow 2) = "363011"
,,,,,case 4
,,,,,x.Cell(newRow 1) = "Auf Rechnung"
,,,,,x.Cell(newRow 2) = "363012"
,,,,,case else ret
,,,,,out "No valid Cards provided"
The script can detect the wrong thing and then use continue.

Macro Macro3178
Copy      Help
int k
rep 5
,inp- k
,if k<0
,,mes "wrong"
,out k

Forum Jump:

Users browsing this thread: 1 Guest(s)