Foreach data string holding

Hello master, Im here again with another question.

I do want to write all ppp secret details txt file format, The problem is, when i run my code, it only register one name , what could be wrong?

:local filedata ""

:foreach i in=[/ppp secret find] do={
  :local name [/ppp secret get $i name]
  :local password [/ppp secret get $i password]
  :set  $filedata ("$name:$password\n")
}
/file print file="ppp-secrets.txt"
:delay 2
/file set "ppp-secrets.txt" content=$filedata

You do not keep previous values…

set is… set, not “add at the end”
set x a
set x b
set x c
and at the end x is only c, not “abc”

Please write code correctly, no $ on variable name after global, local or set

:local filedata ""
/ppp secret
:foreach i in=[find] do={
  :local name     [get $i name]
  :local password [get $i password]
  :set filedata "$filedata$name:$password\r\n"
}
/file print file="ppp-secrets.txt"
:delay 2s
/file set "ppp-secrets.txt" content=$filedata

Thankyou for the reply sir, but the problem sir still insist, it does not work :frowning: . i also tried in telegram, but still i got no reply
here’s my code

#telegram
    :local botToken "XXXXXXXXX:XXXXXXX"
    :local chatID "-XXXXXXX"

:local filedata ""
/ppp secret
:foreach i in=[find] do={

  :local name     [get $i name]
  :local password [get $i password]
  :set filedata "$filedata$name:$password\r\n"
}

/tool fetch url="https://api.telegram.org/bot$botToken/sendMessage?chat_id=$chatID&text=test $filedata"

The script on post #2 for me works, but how many items are?
The file created on this way can not exceed ~4000 Bytes…


On terminal, THIS work? (do not omit parenthesys { })

{
:local filedata ""
/ppp secret
:foreach i in=[find] do={
  :local name     [get $i name]
  :local password [get $i password]
  :set filedata "$filedata$name:$password\r\n"
}
:put $filedata
}

You can not send the data directly to telegram if you do not convert it to UTF-8 + URLencode…
And probably GET on fetch can not support more than 256 characters (not tested)

Thank you sir, It works now, but the problem the limit of the data must only 4000bytes as you said, anyway, thankyou so much!!!

If are not soo much, consider this… remove unused start letters on your secrets, or add numbers or symbols you use…

/ppp secret
:foreach l in=[:toarray "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"] do={
    :local filedata ""
    :local letter $l
    :local filename "ppp-secrets-$letter.txt"
    /file print file=$filename
    :delay 2s
    :foreach i in=[find where name~"^$l"] do={
        :local name [get $i name]
        :local password [get $i password]
        :set filedata "$filedata$name:$password\r\n"
    }
    /file set $filename content=$filedata
}

Thankyou again sir. Youre the best!!! :grin::grin::grin: