It is currently Wed Apr 26, 2017 4:26 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: One of mine: mSelect
Unread postPosted: Wed Mar 08, 2017 10:51 am 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 68
Location: France
Extension of Dialog.Select, mSelect function displays a select dialog allowing to choose none, one, or more items.
Menu items are entered in a N-type list as the second parameter.
The N-type list pointed by the first parameter will receive for each item 0 or 1; 1 means selected.
Returned value as a function is 0 or 1; 1 means cancelled.
Code:
FN.DEF mSelect(#marks,#items, title$)
! define check mark
ARRAY.LOAD x$[]," ","√"

! menu installation
LIST.SIZE #items,n
nn=n+1
DIM mn$[nn]
DIM chk[n]
! local dynamic menu
FOR i = 1 to n
  LIST.GET #items,i,w$
  let mn$[i]=" "+w$
NEXT
let mn$[nn]="\t\t\t☞ SUBMIT ☜"

! Selection loop
WHILE 1
  DIALOG.SELECT sel,mn$[], title$

  ! cancelled
  IF !sel then FN.RTN 1

  ! Submitted
  IF sel=nn then W_R.BREAK
  ! Mark/unmark the item
  chk[sel]=!chk[sel]
  let w$=x$ chk[sel]+1] +MID$(mn$[sel],2)
  let mn$[sel]=w$
REPEAT

! passing result
LIST.ADD.ARRAY #marks,chk[]
FN.RTN 0
FN.END

Try mSelect
Code:
LIST.CREATE S,#items
LIST.ADD #items,"a"
LIST.ADD #items,"b"
LIST.ADD #items,"c"
LIST.CREATE N,#marks
Abort=
mSelect(#marks,#items, "Choose none, one or more")

debug.on
Debug.print abort
debug.dump.list #marks


Attachments:
mSelect.zip [1.09 KiB]
Downloaded 6 times

_________________
Alain
Top
 Profile  
 
 Post subject: Indexed dump of an array, anyhow dimensioned.
Unread postPosted: Thu Mar 16, 2017 7:54 pm 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 68
Location: France
Missing in Debug lbrary: two fonctions to print on each line of the dump the indexes followed by the value: prArr(array[]) and prArr$(array$[]).
Code:
! library myDump
! prArr prArr$

!......... command .........

FN.DEF prArr(t[])
ARRAY.COPY t[],v[]
ARRAY.LENGTH lv,v[]
ARRAY.DIMS t[],d[],nd
ARRAY.COPY d[],div[2]
ARRAY.FILL div[nd+1,2],1
d[1]= lv
comma$=","
initag$ = "["
fintag$ = "] "

FOR i= 1 TO lv
  tag$=initag$
  FOR n = 1 TO nd
   k=MOD(INT((i-1)/div[n+1]/div[n+2])+1,d[n])
   IF !k THEN k=d[n]
   k$=USING$("","%,d",INT(k))
   tag$+=k$
   IF n<>nd
    tag$+=comma$
   ELSE
    tag$+=fintag$
   ENDIF
  NEXT
  ? tag$;v[i]
NEXT
FN.END
!! Try prArr
DIM t[3,4,5]
t[1,1,1]=1
t[1,1,2]=2
t[1,1,3]=3
t[1,1,4]=4
t[1,1,5]=5
t[1,2,1]=6
t[1,2,2]=7
t[1,2,3]=8
t[1,2,4]=9
t[1,2,5]=10
t[1,3,1]=11
t[1,3,2]=12
t[1,3,3]=13
t[1,3,4]=14
t[1,3,5]=15
t[1,4,1]=16
t[1,4,2]=17
t[1,4,3]=18
t[1,4,4]=19
t[1,4,5]=20
t[2,1,1]=21
t[2,1,2]=22
t[2,1,3]=23
t[2,1,4]=24
t[2,1,5]=25
t[2,2,1]=26
t[2,2,2]=27
t[2,2,3]=28
t[2,2,4]=29
t[2,2,5]=30
t[2,3,1]=31
t[2,3,2]=32
t[2,3,3]=33
t[2,3,4]=34
t[2,3,5]=35
t[2,4,1]=36
t[2,4,2]=37
t[2,4,3]=38
t[2,4,4]=39
t[2,4,5]=40
t[3,1,1]=41
t[3,1,2]=42
t[3,1,3]=43
t[3,1,4]=44
t[3,1,5]=45
t[3,2,1]=46
t[3,2,2]=47
t[3,2,3]=48
t[3,2,4]=49
t[3,2,5]=50
t[3,3,1]=51
t[3,3,2]=52
t[3,3,3]=53
t[3,3,4]=54
t[3,3,5]=55
t[3,4,1]=56
t[3,4,2]=57
t[3,4,3]=58
t[3,4,4]=59
t[3,4,5]=60
prarr(t[])
END
!!




!......... command ..........
FN.DEF prArr$(t$[])
ARRAY.COPY t$[],v$[]
ARRAY.LENGTH lv,v$[]
ARRAY.DIMS t$[],d[],nd
ARRAY.COPY d[],div[2]
ARRAY.FILL div[nd+1,2],1
d[1] = lv
comma$=","
initag$ = "["
fintag$ = "] "

FOR i= 1 TO lv
  tag$=initag$
  FOR n = 1 TO nd
   k=MOD(INT((i-1)/div[n+1]/div[n+2])+1,d[n])
   IF !k THEN k=d[n]
   k$=USING$("","%,d",int(k))
   tag$+=k$
   IF n<>nd
    tag$+=comma$
   ELSE
    tag$+=fintag$
   ENDIF
  NEXT
  ? tag$;v$[i]
NEXT
FN.END

!! try prArr$
DIM t$[3,4,5]
t$[1,1,1]="1"
t$[1,1,2]="2"
t$[1,1,3]="3"
t$[1,1,4]="4"
t$[1,1,5]="5"
t$[1,2,1]="6"
t$[1,2,2]="7"
t$[1,2,3]="8"
t$[1,2,4]="9"
t$[1,2,5]="10"
t$[1,3,1]="11"
t$[1,3,2]="12"
t$[1,3,3]="13"
t$[1,3,4]="14"
t$[1,3,5]="15"
t$[1,4,1]="16"
t$[1,4,2]="17"
t$[1,4,3]="18"
t$[1,4,4]="19"
t$[1,4,5]="20"
t$[2,1,1]="21"
t$[2,1,2]="22"
t$[2,1,3]="23"
t$[2,1,4]="24"
t$[2,1,5]="25"
t$[2,2,1]="26"
t$[2,2,2]="27"
t$[2,2,3]="28"
t$[2,2,4]="29"
t$[2,2,5]="30"
t$[2,3,1]="31"
t$[2,3,2]="32"
t$[2,3,3]="33"
t$[2,3,4]="34"
t$[2,3,5]="35"
t$[2,4,1]="36"
t$[2,4,2]="37"
t$[2,4,3]="38"
t$[2,4,4]="39"
t$[2,4,5]="40"
t$[3,1,1]="41"
!$[3,1,2]="42"
!$[3,1,3]="43"
t$[3,1,4]="44"
t$[3,1,5]="45"
t$[3,2,1]="46"
t$[3,2,2]="47"
t$[3,2,3]="48"
t$[3,2,4]="49"
t$[3,2,5]="50"
t$[3,3,1]="51"
t$[3,3,2]="52"
t$[3,3,3]="53"
t$[3,3,4]="54"
t$[3,3,5]="55"
t$[3,4,1]="56"
t$[3,4,2]="57"
t$[3,4,3]="58"
t$[3,4,4]="59"
t$[3,4,5]="60"
prArr$(t$[])
END
!!

! Made by Sprougnaf
! 2017-03-17 03:59:35


Attachments:
File comment: With detection of currently debugging on or off, does not run if off.
dump.zip [1.11 KiB]
Downloaded 3 times

_________________
Alain
Top
 Profile  
 
 Post subject: Re: Some functions and tricks
Unread postPosted: Mon Mar 20, 2017 5:29 pm 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 68
Location: France
Fonction formatting a bytes number in terms of Kb, Mb, Gb.

FN.DEF Size$(n)
LET prd$="%,d"
LET prf$="%,.3f"

IF n<1024 THEN FN.RTN USING$("",prd$,INT(n))+"b"

ARRAY.LOAD t$[],"Kb", "Mb","Gb"
FOR i=1 TO 3
n=n/1024
IF n<1024
IF last$(STR$(n))="0" THEN FN.RTN USING$("",prd$,INT(n)) +t$[i]
w$=USING$("",prf$,n)
IF RIGHT$(w$,2)="00"THEN w$=MID$(w$,1,LEN(w$)-2)
IF RIGHT$(w$,1)="0"THEN w$=MID$(w$,1,LEN(w$)-1)
FN.RTN w$+t$[i]
ENDIF
NEXT
FN.END


Attachments:
Size$.zip [928 Bytes]
Downloaded 3 times

_________________
Alain
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3, 4


Who is online

Users browsing this forum: No registered users and 0 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:  
suspicion-preferred