Pop-Up Thingie

BAJA Programming 101.2

From PistolGrip@VERT to All on Sun Oct 21 14:59:00 2001

############################################################################### ### PistolGrip's BAJA Examples (Version 2) ############################################################################### ###
### This version expands a little on the last, and includes a very crude
### implementation of a WALL or One-Liner module. This example is primarily ### designed to show an example of both string-based and binary File I/O.
### ############################################################################### ### Note: This file is an example only, it is by no means supposed to work or ### or do anything other than hopefully help some people get started
### with BAJA programming. This code is not tested or thought-out very ### well, it is only intended to show some basic concepts and common
### tasks useful when coding custom modules. I'm sure there is easier ### and better ways to do some of this with with BAJA, but again, this ### code has just been 'thrown-together' to try to show some ideas.
###
### THIS CODE MAY OR MAY NOT COMPILE WITHOUT ERRORS!
### ############################################################################### ### Required Include Files for SBBS Definitions, and our File I/O Functions ############################################################################### !include sbbsdefs.inc
!include file_io.inc ############################################################################### ### Defines Global or Constant Variables ############################################################################### !define USER _USERON.ALIAS
!define USER_NUM _USERON.NUMBER
!define MAX_ENTRY_LENGTH 100
!define WALL_VERSION "1.0" ############################################################################### ### Define our Integer variables ############################################################################### int cfg_file
int dat_file
int access_lvl
int user_number

############################################################################### ### Two things to notice about this next section:
### 1.) When using Synchronet Command Line Specifiers (ie. "%n") with the
### BAJA sprintf command, you must use two (2) percent signs (%). Refer ### to the BAJA docs for more information on using the sprintf function ### and certain characters.
### 2.) The double forward slashes "/" in the path. When you specify paths
### within a sprintf statement you must use two (2) slashes, either forward ### (/) or backward (\). We use the "/" to ensure Linux compatibility.
### Refer to the BAJA docs for more information on using the sprintf
### function and certain characters.
###

############################################################################### ### Now we'll read our config file one line at a time and set the appropriate ### variables to the correct values for our CONFIG. ############################################################################### fread_line cfg_file sysop
truncsp sysop

############################################################################### ###
### Note: On this next line read-in, we read in a string value and then
### convert it to an integer when we use the copy command.
###

############################################################################### ### Note: You can use this technique to fairly easily create complex
### configuration and customization options of your programs. ###############################################################################

############################################################################### ### Here's were we will see what argurments were passed to module upon exec. ############################################################################### compare cmd_line "DISPLAY"
if_true
goto display_mode
end_if

############################################################################### ### This next sections checks for existence of menu file and then decides if ### we should display it or the internal menu ############################################################################### sprintf str "%%n..//baja//wall//menu.*"
chkfile "%s" ### Note: Here the "%s" is translated into str as sprintf'd
### above for the chkfile function.

############################################################################
### This is the beginning of the loop we use to read in our data from file
############################################################################
:wall_read_loop_view
feof dat_file
if_true
fclose dat_file
print "\r\n-------------------------------\r\n"
pause
return
end_if

### Fall-through
print "\r\nERROR: Fall through to the end of the Main Section of Module" cmd_pop
return ############################################################################### ##### End Main Program Section ###############################################################################

############################################################################### ############################################################################### ### This is where we go if called with the DISPLAY parameter ############################################################################### :display_mode
cls
printf "EZWALL v%s" WALL_VERSION
print "\r\n-------------------------------"

############################################################################
### This is the beginning of the loop we use to read in our data from file
############################################################################
:wall_read_loop_display
feof dat_file
if_true
fclose dat_file
print "\r\n-------------------------------\r\n"
pause
return
end_if

############################################################################ ### Two things to notice about this next section:
### 1.) When using Synchronet Command Line Specifiers (ie. "%n") with the ### BAJA sprintf command, you must use two (2) percent signs (%). Refe ### to the BAJA docs for more information on using the sprintf function ### and certain characters.
### 2.) The double forward slashes "/" in the path. When you specify paths ### within a sprintf statement you must use two (2) slashes, either forw

Are you sure about this double forward-slash thing? You have to use double-backslash to represent a single backslash character (because the C programming language uses backslash a special 'escape' character - e.g. '\r' indicates carriage return), but the same is not true of the forward slash character.

### 2.) The double forward slashes "/" in the path. When you specify p

at

### within a sprintf statement you must use two (2) slashes, either f

Are you sure about this double forward-slash thing? You have to use double-backslash to represent a single backslash character (because the C programming language uses backslash a special 'escape' character - e.g. '\r' indicates carriage return), but the same is not true of the forward slash character.

Just another incentive to use forward slashes instead of backslashes in pathnames. :-)

Hrrm... I will have to look into this further. I was going by what I thought I remembered back when converting modules for linux compatibility. I thought the single forward slash did not work when used in a sprintf, and my code from that time is and has been working with two forward slashes.

But, what you say makes sense. I would think it would only apply to the backslash in retrospect. I will do some tests here with this to see what turns up.