Scripting library for B4ppc

aroom

Member
Licensed User
A program starts with an initial code section at the beginning of the program. All Subs must follow this code section. Execution commences at the first line of the program and ends when AppClose is executed or if the code tries to run off the end of this initial section into the first Sub.

could program run over Sub define part, to the AppClose or file end ? because Sub define in multiple script files, and files to be load one by one.

thanks.
 

agraham

Expert
Licensed User
Longtime User
could program run over Sub define part, to the AppClose or file end ?
No, the structure of the interpreter makes that difficult to implement. However I don't see why you would need to. A script cannot be partially loaded into the interpreter so if you are building a script at runtime you just need to assemble it in the required order.
 

aroom

Member
Licensed User
B4X:
dateformat("yyyy-mm-dd")
date(now)
return: 2010-53-27 (53 > 12, bug)

BTW,
1. could I define Sub name with dot pair like the oriented-object program style?
B4X:
Sub myObject.method(p1, p2)
      ......
End


2. define in Sub (paramList), it is perfect that paramList can use Option parameter! with one or more parameters only need write one Sub routine, the same as the Lisp style.
B4X:
Sub fun(p1, [p2], [p3])
      sum = p1
      if isnumber(p2) = true then
         sum = sum + p2
      end if
      if isnumber(p3) = true then
         sum = sum + p3
      end if
      return sum
End
fun(1) -> 1
fun(1, 2) -> 3
fun(1, 2, 3) -> 6

thanks.
 

agraham

Expert
Licensed User
Longtime User
1) Use dateformat("yyyy-MM-dd")

Sorry, it's a documentation failure rather than a bug. DateFormat and TimeFormat in Basic4ppc and BasicLib use the .NET standard formatting characters Custom DateTime Format Strings so you can use TimeFormat for dates and DateFormat for times if you want. However for DateFormat Basic4ppc converts any "m" to "M" because "m" is minutes and "M" is months. For TimeFormat Basic4ppc changes "M" to "m" for the same reason.

I chose not to do this in BasicLib so DateFormat and TimeFormat are identical but maintain separate formatting strings so you can keep two different date/time formats defined.


2) I'm afraid not.


3) I'm afraid not. However you could get a similar effect by putting the parameters in an global array, pass the name of the array variable as the parameter and use GetLen and GetItem to access the array. Or you could just have the Sub assume which array to use.
 
Top